From cec230b21e03b81d5bd6cabed0c8f2167e52fa90 Mon Sep 17 00:00:00 2001 From: Stefan Holder Date: Mon, 12 Dec 2016 07:35:51 +0100 Subject: [PATCH] Use non-normalized transition metric and remove timeDiff check (#70) For GPX traces with equal timestamps, all transitions had a probability of 1 and hence transitions were not considered during map matching. With directed candidates the siutation got even worse because it could happen that the Viterbi algorithm chose a candidate with wrong direction because penalties from unfavored edges would still result in a transition probability of 1. In this case the resulting map matching path would take unnecessary detours. --- .../com/graphhopper/matching/MapMatching.java | 5 +-- .../graphhopper/matching/MapMatchingMain.java | 3 +- .../matching/util/HmmProbabilities.java | 45 +++---------------- .../matching/util/HmmProbabilitiesTest.java | 18 -------- 4 files changed, 10 insertions(+), 61 deletions(-) delete mode 100644 matching-core/src/test/java/com/graphhopper/matching/util/HmmProbabilitiesTest.java diff --git a/matching-core/src/main/java/com/graphhopper/matching/MapMatching.java b/matching-core/src/main/java/com/graphhopper/matching/MapMatching.java index cda879c6..38c0531e 100644 --- a/matching-core/src/main/java/com/graphhopper/matching/MapMatching.java +++ b/matching-core/src/main/java/com/graphhopper/matching/MapMatching.java @@ -71,7 +71,7 @@ public class MapMatching { private final Graph routingGraph; private final LocationIndexMatch locationIndex; private double measurementErrorSigma = 50.0; - private double transitionProbabilityBeta = 0.00959442; + private double transitionProbabilityBeta = 2.0; private final int nodeCount; private DistanceCalc distanceCalc = new DistancePlaneProjection(); private final RoutingAlgorithmFactory algoFactory; @@ -474,8 +474,7 @@ private void computeTransitionProbabilities(TimeStep= 0."); - } - return Math.abs(linearDistance - routeLength) / (timeDiff * timeDiff); + return Distributions.logExponentialDistribution(beta, transitionMetric); } } diff --git a/matching-core/src/test/java/com/graphhopper/matching/util/HmmProbabilitiesTest.java b/matching-core/src/test/java/com/graphhopper/matching/util/HmmProbabilitiesTest.java deleted file mode 100644 index ae990f0b..00000000 --- a/matching-core/src/test/java/com/graphhopper/matching/util/HmmProbabilitiesTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.graphhopper.matching.util; - -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author Peter Karich - */ -public class HmmProbabilitiesTest { - - @Test - public void testTransitionLogProbability() { - HmmProbabilities instance = new HmmProbabilities(); - // see #13 for the real world problem - assertEquals(0, instance.transitionLogProbability(1, 1, 0), 0.001); - } -}