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

Prevent track from birth component w/o detection #628

Merged
merged 5 commits into from
May 9, 2022

Conversation

ekhunter123
Copy link
Collaborator

Problem: In Gaussian-mixture based trackers, tracks can currently be made from the birth component without a detection.

The GaussianMixtureHypothesiser creates prediction-detection pairs as hypotheses. Each prediction is paired with each TrueDetection and also with a MissedDetection. If the prediction is from the birth component, the hypothesis will get assigned a new tag. Otherwise, the hypothesis will carry the tag from the predicted component. But if the hypothesis is from the birth component with a MissedDetection, then it should not get a new tag. It should keep the "birth" tag because it does not correspond to any real data. This problem is realized later, when the PointProcessMultiTargetTracker checks the tag of each component. If a component does not have the 'birth' tag, then it will try to make a track or add to an existing one. For this if-statement to be effective, we need the birth component to keep its birth tag.

To fix this, I added a new conditional when assigning tags to hypotheses.


Also, pointprocess.py use '0' as the tag of the birth component, , while these other files use 'birth':

tag=component.tag if component.tag != "birth"

I changed pointprocess.py to also use 'birth'.

It may be good to explicitly say that the birth component must have tag 'birth' in the docstring of the birth_component, and/or to check for it in the constructor and raise an error otherwise. Thoughts?

@codecov
Copy link

codecov bot commented May 3, 2022

Codecov Report

Merging #628 (ef1cb4d) into main (d38a196) will increase coverage by 0.01%.
The diff coverage is 88.88%.

@@            Coverage Diff             @@
##             main     #628      +/-   ##
==========================================
+ Coverage   94.22%   94.24%   +0.01%     
==========================================
  Files         158      158              
  Lines        7832     7840       +8     
  Branches     1506     1508       +2     
==========================================
+ Hits         7380     7389       +9     
  Misses        343      343              
+ Partials      109      108       -1     
Flag Coverage Δ
integration 67.81% <88.88%> (+0.02%) ⬆️
unittests 92.00% <88.88%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
stonesoup/tracker/pointprocess.py 93.54% <0.00%> (ø)
stonesoup/hypothesiser/gaussianmixture.py 92.50% <100.00%> (+1.32%) ⬆️
stonesoup/types/state.py 99.59% <100.00%> (+<0.01%) ⬆️
stonesoup/updater/pointprocess.py 98.57% <0.00%> (+1.42%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d38a196...ef1cb4d. Read the comment docs.

@sdhiscocks
Copy link
Member

It may be good to explicitly say that the birth component must have tag 'birth' in the docstring of the birth_component, and/or to check for it in the constructor and raise an error otherwise. Thoughts?

Sounds good. I think we should probably make an explicit definition for it to avoid issues with assuming what the value is.

diff --git a/stonesoup/types/state.py b/stonesoup/types/state.py
index b86c957f..968bbd18 100644
--- a/stonesoup/types/state.py
+++ b/stonesoup/types/state.py
@@ -420,6 +420,8 @@ class TaggedWeightedGaussianState(WeightedGaussianState):
     """
     tag: str = Property(default=None, doc="Unique tag of the Gaussian State.")
 
+    BIRTH = 'birth'
+
     def __init__(self, *args, **kwargs):
         super().__init__(*args, **kwargs)
         if self.tag is None:

such you can check with for example if component.tag == component.BIRTH:

Constant added to class TaggedWeightedGaussianState.
@ekhunter123
Copy link
Collaborator Author

Sounds good. I think we should probably make an explicit definition for it to avoid issues with assuming what the value is.

I like that! I made a new commit where I added that BIRTH constant and changed all the files to use it. Did I do that correctly?

@ekhunter123 ekhunter123 marked this pull request as ready for review May 4, 2022 14:02
@ekhunter123 ekhunter123 requested a review from a team as a code owner May 4, 2022 14:02
@ekhunter123 ekhunter123 requested review from jwragg-dstl and bgarthwaite-dstl and removed request for a team May 4, 2022 14:02
Copy link
Contributor

@jwragg-dstl jwragg-dstl left a comment

Choose a reason for hiding this comment

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

All reviewed. Nothing to add from me. Looks to retain the 'Birth Tag' correctly. Thank you very much.

Copy link
Contributor

@jwragg-dstl jwragg-dstl left a comment

Choose a reason for hiding this comment

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

Just adding the approval. Thank you.

Co-authored-by: Steven Hiscocks <sdhiscocks@dstl.gov.uk>
@sdhiscocks sdhiscocks added the bug label May 9, 2022
@sdhiscocks sdhiscocks merged commit ff5263c into dstl:main May 9, 2022
@ekhunter123 ekhunter123 deleted the birth_tag_GM branch May 26, 2022 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants