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

Fix UncertaintyReward bug and improve ExpectedKLDivergence #1066

Merged
merged 1 commit into from
Jul 24, 2024
Merged
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
47 changes: 31 additions & 16 deletions stonesoup/sensormanager/reward.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,21 @@ def __call__(self, config: Mapping[Sensor, Sequence[Action]], tracks: Set[Track]

for sensor in predicted_sensors:

ground_truth_states = dict(
(GroundTruthState(predicted_track.mean,
timestamp=predicted_track.timestamp,
metadata=predicted_track.metadata),
predicted_track)
for predicted_track in predicted_tracks)

detections_set = sensor.measure(
set(ground_truth_states.keys()), noise=self.measurement_noise)

# Assumes one detection per track
detections = {predicted_track: detection
for detection in
sensor.measure({GroundTruthState(predicted_track.mean,
timestamp=predicted_track.timestamp,
metadata=predicted_track.metadata)},
noise=self.measurement_noise)
for predicted_track in predicted_tracks
if isinstance(detection, TrueDetection)}
detections = {
ground_truth_states[detection.groundtruth_path]: detection
for detection in detections_set
if isinstance(detection, TrueDetection)}

for predicted_track, detection in detections.items():
# Generate hypothesis based on prediction/previous update and detection
Expand Down Expand Up @@ -275,7 +281,7 @@ def __call__(self, config: Mapping[Sensor, Sequence[Action]], tracks: Set[Track]
for n, detection in enumerate(detection_set):

# Generate hypothesis based on prediction/previous update and detection
hypothesis = SingleHypothesis(predicted_track, detection)
hypothesis = SingleHypothesis(predicted_track.state, detection)

# Do the update based on this hypothesis and store covariance matrix
update = self.updater.update(hypothesis)
Expand All @@ -301,13 +307,22 @@ def _generate_detections(self, predicted_tracks, sensors, timestamp=None):

for sensor in sensors:
detections = {}
for predicted_track in predicted_tracks:
tmp_detection = sensor.measure(
{GroundTruthState(predicted_track.mean,
timestamp=predicted_track.timestamp,
metadata=predicted_track.metadata)},
noise=self.measurement_noise)
detections.update({predicted_track: tmp_detection})

ground_truth_states = dict(
(GroundTruthState(predicted_track.mean,
timestamp=predicted_track.timestamp,
metadata=predicted_track.metadata),
predicted_track)
for predicted_track in predicted_tracks)

detections_set = sensor.measure(
set(ground_truth_states.keys()), noise=self.measurement_noise)

# Assumes one detection per track
detections = {
ground_truth_states[detection.groundtruth_path]: {detection}
for detection in detections_set
if isinstance(detection, TrueDetection)}

if self.data_associator:
tmp_hypotheses = self.data_associator.associate(
Expand Down