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
406 stars 134 forks source link

Data association with Global Nearest Neighbor Filter not working as expected #824

Open arickGrootveld opened 1 year ago

arickGrootveld commented 1 year ago

I've found that using a global nearest neighbor filter as a data associator in my own code creates an unexpected effect.

Basically, the Global Nearest Neighbor associates the measurement to the first track, rather than the track with the smallest distance.

In reality, this might just be user error, but I wanted to make an issue demonstrating what I'm seeing so that I can be sure this is not a problem with Stone Soup.

See the attached files and script as a demonstration of what I mean (you may have to change the path in the script, so that it points at the pickle files correctly, depending on where you put them). issueDemonstrationFiles.zip

sdhiscocks commented 1 year ago

Thanks for the report @arickGrootveld.

So the issue we've identified is when there is no missed distance set in the DistanceHypothesiser, the default missed distance is then np.inf. This results in the Joint Hypotheses, which sums the combination of individual hypotheses across all tracks, having every sum containing a np.inf in the case that there are less tracks than measurements.

If you use the GNNWith2DAssignment (which we generally recommend to use, as it's much faster) it will raise that the problem is infeasible. The GlobalNearestNeighbour should really also do this, but currently it just returns the first result.

In the interim, adding a large missed distance in the DistanceHypothesier will fix this. In case of using Mahalanobis, then 100 would be fine.

We are thinking a possible fix, would be where the missed distances are all np.inf that setting them to the largest non-missed distance plus epsilon, will ensure that both GlobalNearestNeighbour and GNNWith2DAssignment function correctly in case of having no missed distance defined.

arickGrootveld commented 1 year ago

Thank you so much for getting back to me about this @sdhiscocks. I just verified that setting the "missed_distance" parameter in the initialization of the "DistanceHypothesiser" with a large value (I used 100 as you recommended) fixes the issue entirely.

Would you or your group be interested in having an external pull request for this? It might take me a bit to familiarize myself with your code base, but I could at least give it a shot.

Thanks again for helping me with this, and let me know if you guys would be ok with me taking a shot at fixing it.

sdhiscocks commented 1 year ago

Would you or your group be interested in having an external pull request for this? It might take me a bit to familiarize myself with your code base, but I could at least give it a shot.

Yes, that would be great. Thanks.