dstl / Stone-Soup

A software project to provide the target tracking community with a framework for the development and testing of tracking algorithms.
https://stonesoup.rtfd.io
MIT License
384 stars 126 forks source link

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

Closed timothy-glover closed 9 months ago

timothy-glover commented 9 months ago

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. https://github.com/dstl/Stone-Soup/blob/f24090cc919b3b590b84f965a3884ed1293d181d/stonesoup/updater/tests/test_particle.py#L74