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

Resampling dependant regularisation in ParticleUpdater #869

Closed timothy-glover closed 9 months ago

timothy-glover commented 9 months ago

This PR adds the functionality that prevents regularisation from happening if resampling has not been performed. Since the regularisation process is intended to prevent particle impoverishment as a result of resampling. Performing regularisation when resampling has not been performed may lead to unnecessary particle spreading. The changes in the PR check to see if the ParticleState object is the same before and after resampling. This check prevents negates the problem where a Resampler is defined but the resampling process has not been performed due to the effective sample size threshold not being met. If changes have occurred then the Regulariser will be used if it has been defined.

The changes have been made here in such a way that will allow regularisation to occur if a Resampler has not been provided. The reason for this is if the author has not defined a Resampler but has defined a Regulariser then there must be an exceptional reason for doing so. If this is the case, the ParticleUpdater will warn the user on initialisation.

timothy-glover commented 9 months ago

The test error seems to be a problem with the test_gaussian_particle test in the initiator module. The chance of the assertion error happening is <1%. Changing the tolerance on this test assertion should prevent the error.

hpritchett-dstl commented 9 months ago

Happy to approve this once the test_gaussian_particle test has been addressed.

timothy-glover commented 9 months ago

Happy to approve this once the test_gaussian_particle test has been addressed.

Thank you. I have implemented your suggested change above in a local commit that I will push shortly. It actually pointed me towards a documentation error as I missed the preceding colon before two class type definitions in that doc string.

Regarding the test_gaussian_particle test, I am not sure if this is the right place to fix that. I haven't made any changes to the initiator classes in this PR or caused the test fail. Happy to fix it here though if you think that is the right thing to do.

hpritchett-dstl commented 9 months ago

Regarding the test_gaussian_particle test, I am not sure if this is the right place to fix that. I haven't made any changes to the initiator classes in this PR or caused the test fail. Happy to fix it here though if you think that is the right thing to do.

Yes you're right, should be addressed elsewhere as this PR did not influence it!