Java library · version 1.0

Multiple hypothesis tracking, without writing the bookkeeping.

When a detection could belong to more than one target, the right choice is often only clear later. MHL keeps every plausible hypothesis in a tree, prunes the unlikely ones and tells your application what has become certain. You only describe how one hypothesis grows from the previous one.

best hypothesis pruned
How it works

You describe the alternatives. MHL keeps track of them.

The application never manages the hypotheses tree itself. It works with five ideas, each one an interface of the API in the eu.anorien.mhl package.

1

Events

Event

Something that happened at a point in time, such as “ship #29384 moved from (183.2, 330.2) to (187.9, 334.8) at 22:43”. Once an event is certain (its probability reaches 1), the library sends it to your application.

2

Facts

Fact

A piece of the current state of the world, such as “ship #29384 is at (187.9, 334.8)”. The library keeps facts for you, one version per hypothesis, and hands them back when you need them to grow a hypothesis.

3

Hypothesis generation

HypothesesGenerator

When new data arrives you ask for a generation, naming the events and facts it depends on. The library calls your generator once per leaf of the tree where those are available, and you return the alternatives, each with its probability and its new events and facts.

4

Pruning

Pruner

The tree would grow without limit, so a pruner keeps it in check: keep only the best K leaves, cap the tree's depth, or chain several pruners together.

5

Watching

Watcher

Register a watcher to hear what became certain (confirmed events, facts added or removed) and when the best hypothesis changes, or ask for the best hypothesis at any time.

The API (MHL) and its implementation are separate: your code depends only on the API, and the implementation, such as Lisbon MHL, is found at run time through Java's ServiceLoader.

Quick start

From an empty project to a tracker

Put the API, an implementation and its libraries on the classpath, then set up a hypotheses manager once and ask for a generation whenever new data arrives. The code below is shortened from the Simple Tracker example; its full source is in the download.

Classpath

MHL1.0.jar              # the API
LisbonMHL-1.0.jar       # the implementation
lib/*.jar               # JUNG 2.0, collections-generic, log4j (in the Lisbon MHL zip)

Set up the library

// 1. Find the implementation on the classpath and create a hypotheses manager
MHLService service = ServiceLoader.load(MHLService.class).iterator().next();
Factory factory = service.getFactory();
HypothesesManager hm = factory.newHypothesesManager();

// 2. Keep the tree small: the best 100 leaves, at most 10 levels deep
PrunerFactory pruners = factory.getPrunerFactory();
hm.setPruner(pruners.newCompositePruner(new Pruner[]{
        pruners.newBestKPruner(100),
        pruners.newTreeDepthPruner(10)}));

// 3. Hear about what becomes certain
hm.register(myWatcher);

Generate hypotheses

// 4. For each new scan, ask for a generation that needs this target's fact
Set<Fact> reqFacts = Collections.singleton(target);
hm.generateHypotheses(new HypothesesGenerator() {
    public GeneratedHypotheses generate(Set<Event> events, Set<Fact> facts) {
        List<GeneratedHypothesis> alternatives = new ArrayList<GeneratedHypothesis>();
        TargetFact t = (TargetFact) facts.iterator().next();
        // the target was detected at p ...
        alternatives.add(factory.newGeneratedHypothesis(probDetected,
                noEvents, Collections.singleton(t.movedTo(p))));
        // ... or it wasn't, and only moved on
        alternatives.add(factory.newGeneratedHypothesis(probUndetected,
                noEvents, Collections.singleton(t.predicted())));
        return factory.newGeneratedHypotheses(alternatives);
    }
}, noEvents, reqFacts);

// 5. Read the most likely state of the world
Hypothesis best = hm.getBestHypothesis();

Events and facts must never change after they are created, and must implement equals and hashCode: the library compares them to know which hypotheses share them.

Demos

See it tracking

Two example applications, each in a single jar with everything it needs. Download one and start it with the command below its description (Java 6 or later).

Simple Tracker

The smallest complete tracker built on MHL: detections come in, the library keeps the competing hypotheses on which detection belongs to which target, and the best one is shown.

java -cp SimpleTrackerFull.jar com.multiplehypothesis.simpletracker.Main
Download SimpleTrackerFull.jar (2.0 MB)

Radar Simulator

A simulated radar with several targets: each track is followed by a Kalman filter, and MHL resolves which radar return belongs to which track.

java -cp RadarSimFull.jar eu.anorien.radarsim.RadarSim
Download RadarSimFull.jar (3.9 MB)
Downloads

Version 1.0

Each package includes its README and license. To use the library you need the API and an implementation; the examples include both.

PackageContentsLicenseSize
MHL 1.0 — API
MHL1.0.zip
The API only: the interfaces an application programs against, with their sources and javadoc. It needs an implementation to run, such as Lisbon MHL. MIT 126 KB
Lisbon MHL 1.0 — implementation
LisbonMHL1.0.zip
An implementation of the MHL API, with the libraries it needs (JUNG 2.0, collections-generic, log4j). CC BY-NC-SA 3.0 1.6 MB
Simple Tracker 1.0
SimpleTracker1.0.zip
The smallest complete example: a tracker written with MHL, with its sources. MIT 1.7 MB
Radar Simulator 1.0
RadarSim1.0.zip
A radar simulator that tracks targets with MHL and a Kalman filter, with its sources. MIT 3.4 MB
Matlab example
MatlabExampleApp.zip
Using MHL from Matlab, through Matlab's Java bridge. CC BY-NC-SA 3.0 4.0 MB
Documentation

Reference and licenses

API reference

The javadoc of MHL 1.0: every interface, with what the library expects from your events, facts and generators.

Open the javadoc

Licenses

The MHL API and the Simple Tracker and Radar Simulator examples are released under the MIT license. The Lisbon MHL implementation and the Matlab example are released under Creative Commons BY-NC-SA 3.0: free for non-commercial use, with attribution, sharing adaptations under the same terms. The licenses of the bundled third-party libraries are in each package.

Contact

For requests, help or questions, write to David Miguel Antunes: