Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce ability to constrain particle states in ParticleUpdater and MCMCRegulariser #855

Merged

Conversation

timothy-glover
Copy link
Contributor

This PR has introduced the optional property constraint_func to ParticleUpdater and MCMCRegulariser. If defined, this is intended to enforce that particle states should not exceed certain values by modifying the associated weights, increasing the likelihood of resampling. Here the constraint function should accept a ParticleState type and return a logical index of particles that exceed the defined constraints. An example of this can be seen here:
https://github.com/timothy-glover/Stone-Soup/blob/7ae343e147176107a35fafa81c00c2a7d879561e/stonesoup/regulariser/tests/test_particle.py#L16-L18

A bug was also spotted in the test for the ParticleUpdater. The original line, seen below, was passing regardless of what the weights are. This has been replaced with a check to ensure the sum of the weights is correct.

assert np.all(weight == 1 / 9 for weight in updated_state.weight)

@timothy-glover timothy-glover requested a review from a team as a code owner September 13, 2023 16:06
@timothy-glover timothy-glover requested review from hpritchett-dstl and mharris-dstl and removed request for a team September 13, 2023 16:06
Comment on lines 38 to 39
"constraints to particle states. This is done by reverting "
"that are moved to a state outside of the defined constraints "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"constraints to particle states. This is done by reverting "
"that are moved to a state outside of the defined constraints "
"constraints to particle states. This is done by reverting particles "
"that are moved to a state outside of the defined constraints "

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well spotted. Fixed and improved clarity in latest commit.

@sdhiscocks sdhiscocks merged commit 900538e into dstl:main Sep 29, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants