reproduced
This commit is contained in:
		
							parent
							
								
									3eaa676626
								
							
						
					
					
						commit
						98e8c2e06c
					
				| @ -214,7 +214,7 @@ struct PhantomNode | |||||||
|     util::Coordinate input_location; |     util::Coordinate input_location; | ||||||
|     unsigned short fwd_segment_position; |     unsigned short fwd_segment_position; | ||||||
|     // is phantom node valid to be used as source or target
 |     // is phantom node valid to be used as source or target
 | ||||||
|   private: |   //private:
 | ||||||
|     unsigned short is_valid_forward_source : 1; |     unsigned short is_valid_forward_source : 1; | ||||||
|     unsigned short is_valid_forward_target : 1; |     unsigned short is_valid_forward_target : 1; | ||||||
|     unsigned short is_valid_reverse_source : 1; |     unsigned short is_valid_reverse_source : 1; | ||||||
|  | |||||||
| @ -734,29 +734,9 @@ double getNetworkDistance(SearchEngineData<Algorithm> &engine_working_data, | |||||||
|     //     }
 |     //     }
 | ||||||
|     // }
 |     // }
 | ||||||
| 
 | 
 | ||||||
|     if (!forward_heap.Empty()) |  | ||||||
|     { |  | ||||||
|         if (target_phantom.IsValidForwardTarget() && !target_phantom.IsValidReverseTarget()) |  | ||||||
|         { |  | ||||||
|             if (const auto node = |  | ||||||
|                     forward_heap.GetHeapNodeIfWasInserted(target_phantom.forward_segment_id.id)) |  | ||||||
|             { |  | ||||||
|                 if (node->weight < weight_upper_bound) { |  | ||||||
|                     return from_alias<double>(node->data.distance); |  | ||||||
|                 }  |  | ||||||
|                 return std::numeric_limits<double>::max(); |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         // if (target_phantom.IsValidReverseTarget()) {
 |  | ||||||
|         //     if (const auto node =
 |  | ||||||
|         //     forward_heap.GetHeapNodeIfWasInserted(target_phantom.reverse_segment_id.id)) {
 |  | ||||||
|         //         return from_alias<double>(node->data.distance);
 |  | ||||||
|         //     }
 |  | ||||||
|         // }
 |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     forward_heap.Clear(); |  | ||||||
| 
 | 
 | ||||||
|  |   //  forward_heap.Clear();
 | ||||||
|  |  if (forward_heap.Empty()) { | ||||||
|     if (source_phantom.IsValidForwardSource()) |     if (source_phantom.IsValidForwardSource()) | ||||||
|     { |     { | ||||||
|         forward_heap.Insert(source_phantom.forward_segment_id.id, |         forward_heap.Insert(source_phantom.forward_segment_id.id, | ||||||
| @ -770,6 +750,7 @@ double getNetworkDistance(SearchEngineData<Algorithm> &engine_working_data, | |||||||
|                             EdgeWeight{0}, |                             EdgeWeight{0}, | ||||||
|                             {source_phantom.reverse_segment_id.id, false, EdgeDistance{0}}); |                             {source_phantom.reverse_segment_id.id, false, EdgeDistance{0}}); | ||||||
|     } |     } | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
|     if (target_phantom.IsValidForwardTarget()) |     if (target_phantom.IsValidForwardTarget()) | ||||||
|     { |     { | ||||||
|  | |||||||
| @ -1,4 +1,5 @@ | |||||||
| #include "engine/routing_algorithms/map_matching.hpp" | #include "engine/routing_algorithms/map_matching.hpp" | ||||||
|  | #include "engine/phantom_node.hpp" | ||||||
| #include "engine/routing_algorithms/routing_base_ch.hpp" | #include "engine/routing_algorithms/routing_base_ch.hpp" | ||||||
| #include "engine/routing_algorithms/routing_base_mld.hpp" | #include "engine/routing_algorithms/routing_base_mld.hpp" | ||||||
| 
 | 
 | ||||||
| @ -13,6 +14,7 @@ | |||||||
| #include <cstddef> | #include <cstddef> | ||||||
| #include <deque> | #include <deque> | ||||||
| #include <iomanip> | #include <iomanip> | ||||||
|  | #include <limits> | ||||||
| #include <memory> | #include <memory> | ||||||
| #include <numeric> | #include <numeric> | ||||||
| #include <utility> | #include <utility> | ||||||
| @ -217,78 +219,96 @@ SubMatchingList mapMatching(SearchEngineData<Algorithm> &engine_working_data, | |||||||
|             const EdgeWeight weight_upper_bound = to_alias<EdgeWeight>( |             const EdgeWeight weight_upper_bound = to_alias<EdgeWeight>( | ||||||
|                 ((haversine_distance + max_distance_delta) / 4.) * facade.GetWeightMultiplier()); |                 ((haversine_distance + max_distance_delta) / 4.) * facade.GetWeightMultiplier()); | ||||||
| 
 | 
 | ||||||
|             std::vector<double> old_distances; |            | ||||||
|             for (const auto s : util::irange<std::size_t>(0UL, prev_viterbi.size())) |  | ||||||
|             { |  | ||||||
|                 if (prev_pruned[s]) |  | ||||||
|                 { |  | ||||||
|                     continue; |  | ||||||
|                 } |  | ||||||
| 
 | 
 | ||||||
|                 forward_heap.Clear(); |             std::vector<PhantomNode> test_sources; | ||||||
|  |             std::vector<PhantomNode> test_targets; | ||||||
| 
 | 
 | ||||||
|                 for (const auto s_prime : util::irange<std::size_t>(0UL, current_viterbi.size())) |             test_sources.resize(2); | ||||||
|                 { |             test_targets.resize(2); | ||||||
|                     const double emission_pr = emission_log_probabilities[t][s_prime]; |  | ||||||
|                     double new_value = prev_viterbi[s] + emission_pr; |  | ||||||
|                     if (current_viterbi[s_prime] > new_value) |  | ||||||
|                     { |  | ||||||
|                         continue; |  | ||||||
|                     } |  | ||||||
| 
 | 
 | ||||||
|                     double network_distance = |             test_sources[0].forward_segment_id.id = 273; | ||||||
|                         getNetworkDistanceOld(engine_working_data, |             test_sources[0].forward_segment_id.enabled = 1; | ||||||
|                                               facade, |             test_sources[0].is_valid_forward_source = true; | ||||||
|                                               forward_heap, | 
 | ||||||
|                                               reverse_heap, |             test_sources[0].reverse_segment_id.id = 2147483647; | ||||||
|                                               prev_unbroken_timestamps_list[s].phantom_node, |             test_sources[0].reverse_segment_id.enabled = 0; | ||||||
|                                               current_timestamps_list[s_prime].phantom_node, | 
 | ||||||
|                                               weight_upper_bound); |             test_targets[0].forward_segment_id.id = 197; | ||||||
|                     old_distances.push_back(network_distance); |             test_targets[0].forward_segment_id.enabled = 1; | ||||||
|                 } |             test_targets[0].is_valid_forward_target = true; | ||||||
|             } | 
 | ||||||
|  | 
 | ||||||
|  |             test_targets[0].reverse_segment_id.id = 268; | ||||||
|  |             test_targets[0].reverse_segment_id.enabled = 0; | ||||||
|  | 
 | ||||||
|  |             test_sources[1].forward_segment_id.id = 215; | ||||||
|  |             test_sources[1].forward_segment_id.enabled = 1; | ||||||
|  |             test_sources[0].is_valid_forward_source = true; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |             test_sources[1].reverse_segment_id.id = 2147483647; | ||||||
|  |             test_sources[1].reverse_segment_id.enabled = 0; | ||||||
|  | 
 | ||||||
|  |             test_targets[1].forward_segment_id.id = 197; | ||||||
|  |             test_targets[1].forward_segment_id.enabled = 0; | ||||||
|  | 
 | ||||||
|  |             test_targets[1].reverse_segment_id.id = 268; | ||||||
|  |             test_targets[1].reverse_segment_id.enabled = 1; | ||||||
|  |             test_targets[1].is_valid_reverse_target = true; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |             // std::vector<double> old_distances;
 | ||||||
|  | 
 | ||||||
|  |             // for (const auto& s: test_sources) {
 | ||||||
|  |             //     for (const auto& t: test_targets) {
 | ||||||
|  |             //         forward_heap.Clear();
 | ||||||
|  |             //         double network_distance =
 | ||||||
|  |             //             getNetworkDistanceOld(engine_working_data,
 | ||||||
|  |             //                                facade,
 | ||||||
|  |             //                                forward_heap,
 | ||||||
|  |             //                                reverse_heap,
 | ||||||
|  |             //                                s,
 | ||||||
|  |             //                                t,
 | ||||||
|  |             //                                weight_upper_bound);
 | ||||||
|  |             //         old_distances.push_back(network_distance);
 | ||||||
|  |                  | ||||||
|  |             //     }
 | ||||||
|  |             // }
 | ||||||
| 
 | 
 | ||||||
|             std::vector<double> new_distances; |             std::vector<double> new_distances; | ||||||
|             for (const auto s : util::irange<std::size_t>(0UL, prev_viterbi.size())) |  | ||||||
|             { |  | ||||||
|                 if (prev_pruned[s]) |  | ||||||
|                 { |  | ||||||
|                     continue; |  | ||||||
|                 } |  | ||||||
| 
 |  | ||||||
|                 forward_heap.Clear(); |  | ||||||
| 
 |  | ||||||
|                 for (const auto s_prime : util::irange<std::size_t>(0UL, current_viterbi.size())) |  | ||||||
|                 { |  | ||||||
|                     const double emission_pr = emission_log_probabilities[t][s_prime]; |  | ||||||
|                     double new_value = prev_viterbi[s] + emission_pr; |  | ||||||
|                     if (current_viterbi[s_prime] > new_value) |  | ||||||
|                     { |  | ||||||
|                         continue; |  | ||||||
|                     } |  | ||||||
| 
 | 
 | ||||||
|  |             for (const auto& s: test_sources) { | ||||||
|  |                     forward_heap.Clear(); | ||||||
|  |                  | ||||||
|  |                 for (const auto& t: test_targets) { | ||||||
|  |                      | ||||||
|                     double network_distance = |                     double network_distance = | ||||||
|                         getNetworkDistance(engine_working_data, |                         getNetworkDistance(engine_working_data, | ||||||
|                                            facade, |                                            facade, | ||||||
|                                            forward_heap, |                                            forward_heap, | ||||||
|                                            reverse_heap, |                                            reverse_heap, | ||||||
|                                            prev_unbroken_timestamps_list[s].phantom_node, |                                            s, | ||||||
|                                            current_timestamps_list[s_prime].phantom_node, |                                            t, | ||||||
|                                            weight_upper_bound); |                                            weight_upper_bound); | ||||||
|                     new_distances.push_back(network_distance); |                     new_distances.push_back(network_distance); | ||||||
|  |                  | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             BOOST_ASSERT(old_distances.size() == new_distances.size()); |             std::vector<double> expected = {663.997, 1533.04, std::numeric_limits<double>::max(), std::numeric_limits<double>::max()}; | ||||||
|             for (std::size_t i = 0; i < old_distances.size(); i++) |             if (new_distances.size() != expected.size()) { | ||||||
|             { |                 std::cerr << "New distances size is not equal to expected size" << std::endl; | ||||||
|                 if (std::abs(old_distances[i] - new_distances[i]) > 1e-3) |                 std::exit(1); | ||||||
|                 { |             } | ||||||
|                     std::cout << "Old: " << old_distances[i] << " New: " << new_distances[i] |             for (size_t index = 0; index < new_distances.size(); index++) { | ||||||
|                               << std::endl; |                 if (std::abs(new_distances[index] - expected[index]) > 1e-1) { | ||||||
|  |                     std::cerr << "New: " << new_distances[index] << " Expected: " << expected[index] << std::endl; | ||||||
|  |                     std::exit(1); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|             // compute d_t for this timestamp and the next one
 |             // compute d_t for this timestamp and the next one
 | ||||||
|             for (const auto s : util::irange<std::size_t>(0UL, prev_viterbi.size())) |             for (const auto s : util::irange<std::size_t>(0UL, prev_viterbi.size())) | ||||||
|             { |             { | ||||||
| @ -309,7 +329,7 @@ SubMatchingList mapMatching(SearchEngineData<Algorithm> &engine_working_data, | |||||||
|                     } |                     } | ||||||
| 
 | 
 | ||||||
|                     double network_distance = |                     double network_distance = | ||||||
|                         getNetworkDistance(engine_working_data, |                         getNetworkDistanceOld(engine_working_data, | ||||||
|                                            facade, |                                            facade, | ||||||
|                                            forward_heap, |                                            forward_heap, | ||||||
|                                            reverse_heap, |                                            reverse_heap, | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user