-
Notifications
You must be signed in to change notification settings - Fork 141
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
Add SMC-PHD components #798
Conversation
620ccc2
to
c9d980c
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #798 +/- ##
==========================================
+ Coverage 93.40% 93.42% +0.01%
==========================================
Files 201 202 +1
Lines 12700 12813 +113
Branches 2608 2621 +13
==========================================
+ Hits 11863 11970 +107
- Misses 593 595 +2
- Partials 244 248 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
…cleFilter and tidy up tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Some spelling mistakes and spelling consistency changes.
stonesoup/updater/particle.py
Outdated
.. note:: | ||
|
||
- It is assumed that the proposal distribution is the same as the dynamics | ||
- Target "spawing" is not implemented |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Target "spawing" is not implemented | |
- Target "spawning" is not implemented |
stonesoup/updater/particle.py
Outdated
|
||
# Resample | ||
if self.resampler is not None: | ||
# Normalize weights |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Normalize weights | |
# Normalise weights |
stonesoup/updater/particle.py
Outdated
updated_state.log_weight = log_post_weights - log_num_targets | ||
# Resample | ||
updated_state = self.resampler.resample(updated_state, self.num_samples) | ||
# De-normalize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# De-normalize | |
# De-normalise |
|
||
# Compute measurement prediction | ||
if self.predict_measurement: | ||
measurement_prediction = self.updater.predict_measurement( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codecov reported as not covered by test, which seems odd when test below should be setting predict_measurement
to True and False.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice spot. I have added an extra test case to make sure we reach that part of the code.
stonesoup/predictor/particle.py
Outdated
.. note:: | ||
|
||
- It is assumed that the proposal distribution is the same as the dynamics | ||
- Target "spawing" is not implemented |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Target "spawing" is not implemented | |
- Target "spawning" is not implemented |
stonesoup/predictor/particle.py
Outdated
doc="The field name of the number of samples parameter for the birth sampler. This is " | ||
"required since the number of samples required for the birth sampler may be vary" | ||
"between iterations. Default is 'num_samples'") | ||
birth_scheme: Literal["expansion", "mixture"] = Property( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be better as an Enum, but also support strings. Similar to plotting which use Enum but also supports int's.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds sensible. My only question is then where to place/document this Enum.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this file would be fine?
stonesoup/updater/particle.py
Outdated
g = self._get_measurement_loglikelihoods(prediction, detections) | ||
|
||
# Calculate w^{n,i} Eq. (20) of [2] | ||
Ck = self.prob_detect.log() + g + prediction.log_weight[:, np.newaxis] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ck = self.prob_detect.log() + g + prediction.log_weight[:, np.newaxis] | |
Ck = np.log(self.prob_detect) + g + prediction.log_weight[:, np.newaxis] |
stonesoup/updater/particle.py
Outdated
clutter_intensity: float = Property( | ||
doc="Average number of clutter measurements per time step, per unit volume") | ||
num_samples: int = Property( | ||
default=1024, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to have option of None
as well (possibly even default), where it is the set to number of particles on input prediction?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds sensible. I have done this, but also added a note to emphasise that users should set this value when used in conjunction with a predictor that performs birth via expansion.
stonesoup/hypothesiser/simple.py
Outdated
|
||
if self.check_timestamp: | ||
# Check to make sure all detections are obtained from the same time | ||
timestamps = set([detection.timestamp for detection in detections]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
timestamps = set([detection.timestamp for detection in detections]) | |
timestamps = {detection.timestamp for detection in detections} |
@sdhiscocks @jswright-dstl, I have applied the requested changes and improved the documentation slightly. |
This PR adds the following components:
SMCPHDPredictor
: Performs the SMC-PHD prediction stepSMCPHDUpdater
: Performs the SMC-PHD update stepSimpleHypothesiser
: A configurable hypothesiser that generates a sequence ofSingleHypothesis
objects (used to generate the hypotheses required by theSMCPHDUpdater
)A running example can be found here