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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/tutorials/11_GMPHDTutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@
state_vector=truth.state_vector,
covar=covar**2,
weight=0.25,
tag='birth',
tag=TaggedWeightedGaussianState.BIRTH,
timestamp=start_time)
tracks.add(Track(new_track))

Expand Down
13 changes: 11 additions & 2 deletions stonesoup/hypothesiser/gaussianmixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from ..types.prediction import (TaggedWeightedGaussianStatePrediction,
WeightedGaussianStatePrediction)
from ..types.state import TaggedWeightedGaussianState
from ..types.detection import MissedDetection


class GaussianMixtureHypothesiser(Hypothesiser):
Expand Down Expand Up @@ -59,10 +60,18 @@ def hypothesise(self, components, detections, timestamp, **kwargs):
**kwargs)
for hypothesis in component_hypotheses:
if isinstance(component, TaggedWeightedGaussianState):
# Ensure that a birth component without a measurement retains
# the birth tag. This will prevent a track from being made
if component.tag == component.BIRTH and \
isinstance(hypothesis.measurement, MissedDetection):
tag = component.BIRTH
elif component.tag == component.BIRTH:
tag = None # a new tag will be made
else:
tag = component.tag
hypothesis.prediction = \
TaggedWeightedGaussianStatePrediction(
tag=component.tag if component.tag != "birth"
else None,
tag=tag,
weight=component.weight,
state_vector=hypothesis.prediction.state_vector,
covar=hypothesis.prediction.covar,
Expand Down
7 changes: 4 additions & 3 deletions stonesoup/tracker/pointprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ class PointProcessMultiTargetTracker(Tracker):
default=None,
doc="The birth component. The weight should be "
"equal to the mean of the expected number of "
"births per timestep (Poission distributed)")
"births per timestep (Poission distributed). "
"The tag should be "
":attr:`TaggedWeightedGaussianState.BIRTH`")

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand Down Expand Up @@ -64,8 +66,7 @@ def update_tracks(self):
"""
for component in self.gaussian_mixture:
tag = component.tag
if tag != 0:
# Sanity check for birth component
if tag != component.BIRTH: # Sanity check for birth component
if tag in self.target_tracks:
# Track found, so update it
track = self.target_tracks[tag]
Expand Down
2 changes: 1 addition & 1 deletion stonesoup/tracker/tests/test_pointprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_point_process_multi_target_tracker_cycle(detector, predictor):
birth_mean,
birth_covar,
weight=0.3,
tag="birth",
tag=TaggedWeightedGaussianState.BIRTH,
timestamp=timestamp)

# Initialise a Kalman Updater
Expand Down
3 changes: 3 additions & 0 deletions stonesoup/types/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,9 @@ class TaggedWeightedGaussianState(WeightedGaussianState):
"""
tag: str = Property(default=None, doc="Unique tag of the Gaussian State.")

BIRTH = 'birth'
ekhunter123 marked this conversation as resolved.
Show resolved Hide resolved
'''Tag value used to signify birth component'''

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
if self.tag is None:
Expand Down