From a372ade7ce145f35f16989e59ce71bcc874975a8 Mon Sep 17 00:00:00 2001 From: Patrick Niklaus Date: Tue, 17 Mar 2015 01:00:04 +0100 Subject: [PATCH] Mark suspicious transitions --- data_structures/hidden_markov_model.hpp | 4 ++++ routing_algorithms/map_matching.hpp | 9 +++++++-- util/matching_debug_info.hpp | 5 ++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/data_structures/hidden_markov_model.hpp b/data_structures/hidden_markov_model.hpp index 403f76608..cccaf7b5d 100644 --- a/data_structures/hidden_markov_model.hpp +++ b/data_structures/hidden_markov_model.hpp @@ -80,6 +80,7 @@ template struct HiddenMarkovModel std::vector>> parents; std::vector> path_lengths; std::vector> pruned; + std::vector> suspicious; std::vector breakage; const CandidateLists &candidates_list; @@ -95,6 +96,7 @@ template struct HiddenMarkovModel viterbi.emplace_back(l.size()); parents.emplace_back(l.size()); path_lengths.emplace_back(l.size()); + suspicious.emplace_back(l.size()); pruned.emplace_back(l.size()); } @@ -111,6 +113,7 @@ template struct HiddenMarkovModel std::fill(viterbi[t].begin(), viterbi[t].end(), osrm::matching::IMPOSSIBLE_LOG_PROB); std::fill(parents[t].begin(), parents[t].end(), std::make_pair(0u, 0u)); std::fill(path_lengths[t].begin(), path_lengths[t].end(), 0); + std::fill(suspicious[t].begin(), suspicious[t].end(), true); std::fill(pruned[t].begin(), pruned[t].end(), true); } std::fill(breakage.begin() + initial_timestamp, breakage.end(), true); @@ -129,6 +132,7 @@ template struct HiddenMarkovModel parents[initial_timestamp][s] = std::make_pair(initial_timestamp, s); pruned[initial_timestamp][s] = viterbi[initial_timestamp][s] < osrm::matching::MINIMAL_LOG_PROB; + suspicious[initial_timestamp][s] = false; breakage[initial_timestamp] = breakage[initial_timestamp] && pruned[initial_timestamp][s]; diff --git a/routing_algorithms/map_matching.hpp b/routing_algorithms/map_matching.hpp index 75598ca2c..eb405a8e4 100644 --- a/routing_algorithms/map_matching.hpp +++ b/routing_algorithms/map_matching.hpp @@ -62,6 +62,9 @@ using SubMatchingList = std::vector; constexpr static const unsigned MAX_BROKEN_STATES = 6; constexpr static const unsigned MAX_BROKEN_TIME = 60; +constexpr static const unsigned MAX_DISTANCE_DELTA = 500; +constexpr static const unsigned SUSPICIOUS_DISTANCE_DELTA = 100; + constexpr static const double default_beta = 10.0; constexpr static const double default_sigma_z = 4.07; } @@ -168,6 +171,7 @@ class MapMatching final : public BasicRoutingInterface prune - if (d_t > 500) + if (d_t > osrm::matching::MAX_DISTANCE_DELTA) { continue; } @@ -232,6 +236,7 @@ class MapMatching final : public BasicRoutingInterface osrm::matching::SUSPICIOUS_DISTANCE_DELTA; model.breakage[t] = false; } } @@ -255,7 +260,7 @@ class MapMatching final : public BasicRoutingInterface> &viterbi, - const std::vector> &pruned) + const std::vector> &pruned, + const std::vector> &suspicious) { // json logger not enabled if (!logger) @@ -119,6 +120,8 @@ struct MatchingDebugInfo osrm::json::clamp_float(viterbi[t][s_prime]); osrm::json::get(*object, "states", t, s_prime, "pruned") = static_cast(pruned[t][s_prime]); + osrm::json::get(*object, "states", t, s_prime, "suspicious") = + static_cast(suspicious[t][s_prime]); } } }