itroduce ADL via algorithm specific ch, corech and mld namespaces
This commit is contained in:
		
							parent
							
								
									2566f64c34
								
							
						
					
					
						commit
						8c64b01d67
					
				| @ -7,30 +7,36 @@ namespace osrm | ||||
| { | ||||
| namespace engine | ||||
| { | ||||
| namespace algorithm | ||||
| namespace routing_algorithms | ||||
| { | ||||
| 
 | ||||
| // Contraction Hiearchy
 | ||||
| struct CH final | ||||
| namespace ch | ||||
| { | ||||
| struct Algorithm final | ||||
| { | ||||
| }; | ||||
| } | ||||
| // Contraction Hiearchy with core
 | ||||
| struct CoreCH final | ||||
| namespace corech | ||||
| { | ||||
| struct Algorithm final | ||||
| { | ||||
| }; | ||||
| } | ||||
| // Multi-Level Dijkstra
 | ||||
| struct MLD final | ||||
| namespace mld | ||||
| { | ||||
| struct Algorithm final | ||||
| { | ||||
| }; | ||||
| 
 | ||||
| template <typename AlgorithmT> const char *name(); | ||||
| template <> inline const char *name<CH>() { return "CH"; } | ||||
| template <> inline const char *name<CoreCH>() { return "CoreCH"; } | ||||
| template <> inline const char *name<MLD>() { return "MLD"; } | ||||
| } | ||||
| 
 | ||||
| namespace algorithm_trais | ||||
| { | ||||
| // Algorithm names
 | ||||
| template <typename AlgorithmT> const char *name(); | ||||
| template <> inline const char *name<ch::Algorithm>() { return "CH"; } | ||||
| template <> inline const char *name<corech::Algorithm>() { return "CoreCH"; } | ||||
| template <> inline const char *name<mld::Algorithm>() { return "MLD"; } | ||||
| 
 | ||||
| template <typename AlgorithmT> struct HasAlternativePathSearch final : std::false_type | ||||
| { | ||||
| @ -51,62 +57,64 @@ template <typename AlgorithmT> struct HasGetTileTurns final : std::false_type | ||||
| { | ||||
| }; | ||||
| 
 | ||||
| template <> struct HasAlternativePathSearch<algorithm::CH> final : std::true_type | ||||
| // Algorithms supported by Contraction Hierarchies
 | ||||
| template <> struct HasAlternativePathSearch<ch::Algorithm> final : std::true_type | ||||
| { | ||||
| }; | ||||
| template <> struct HasShortestPathSearch<algorithm::CH> final : std::true_type | ||||
| template <> struct HasShortestPathSearch<ch::Algorithm> final : std::true_type | ||||
| { | ||||
| }; | ||||
| template <> struct HasDirectShortestPathSearch<algorithm::CH> final : std::true_type | ||||
| template <> struct HasDirectShortestPathSearch<ch::Algorithm> final : std::true_type | ||||
| { | ||||
| }; | ||||
| template <> struct HasMapMatching<algorithm::CH> final : std::true_type | ||||
| template <> struct HasMapMatching<ch::Algorithm> final : std::true_type | ||||
| { | ||||
| }; | ||||
| template <> struct HasManyToManySearch<algorithm::CH> final : std::true_type | ||||
| template <> struct HasManyToManySearch<ch::Algorithm> final : std::true_type | ||||
| { | ||||
| }; | ||||
| template <> struct HasGetTileTurns<algorithm::CH> final : std::true_type | ||||
| template <> struct HasGetTileTurns<ch::Algorithm> final : std::true_type | ||||
| { | ||||
| }; | ||||
| 
 | ||||
| // Algorithms supported by Contraction Hierarchies with core
 | ||||
| template <> struct HasShortestPathSearch<corech::Algorithm> final : std::true_type | ||||
| { | ||||
| }; | ||||
| template <> struct HasDirectShortestPathSearch<corech::Algorithm> final : std::true_type | ||||
| { | ||||
| }; | ||||
| template <> struct HasMapMatching<corech::Algorithm> final : std::true_type | ||||
| { | ||||
| }; | ||||
| template <> struct HasGetTileTurns<corech::Algorithm> final : std::true_type | ||||
| { | ||||
| }; | ||||
| // disbaled because of perfomance reasons
 | ||||
| template <> struct HasAlternativePathSearch<algorithm::CoreCH> final : std::false_type | ||||
| template <> struct HasAlternativePathSearch<corech::Algorithm> final : std::false_type | ||||
| { | ||||
| }; | ||||
| template <> struct HasManyToManySearch<algorithm::CoreCH> final : std::false_type | ||||
| { | ||||
| }; | ||||
| template <> struct HasShortestPathSearch<algorithm::CoreCH> final : std::true_type | ||||
| { | ||||
| }; | ||||
| template <> struct HasDirectShortestPathSearch<algorithm::CoreCH> final : std::true_type | ||||
| { | ||||
| }; | ||||
| template <> struct HasMapMatching<algorithm::CoreCH> final : std::true_type | ||||
| { | ||||
| }; | ||||
| template <> struct HasGetTileTurns<algorithm::CoreCH> final : std::true_type | ||||
| template <> struct HasManyToManySearch<corech::Algorithm> final : std::false_type | ||||
| { | ||||
| }; | ||||
| 
 | ||||
| // disbaled because of perfomance reasons
 | ||||
| template <> struct HasAlternativePathSearch<algorithm::MLD> final : std::false_type | ||||
| // Algorithms supported by Multi-Level Dijkstra
 | ||||
| template <> struct HasDirectShortestPathSearch<mld::Algorithm> final : std::true_type | ||||
| { | ||||
| }; | ||||
| template <> struct HasManyToManySearch<algorithm::MLD> final : std::false_type | ||||
| template <> struct HasMapMatching<mld::Algorithm> final : std::false_type | ||||
| { | ||||
| }; | ||||
| template <> struct HasShortestPathSearch<algorithm::MLD> final : std::false_type | ||||
| template <> struct HasAlternativePathSearch<mld::Algorithm> final : std::false_type | ||||
| { | ||||
| }; | ||||
| template <> struct HasDirectShortestPathSearch<algorithm::MLD> final : std::true_type | ||||
| template <> struct HasManyToManySearch<mld::Algorithm> final : std::false_type | ||||
| { | ||||
| }; | ||||
| template <> struct HasMapMatching<algorithm::MLD> final : std::false_type | ||||
| template <> struct HasShortestPathSearch<mld::Algorithm> final : std::false_type | ||||
| { | ||||
| }; | ||||
| template <> struct HasGetTileTurns<algorithm::MLD> final : std::false_type | ||||
| template <> struct HasGetTileTurns<mld::Algorithm> final : std::false_type | ||||
| { | ||||
| }; | ||||
| } | ||||
|  | ||||
| @ -17,11 +17,16 @@ namespace engine | ||||
| namespace datafacade | ||||
| { | ||||
| 
 | ||||
| // Namespace local aliases for algorithms
 | ||||
| using CH = routing_algorithms::ch::Algorithm; | ||||
| using CoreCH = routing_algorithms::corech::Algorithm; | ||||
| using MLD = routing_algorithms::mld::Algorithm; | ||||
| 
 | ||||
| using EdgeRange = util::range<EdgeID>; | ||||
| 
 | ||||
| template <typename AlgorithmT> class AlgorithmDataFacade; | ||||
| 
 | ||||
| template <> class AlgorithmDataFacade<algorithm::CH> | ||||
| template <> class AlgorithmDataFacade<CH> | ||||
| { | ||||
|   public: | ||||
|     using EdgeData = contractor::QueryEdge::EdgeData; | ||||
| @ -56,7 +61,7 @@ template <> class AlgorithmDataFacade<algorithm::CH> | ||||
|                                     const std::function<bool(EdgeData)> filter) const = 0; | ||||
| }; | ||||
| 
 | ||||
| template <> class AlgorithmDataFacade<algorithm::CoreCH> | ||||
| template <> class AlgorithmDataFacade<CoreCH> | ||||
| { | ||||
|   public: | ||||
|     using EdgeData = contractor::QueryEdge::EdgeData; | ||||
| @ -64,7 +69,7 @@ template <> class AlgorithmDataFacade<algorithm::CoreCH> | ||||
|     virtual bool IsCoreNode(const NodeID id) const = 0; | ||||
| }; | ||||
| 
 | ||||
| template <> class AlgorithmDataFacade<algorithm::MLD> | ||||
| template <> class AlgorithmDataFacade<MLD> | ||||
| { | ||||
|   public: | ||||
|     using EdgeData = extractor::EdgeBasedEdge::EdgeData; | ||||
|  | ||||
| @ -58,8 +58,7 @@ namespace datafacade | ||||
| template <typename AlgorithmT> class ContiguousInternalMemoryAlgorithmDataFacade; | ||||
| 
 | ||||
| template <> | ||||
| class ContiguousInternalMemoryAlgorithmDataFacade<algorithm::CH> | ||||
|     : public datafacade::AlgorithmDataFacade<algorithm::CH> | ||||
| class ContiguousInternalMemoryAlgorithmDataFacade<CH> : public datafacade::AlgorithmDataFacade<CH> | ||||
| { | ||||
|   private: | ||||
|     using QueryGraph = util::StaticGraph<EdgeData, storage::Ownership::View>; | ||||
| @ -151,8 +150,8 @@ class ContiguousInternalMemoryAlgorithmDataFacade<algorithm::CH> | ||||
| }; | ||||
| 
 | ||||
| template <> | ||||
| class ContiguousInternalMemoryAlgorithmDataFacade<algorithm::CoreCH> | ||||
|     : public datafacade::AlgorithmDataFacade<algorithm::CoreCH> | ||||
| class ContiguousInternalMemoryAlgorithmDataFacade<CoreCH> | ||||
|     : public datafacade::AlgorithmDataFacade<CoreCH> | ||||
| { | ||||
|   private: | ||||
|     util::vector_view<bool> m_is_core_node; | ||||
| @ -869,36 +868,34 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade | ||||
| template <typename AlgorithmT> class ContiguousInternalMemoryDataFacade; | ||||
| 
 | ||||
| template <> | ||||
| class ContiguousInternalMemoryDataFacade<algorithm::CH> | ||||
| class ContiguousInternalMemoryDataFacade<CH> | ||||
|     : public ContiguousInternalMemoryDataFacadeBase, | ||||
|       public ContiguousInternalMemoryAlgorithmDataFacade<algorithm::CH> | ||||
|       public ContiguousInternalMemoryAlgorithmDataFacade<CH> | ||||
| { | ||||
|   public: | ||||
|     ContiguousInternalMemoryDataFacade(std::shared_ptr<ContiguousBlockAllocator> allocator) | ||||
|         : ContiguousInternalMemoryDataFacadeBase(allocator), | ||||
|           ContiguousInternalMemoryAlgorithmDataFacade<algorithm::CH>(allocator) | ||||
|           ContiguousInternalMemoryAlgorithmDataFacade<CH>(allocator) | ||||
| 
 | ||||
|     { | ||||
|     } | ||||
| }; | ||||
| 
 | ||||
| template <> | ||||
| class ContiguousInternalMemoryDataFacade<algorithm::CoreCH> final | ||||
|     : public ContiguousInternalMemoryDataFacade<algorithm::CH>, | ||||
|       public ContiguousInternalMemoryAlgorithmDataFacade<algorithm::CoreCH> | ||||
| class ContiguousInternalMemoryDataFacade<CoreCH> final | ||||
|     : public ContiguousInternalMemoryDataFacade<CH>, | ||||
|       public ContiguousInternalMemoryAlgorithmDataFacade<CoreCH> | ||||
| { | ||||
|   public: | ||||
|     ContiguousInternalMemoryDataFacade(std::shared_ptr<ContiguousBlockAllocator> allocator) | ||||
|         : ContiguousInternalMemoryDataFacade<algorithm::CH>(allocator), | ||||
|           ContiguousInternalMemoryAlgorithmDataFacade<algorithm::CoreCH>(allocator) | ||||
|         : ContiguousInternalMemoryDataFacade<CH>(allocator), | ||||
|           ContiguousInternalMemoryAlgorithmDataFacade<CoreCH>(allocator) | ||||
| 
 | ||||
|     { | ||||
|     } | ||||
| }; | ||||
| 
 | ||||
| template <> | ||||
| class ContiguousInternalMemoryAlgorithmDataFacade<algorithm::MLD> | ||||
|     : public datafacade::AlgorithmDataFacade<algorithm::MLD> | ||||
| template <> class ContiguousInternalMemoryAlgorithmDataFacade<MLD> : public AlgorithmDataFacade<MLD> | ||||
| { | ||||
|     // MLD data
 | ||||
|     partition::MultiLevelPartitionView mld_partition; | ||||
| @ -1065,15 +1062,15 @@ class ContiguousInternalMemoryAlgorithmDataFacade<algorithm::MLD> | ||||
| }; | ||||
| 
 | ||||
| template <> | ||||
| class ContiguousInternalMemoryDataFacade<algorithm::MLD> final | ||||
| class ContiguousInternalMemoryDataFacade<MLD> final | ||||
|     : public ContiguousInternalMemoryDataFacadeBase, | ||||
|       public ContiguousInternalMemoryAlgorithmDataFacade<algorithm::MLD> | ||||
|       public ContiguousInternalMemoryAlgorithmDataFacade<MLD> | ||||
| { | ||||
|   private: | ||||
|   public: | ||||
|     ContiguousInternalMemoryDataFacade(std::shared_ptr<ContiguousBlockAllocator> allocator) | ||||
|         : ContiguousInternalMemoryDataFacadeBase(allocator), | ||||
|           ContiguousInternalMemoryAlgorithmDataFacade<algorithm::MLD>(allocator) | ||||
|           ContiguousInternalMemoryAlgorithmDataFacade<MLD>(allocator) | ||||
| 
 | ||||
|     { | ||||
|     } | ||||
|  | ||||
| @ -64,13 +64,13 @@ template <typename AlgorithmT> class Engine final : public EngineInterface | ||||
|         if (config.use_shared_memory) | ||||
|         { | ||||
|             util::Log(logDEBUG) << "Using shared memory with algorithm " | ||||
|                                 << algorithm::name<AlgorithmT>(); | ||||
|                                 << routing_algorithms::name<AlgorithmT>(); | ||||
|             facade_provider = std::make_unique<WatchingProvider<AlgorithmT>>(); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             util::Log(logDEBUG) << "Using internal memory with algorithm " | ||||
|                                 << algorithm::name<AlgorithmT>(); | ||||
|                                 << routing_algorithms::name<AlgorithmT>(); | ||||
|             facade_provider = | ||||
|                 std::make_unique<ImmutableProvider<AlgorithmT>>(config.storage_config); | ||||
|         } | ||||
| @ -143,7 +143,8 @@ template <typename AlgorithmT> class Engine final : public EngineInterface | ||||
|     const plugins::TilePlugin tile_plugin; | ||||
| }; | ||||
| 
 | ||||
| template <> bool Engine<algorithm::CH>::CheckCompability(const EngineConfig &config) | ||||
| template <> | ||||
| bool Engine<routing_algorithms::ch::Algorithm>::CheckCompability(const EngineConfig &config) | ||||
| { | ||||
|     if (config.use_shared_memory) | ||||
|     { | ||||
| @ -168,9 +169,10 @@ template <> bool Engine<algorithm::CH>::CheckCompability(const EngineConfig &con | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| template <> bool Engine<algorithm::CoreCH>::CheckCompability(const EngineConfig &config) | ||||
| template <> | ||||
| bool Engine<routing_algorithms::corech::Algorithm>::CheckCompability(const EngineConfig &config) | ||||
| { | ||||
|     if (!Engine<algorithm::CH>::CheckCompability(config)) | ||||
|     if (!Engine<routing_algorithms::ch::Algorithm>::CheckCompability(config)) | ||||
|     { | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
| @ -93,32 +93,32 @@ template <typename AlgorithmT> class RoutingAlgorithms final : public RoutingAlg | ||||
| 
 | ||||
|     bool HasAlternativePathSearch() const final override | ||||
|     { | ||||
|         return algorithm_trais::HasAlternativePathSearch<AlgorithmT>::value; | ||||
|         return routing_algorithms::HasAlternativePathSearch<AlgorithmT>::value; | ||||
|     } | ||||
| 
 | ||||
|     bool HasShortestPathSearch() const final override | ||||
|     { | ||||
|         return algorithm_trais::HasShortestPathSearch<AlgorithmT>::value; | ||||
|         return routing_algorithms::HasShortestPathSearch<AlgorithmT>::value; | ||||
|     } | ||||
| 
 | ||||
|     bool HasDirectShortestPathSearch() const final override | ||||
|     { | ||||
|         return algorithm_trais::HasDirectShortestPathSearch<AlgorithmT>::value; | ||||
|         return routing_algorithms::HasDirectShortestPathSearch<AlgorithmT>::value; | ||||
|     } | ||||
| 
 | ||||
|     bool HasMapMatching() const final override | ||||
|     { | ||||
|         return algorithm_trais::HasMapMatching<AlgorithmT>::value; | ||||
|         return routing_algorithms::HasMapMatching<AlgorithmT>::value; | ||||
|     } | ||||
| 
 | ||||
|     bool HasManyToManySearch() const final override | ||||
|     { | ||||
|         return algorithm_trais::HasManyToManySearch<AlgorithmT>::value; | ||||
|         return routing_algorithms::HasManyToManySearch<AlgorithmT>::value; | ||||
|     } | ||||
| 
 | ||||
|     bool HasGetTileTurns() const final override | ||||
|     { | ||||
|         return algorithm_trais::HasGetTileTurns<AlgorithmT>::value; | ||||
|         return routing_algorithms::HasGetTileTurns<AlgorithmT>::value; | ||||
|     } | ||||
| 
 | ||||
|   private: | ||||
| @ -131,7 +131,7 @@ template <typename AlgorithmT> | ||||
| InternalRouteResult | ||||
| RoutingAlgorithms<AlgorithmT>::AlternativePathSearch(const PhantomNodes &phantom_node_pair) const | ||||
| { | ||||
|     return routing_algorithms::alternativePathSearch(heaps, facade, phantom_node_pair); | ||||
|     return routing_algorithms::ch::alternativePathSearch(heaps, facade, phantom_node_pair); | ||||
| } | ||||
| 
 | ||||
| template <typename AlgorithmT> | ||||
| @ -156,7 +156,7 @@ std::vector<EdgeWeight> RoutingAlgorithms<AlgorithmT>::ManyToManySearch( | ||||
|     const std::vector<std::size_t> &source_indices, | ||||
|     const std::vector<std::size_t> &target_indices) const | ||||
| { | ||||
|     return routing_algorithms::manyToManySearch( | ||||
|     return routing_algorithms::ch::manyToManySearch( | ||||
|         heaps, facade, phantom_nodes, source_indices, target_indices); | ||||
| } | ||||
| 
 | ||||
| @ -168,13 +168,13 @@ inline routing_algorithms::SubMatchingList RoutingAlgorithms<AlgorithmT>::MapMat | ||||
|     const std::vector<boost::optional<double>> &trace_gps_precision, | ||||
|     const bool allow_splitting) const | ||||
| { | ||||
|     return routing_algorithms::mapMatching(heaps, | ||||
|                                            facade, | ||||
|                                            candidates_list, | ||||
|                                            trace_coordinates, | ||||
|                                            trace_timestamps, | ||||
|                                            trace_gps_precision, | ||||
|                                            allow_splitting); | ||||
|     return routing_algorithms::ch::mapMatching(heaps, | ||||
|                                                facade, | ||||
|                                                candidates_list, | ||||
|                                                trace_coordinates, | ||||
|                                                trace_timestamps, | ||||
|                                                trace_gps_precision, | ||||
|                                                allow_splitting); | ||||
| } | ||||
| 
 | ||||
| template <typename AlgorithmT> | ||||
| @ -187,42 +187,45 @@ inline std::vector<routing_algorithms::TurnData> RoutingAlgorithms<AlgorithmT>:: | ||||
| 
 | ||||
| // MLD overrides for not implemented
 | ||||
| template <> | ||||
| InternalRouteResult inline RoutingAlgorithms<algorithm::MLD>::AlternativePathSearch( | ||||
|     const PhantomNodes &) const | ||||
| InternalRouteResult inline RoutingAlgorithms< | ||||
|     routing_algorithms::mld::Algorithm>::AlternativePathSearch(const PhantomNodes &) const | ||||
| { | ||||
|     throw util::exception("AlternativePathSearch is not implemented"); | ||||
| } | ||||
| 
 | ||||
| template <> | ||||
| inline InternalRouteResult | ||||
| RoutingAlgorithms<algorithm::MLD>::ShortestPathSearch(const std::vector<PhantomNodes> &, | ||||
|                                                       const boost::optional<bool>) const | ||||
| RoutingAlgorithms<routing_algorithms::mld::Algorithm>::ShortestPathSearch( | ||||
|     const std::vector<PhantomNodes> &, const boost::optional<bool>) const | ||||
| { | ||||
|     throw util::exception("ShortestPathSearch is not implemented"); | ||||
| } | ||||
| 
 | ||||
| template <> | ||||
| inline std::vector<EdgeWeight> | ||||
| RoutingAlgorithms<algorithm::MLD>::ManyToManySearch(const std::vector<PhantomNode> &, | ||||
|                                                     const std::vector<std::size_t> &, | ||||
|                                                     const std::vector<std::size_t> &) const | ||||
| RoutingAlgorithms<routing_algorithms::mld::Algorithm>::ManyToManySearch( | ||||
|     const std::vector<PhantomNode> &, | ||||
|     const std::vector<std::size_t> &, | ||||
|     const std::vector<std::size_t> &) const | ||||
| { | ||||
|     throw util::exception("ManyToManySearch is not implemented"); | ||||
| } | ||||
| 
 | ||||
| template <> | ||||
| inline routing_algorithms::SubMatchingList | ||||
| RoutingAlgorithms<algorithm::MLD>::MapMatching(const routing_algorithms::CandidateLists &, | ||||
|                                                const std::vector<util::Coordinate> &, | ||||
|                                                const std::vector<unsigned> &, | ||||
|                                                const std::vector<boost::optional<double>> &, | ||||
|                                                const bool) const | ||||
| RoutingAlgorithms<routing_algorithms::mld::Algorithm>::MapMatching( | ||||
|     const routing_algorithms::CandidateLists &, | ||||
|     const std::vector<util::Coordinate> &, | ||||
|     const std::vector<unsigned> &, | ||||
|     const std::vector<boost::optional<double>> &, | ||||
|     const bool) const | ||||
| { | ||||
|     throw util::exception("MapMatching is not implemented"); | ||||
| } | ||||
| 
 | ||||
| template <> | ||||
| inline std::vector<routing_algorithms::TurnData> RoutingAlgorithms<algorithm::MLD>::GetTileTurns( | ||||
| inline std::vector<routing_algorithms::TurnData> | ||||
| RoutingAlgorithms<routing_algorithms::mld::Algorithm>::GetTileTurns( | ||||
|     const std::vector<datafacade::BaseDataFacade::RTreeLeaf> &, | ||||
|     const std::vector<std::size_t> &) const | ||||
| { | ||||
|  | ||||
| @ -15,12 +15,13 @@ namespace engine | ||||
| { | ||||
| namespace routing_algorithms | ||||
| { | ||||
| 
 | ||||
| namespace ch | ||||
| { | ||||
| InternalRouteResult | ||||
| alternativePathSearch(SearchEngineData &search_engine_data, | ||||
|                       const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, | ||||
|                       const datafacade::ContiguousInternalMemoryDataFacade<ch::Algorithm> &facade, | ||||
|                       const PhantomNodes &phantom_node_pair); | ||||
| 
 | ||||
| } // namespace ch
 | ||||
| } // namespace routing_algorithms
 | ||||
| } // namespace engine
 | ||||
| } // namespace osrm
 | ||||
|  | ||||
| @ -13,16 +13,18 @@ namespace osrm | ||||
| { | ||||
| namespace engine | ||||
| { | ||||
| 
 | ||||
| namespace routing_algorithms | ||||
| { | ||||
| 
 | ||||
| namespace ch | ||||
| { | ||||
| std::vector<EdgeWeight> | ||||
| manyToManySearch(SearchEngineData &engine_working_data, | ||||
|                  const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, | ||||
|                  const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade, | ||||
|                  const std::vector<PhantomNode> &phantom_nodes, | ||||
|                  const std::vector<std::size_t> &source_indices, | ||||
|                  const std::vector<std::size_t> &target_indices); | ||||
| } // namespace ch
 | ||||
| 
 | ||||
| } // namespace routing_algorithms
 | ||||
| } // namespace engine
 | ||||
|  | ||||
| @ -22,23 +22,27 @@ static const constexpr double DEFAULT_GPS_PRECISION = 5; | ||||
| 
 | ||||
| //[1] "Hidden Markov Map Matching Through Noise and Sparseness";
 | ||||
| //     P. Newson and J. Krumm; 2009; ACM GIS
 | ||||
| SubMatchingList | ||||
| mapMatching(SearchEngineData &engine_working_data, | ||||
|             const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, | ||||
|             const CandidateLists &candidates_list, | ||||
|             const std::vector<util::Coordinate> &trace_coordinates, | ||||
|             const std::vector<unsigned> &trace_timestamps, | ||||
|             const std::vector<boost::optional<double>> &trace_gps_precision, | ||||
|             const bool allow_splitting); | ||||
| namespace ch | ||||
| { | ||||
| SubMatchingList mapMatching(SearchEngineData &engine_working_data, | ||||
|                             const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade, | ||||
|                             const CandidateLists &candidates_list, | ||||
|                             const std::vector<util::Coordinate> &trace_coordinates, | ||||
|                             const std::vector<unsigned> &trace_timestamps, | ||||
|                             const std::vector<boost::optional<double>> &trace_gps_precision, | ||||
|                             const bool allow_splitting); | ||||
| } | ||||
| 
 | ||||
| SubMatchingList | ||||
| mapMatching(SearchEngineData &engine_working_data, | ||||
|             const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CoreCH> &facade, | ||||
|             const CandidateLists &candidates_list, | ||||
|             const std::vector<util::Coordinate> &trace_coordinates, | ||||
|             const std::vector<unsigned> &trace_timestamps, | ||||
|             const std::vector<boost::optional<double>> &trace_gps_precision, | ||||
|             const bool allow_splitting); | ||||
| namespace corech | ||||
| { | ||||
| SubMatchingList mapMatching(SearchEngineData &engine_working_data, | ||||
|                             const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade, | ||||
|                             const CandidateLists &candidates_list, | ||||
|                             const std::vector<util::Coordinate> &trace_coordinates, | ||||
|                             const std::vector<unsigned> &trace_timestamps, | ||||
|                             const std::vector<boost::optional<double>> &trace_gps_precision, | ||||
|                             const bool allow_splitting); | ||||
| } | ||||
| } | ||||
| } | ||||
| } | ||||
|  | ||||
| @ -23,7 +23,7 @@ namespace ch | ||||
| 
 | ||||
| // Stalling
 | ||||
| template <bool DIRECTION, typename HeapT> | ||||
| bool stallAtNode(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, | ||||
| bool stallAtNode(const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade, | ||||
|                  const NodeID node, | ||||
|                  const EdgeWeight weight, | ||||
|                  const HeapT &query_heap) | ||||
| @ -49,7 +49,7 @@ bool stallAtNode(const datafacade::ContiguousInternalMemoryDataFacade<algorithm: | ||||
| } | ||||
| 
 | ||||
| template <bool DIRECTION> | ||||
| void relaxOutgoingEdges(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, | ||||
| void relaxOutgoingEdges(const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade, | ||||
|                         const NodeID node, | ||||
|                         const EdgeWeight weight, | ||||
|                         SearchEngineData::QueryHeap &heap) | ||||
| @ -113,7 +113,7 @@ we need to add an offset to the termination criterion. | ||||
| static constexpr bool ENABLE_STALLING = true; | ||||
| static constexpr bool DISABLE_STALLING = false; | ||||
| template <bool DIRECTION, bool STALLING = ENABLE_STALLING> | ||||
| void routingStep(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, | ||||
| void routingStep(const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade, | ||||
|                  SearchEngineData::QueryHeap &forward_heap, | ||||
|                  SearchEngineData::QueryHeap &reverse_heap, | ||||
|                  NodeID &middle_node_id, | ||||
| @ -186,9 +186,8 @@ void routingStep(const datafacade::ContiguousInternalMemoryDataFacade<algorithm: | ||||
| } | ||||
| 
 | ||||
| template <bool UseDuration> | ||||
| EdgeWeight | ||||
| getLoopWeight(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, | ||||
|               NodeID node) | ||||
| EdgeWeight getLoopWeight(const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade, | ||||
|                          NodeID node) | ||||
| { | ||||
|     EdgeWeight loop_weight = UseDuration ? MAXIMAL_EDGE_DURATION : INVALID_EDGE_WEIGHT; | ||||
|     for (auto edge : facade.GetAdjacentEdgeRange(node)) | ||||
| @ -228,7 +227,7 @@ getLoopWeight(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH | ||||
|  * original edge found. | ||||
|  */ | ||||
| template <typename BidirectionalIterator, typename Callback> | ||||
| void unpackPath(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, | ||||
| void unpackPath(const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade, | ||||
|                 BidirectionalIterator packed_path_begin, | ||||
|                 BidirectionalIterator packed_path_end, | ||||
|                 Callback &&callback) | ||||
| @ -325,7 +324,7 @@ void unpackPath(const FacadeT &facade, | ||||
|  * @param to the node the CH edge finishes at | ||||
|  * @param unpacked_path the sequence of original NodeIDs that make up the expanded CH edge | ||||
|  */ | ||||
| void unpackEdge(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, | ||||
| void unpackEdge(const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade, | ||||
|                 const NodeID from, | ||||
|                 const NodeID to, | ||||
|                 std::vector<NodeID> &unpacked_path); | ||||
| @ -351,7 +350,7 @@ void retrievePackedPathFromSingleHeap(const SearchEngineData::QueryHeap &search_ | ||||
| // && source_phantom.GetForwardWeightPlusOffset() > target_phantom.GetForwardWeightPlusOffset())
 | ||||
| // requires
 | ||||
| // a force loop, if the heaps have been initialized with positive offsets.
 | ||||
| void search(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, | ||||
| void search(const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade, | ||||
|             SearchEngineData::QueryHeap &forward_heap, | ||||
|             SearchEngineData::QueryHeap &reverse_heap, | ||||
|             std::int32_t &weight, | ||||
| @ -361,7 +360,7 @@ void search(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> | ||||
|             const int duration_upper_bound = INVALID_EDGE_WEIGHT); | ||||
| 
 | ||||
| // Alias to be compatible with the overload for CoreCH that needs 4 heaps
 | ||||
| inline void search(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, | ||||
| inline void search(const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade, | ||||
|                    SearchEngineData::QueryHeap &forward_heap, | ||||
|                    SearchEngineData::QueryHeap &reverse_heap, | ||||
|                    SearchEngineData::QueryHeap &, | ||||
| @ -382,31 +381,11 @@ inline void search(const datafacade::ContiguousInternalMemoryDataFacade<algorith | ||||
|            duration_upper_bound); | ||||
| } | ||||
| 
 | ||||
| // assumes that heaps are already setup correctly.
 | ||||
| // A forced loop might be necessary, if source and target are on the same segment.
 | ||||
| // If this is the case and the offsets of the respective direction are larger for the source
 | ||||
| // than the target
 | ||||
| // then a force loop is required (e.g. source_phantom.forward_segment_id ==
 | ||||
| // target_phantom.forward_segment_id
 | ||||
| // && source_phantom.GetForwardWeightPlusOffset() > target_phantom.GetForwardWeightPlusOffset())
 | ||||
| // requires
 | ||||
| // a force loop, if the heaps have been initialized with positive offsets.
 | ||||
| void search(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CoreCH> &facade, | ||||
|             SearchEngineData::QueryHeap &forward_heap, | ||||
|             SearchEngineData::QueryHeap &reverse_heap, | ||||
|             SearchEngineData::QueryHeap &forward_core_heap, | ||||
|             SearchEngineData::QueryHeap &reverse_core_heap, | ||||
|             int &weight, | ||||
|             std::vector<NodeID> &packed_leg, | ||||
|             const bool force_loop_forward, | ||||
|             const bool force_loop_reverse, | ||||
|             int duration_upper_bound = INVALID_EDGE_WEIGHT); | ||||
| 
 | ||||
| bool needsLoopForward(const PhantomNode &source_phantom, const PhantomNode &target_phantom); | ||||
| 
 | ||||
| bool needsLoopBackwards(const PhantomNode &source_phantom, const PhantomNode &target_phantom); | ||||
| 
 | ||||
| double getPathDistance(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, | ||||
| double getPathDistance(const datafacade::ContiguousInternalMemoryDataFacade<ch::Algorithm> &facade, | ||||
|                        const std::vector<NodeID> &packed_path, | ||||
|                        const PhantomNode &source_phantom, | ||||
|                        const PhantomNode &target_phantom); | ||||
| @ -415,20 +394,7 @@ double getPathDistance(const datafacade::ContiguousInternalMemoryDataFacade<algo | ||||
| // If heaps should be adjusted to be initialized outside of this function,
 | ||||
| // the addition of force_loop parameters might be required
 | ||||
| double | ||||
| getNetworkDistance(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CoreCH> &facade, | ||||
|                    SearchEngineData::QueryHeap &forward_heap, | ||||
|                    SearchEngineData::QueryHeap &reverse_heap, | ||||
|                    SearchEngineData::QueryHeap &forward_core_heap, | ||||
|                    SearchEngineData::QueryHeap &reverse_core_heap, | ||||
|                    const PhantomNode &source_phantom, | ||||
|                    const PhantomNode &target_phantom, | ||||
|                    int duration_upper_bound = INVALID_EDGE_WEIGHT); | ||||
| 
 | ||||
| // Requires the heaps for be empty
 | ||||
| // If heaps should be adjusted to be initialized outside of this function,
 | ||||
| // the addition of force_loop parameters might be required
 | ||||
| double | ||||
| getNetworkDistance(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, | ||||
| getNetworkDistance(const datafacade::ContiguousInternalMemoryDataFacade<ch::Algorithm> &facade, | ||||
|                    SearchEngineData::QueryHeap &forward_heap, | ||||
|                    SearchEngineData::QueryHeap &reverse_heap, | ||||
|                    const PhantomNode &source_phantom, | ||||
| @ -437,7 +403,7 @@ getNetworkDistance(const datafacade::ContiguousInternalMemoryDataFacade<algorith | ||||
| 
 | ||||
| // Alias to be compatible with the overload for CoreCH that needs 4 heaps
 | ||||
| inline double | ||||
| getNetworkDistance(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, | ||||
| getNetworkDistance(const datafacade::ContiguousInternalMemoryDataFacade<ch::Algorithm> &facade, | ||||
|                    SearchEngineData::QueryHeap &forward_heap, | ||||
|                    SearchEngineData::QueryHeap &reverse_heap, | ||||
|                    SearchEngineData::QueryHeap &, | ||||
| @ -449,8 +415,44 @@ getNetworkDistance(const datafacade::ContiguousInternalMemoryDataFacade<algorith | ||||
|     return getNetworkDistance( | ||||
|         facade, forward_heap, reverse_heap, source_phantom, target_phantom, duration_upper_bound); | ||||
| } | ||||
| 
 | ||||
| } // namespace ch
 | ||||
| 
 | ||||
| namespace corech | ||||
| { | ||||
| // assumes that heaps are already setup correctly.
 | ||||
| // A forced loop might be necessary, if source and target are on the same segment.
 | ||||
| // If this is the case and the offsets of the respective direction are larger for the source
 | ||||
| // than the target
 | ||||
| // then a force loop is required (e.g. source_phantom.forward_segment_id ==
 | ||||
| // target_phantom.forward_segment_id
 | ||||
| // && source_phantom.GetForwardWeightPlusOffset() > target_phantom.GetForwardWeightPlusOffset())
 | ||||
| // requires
 | ||||
| // a force loop, if the heaps have been initialized with positive offsets.
 | ||||
| void search(const datafacade::ContiguousInternalMemoryDataFacade<corech::Algorithm> &facade, | ||||
|             SearchEngineData::QueryHeap &forward_heap, | ||||
|             SearchEngineData::QueryHeap &reverse_heap, | ||||
|             SearchEngineData::QueryHeap &forward_core_heap, | ||||
|             SearchEngineData::QueryHeap &reverse_core_heap, | ||||
|             int &weight, | ||||
|             std::vector<NodeID> &packed_leg, | ||||
|             const bool force_loop_forward, | ||||
|             const bool force_loop_reverse, | ||||
|             int duration_upper_bound = INVALID_EDGE_WEIGHT); | ||||
| 
 | ||||
| // Requires the heaps for be empty
 | ||||
| // If heaps should be adjusted to be initialized outside of this function,
 | ||||
| // the addition of force_loop parameters might be required
 | ||||
| double | ||||
| getNetworkDistance(const datafacade::ContiguousInternalMemoryDataFacade<corech::Algorithm> &facade, | ||||
|                    SearchEngineData::QueryHeap &forward_heap, | ||||
|                    SearchEngineData::QueryHeap &reverse_heap, | ||||
|                    SearchEngineData::QueryHeap &forward_core_heap, | ||||
|                    SearchEngineData::QueryHeap &reverse_core_heap, | ||||
|                    const PhantomNode &source_phantom, | ||||
|                    const PhantomNode &target_phantom, | ||||
|                    int duration_upper_bound = INVALID_EDGE_WEIGHT); | ||||
| } // namespace corech
 | ||||
| 
 | ||||
| } // namespace routing_algorithms
 | ||||
| } // namespace engine
 | ||||
| } // namespace osrm
 | ||||
|  | ||||
| @ -57,7 +57,7 @@ bool checkParentCellRestriction(CellID cell, LevelID, CellID parent) { return ce | ||||
| } | ||||
| 
 | ||||
| template <bool DIRECTION, typename... Args> | ||||
| void routingStep(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::MLD> &facade, | ||||
| void routingStep(const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade, | ||||
|                  SearchEngineData::MultiLayerDijkstraHeap &forward_heap, | ||||
|                  SearchEngineData::MultiLayerDijkstraHeap &reverse_heap, | ||||
|                  NodeID &middle_node, | ||||
| @ -171,7 +171,7 @@ void routingStep(const datafacade::ContiguousInternalMemoryDataFacade<algorithm: | ||||
| 
 | ||||
| template <typename... Args> | ||||
| std::tuple<EdgeWeight, NodeID, NodeID, std::vector<EdgeID>> | ||||
| search(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::MLD> &facade, | ||||
| search(const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade, | ||||
|        SearchEngineData::MultiLayerDijkstraHeap &forward_heap, | ||||
|        SearchEngineData::MultiLayerDijkstraHeap &reverse_heap, | ||||
|        Args... args) | ||||
|  | ||||
| @ -15,13 +15,13 @@ namespace routing_algorithms | ||||
| 
 | ||||
| InternalRouteResult | ||||
| shortestPathSearch(SearchEngineData &engine_working_data, | ||||
|                    const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, | ||||
|                    const datafacade::ContiguousInternalMemoryDataFacade<ch::Algorithm> &facade, | ||||
|                    const std::vector<PhantomNodes> &phantom_nodes_vector, | ||||
|                    const boost::optional<bool> continue_straight_at_waypoint); | ||||
| 
 | ||||
| InternalRouteResult | ||||
| shortestPathSearch(SearchEngineData &engine_working_data, | ||||
|                    const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CoreCH> &facade, | ||||
|                    const datafacade::ContiguousInternalMemoryDataFacade<corech::Algorithm> &facade, | ||||
|                    const std::vector<PhantomNodes> &phantom_nodes_vector, | ||||
|                    const boost::optional<bool> continue_straight_at_waypoint); | ||||
| 
 | ||||
|  | ||||
| @ -29,7 +29,7 @@ struct TurnData final | ||||
| using RTreeLeaf = datafacade::BaseDataFacade::RTreeLeaf; | ||||
| 
 | ||||
| std::vector<TurnData> | ||||
| getTileTurns(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, | ||||
| getTileTurns(const datafacade::ContiguousInternalMemoryDataFacade<ch::Algorithm> &facade, | ||||
|              const std::vector<RTreeLeaf> &edges, | ||||
|              const std::vector<std::size_t> &sorted_edge_indexes); | ||||
| 
 | ||||
|  | ||||
| @ -19,6 +19,8 @@ namespace engine | ||||
| { | ||||
| namespace routing_algorithms | ||||
| { | ||||
| namespace ch | ||||
| { | ||||
| 
 | ||||
| namespace | ||||
| { | ||||
| @ -48,15 +50,14 @@ struct RankedCandidateNode | ||||
| 
 | ||||
| // todo: reorder parameters
 | ||||
| template <bool DIRECTION> | ||||
| void alternativeRoutingStep( | ||||
|     const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, | ||||
|     QueryHeap &heap1, | ||||
|     QueryHeap &heap2, | ||||
|     NodeID *middle_node, | ||||
|     EdgeWeight *upper_bound_to_shortest_path_weight, | ||||
|     std::vector<NodeID> &search_space_intersection, | ||||
|     std::vector<SearchSpaceEdge> &search_space, | ||||
|     const EdgeWeight min_edge_offset) | ||||
| void alternativeRoutingStep(const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade, | ||||
|                             QueryHeap &heap1, | ||||
|                             QueryHeap &heap2, | ||||
|                             NodeID *middle_node, | ||||
|                             EdgeWeight *upper_bound_to_shortest_path_weight, | ||||
|                             std::vector<NodeID> &search_space_intersection, | ||||
|                             std::vector<SearchSpaceEdge> &search_space, | ||||
|                             const EdgeWeight min_edge_offset) | ||||
| { | ||||
|     QueryHeap &forward_heap = DIRECTION == FORWARD_DIRECTION ? heap1 : heap2; | ||||
|     QueryHeap &reverse_heap = DIRECTION == FORWARD_DIRECTION ? heap2 : heap1; | ||||
| @ -154,7 +155,7 @@ void retrievePackedAlternatePath(const QueryHeap &forward_heap1, | ||||
| // done at this stage
 | ||||
| void computeLengthAndSharingOfViaPath( | ||||
|     SearchEngineData &engine_working_data, | ||||
|     const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, | ||||
|     const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade, | ||||
|     const NodeID via_node, | ||||
|     int *real_length_of_via_path, | ||||
|     int *sharing_of_via_path, | ||||
| @ -319,7 +320,7 @@ void computeLengthAndSharingOfViaPath( | ||||
| // conduct T-Test
 | ||||
| bool viaNodeCandidatePassesTTest( | ||||
|     SearchEngineData &engine_working_data, | ||||
|     const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, | ||||
|     const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade, | ||||
|     QueryHeap &existing_forward_heap, | ||||
|     QueryHeap &existing_reverse_heap, | ||||
|     QueryHeap &new_forward_heap, | ||||
| @ -563,7 +564,7 @@ bool viaNodeCandidatePassesTTest( | ||||
| 
 | ||||
| InternalRouteResult | ||||
| alternativePathSearch(SearchEngineData &engine_working_data, | ||||
|                       const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, | ||||
|                       const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade, | ||||
|                       const PhantomNodes &phantom_node_pair) | ||||
| { | ||||
|     InternalRouteResult raw_route_data; | ||||
| @ -846,6 +847,7 @@ alternativePathSearch(SearchEngineData &engine_working_data, | ||||
|     return raw_route_data; | ||||
| } | ||||
| 
 | ||||
| } // namespace ch
 | ||||
| } // namespace routing_algorithms
 | ||||
| } // namespace engine
 | ||||
| } // namespace osrm}
 | ||||
|  | ||||
| @ -109,7 +109,7 @@ InternalRouteResult directShortestPathSearchImpl( | ||||
| template <> | ||||
| InternalRouteResult directShortestPathSearch( | ||||
|     SearchEngineData &engine_working_data, | ||||
|     const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CoreCH> &facade, | ||||
|     const datafacade::ContiguousInternalMemoryDataFacade<corech::Algorithm> &facade, | ||||
|     const PhantomNodes &phantom_nodes) | ||||
| { | ||||
|     return ch::directShortestPathSearchImpl(engine_working_data, facade, phantom_nodes); | ||||
| @ -118,7 +118,7 @@ InternalRouteResult directShortestPathSearch( | ||||
| template <> | ||||
| InternalRouteResult directShortestPathSearch( | ||||
|     SearchEngineData &engine_working_data, | ||||
|     const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, | ||||
|     const datafacade::ContiguousInternalMemoryDataFacade<ch::Algorithm> &facade, | ||||
|     const PhantomNodes &phantom_nodes) | ||||
| { | ||||
|     return ch::directShortestPathSearchImpl(engine_working_data, facade, phantom_nodes); | ||||
| @ -127,7 +127,7 @@ InternalRouteResult directShortestPathSearch( | ||||
| template <> | ||||
| InternalRouteResult directShortestPathSearch( | ||||
|     SearchEngineData &engine_working_data, | ||||
|     const datafacade::ContiguousInternalMemoryDataFacade<algorithm::MLD> &facade, | ||||
|     const datafacade::ContiguousInternalMemoryDataFacade<mld::Algorithm> &facade, | ||||
|     const PhantomNodes &phantom_nodes) | ||||
| { | ||||
|     engine_working_data.InitializeOrClearMultiLayerDijkstraThreadLocalStorage( | ||||
|  | ||||
| @ -17,6 +17,9 @@ namespace routing_algorithms | ||||
| 
 | ||||
| using ManyToManyQueryHeap = SearchEngineData::ManyToManyQueryHeap; | ||||
| 
 | ||||
| namespace ch | ||||
| { | ||||
| 
 | ||||
| namespace | ||||
| { | ||||
| struct NodeBucket | ||||
| @ -34,7 +37,7 @@ struct NodeBucket | ||||
| using SearchSpaceWithBuckets = std::unordered_map<NodeID, std::vector<NodeBucket>>; | ||||
| 
 | ||||
| template <bool DIRECTION> | ||||
| void relaxOutgoingEdges(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, | ||||
| void relaxOutgoingEdges(const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade, | ||||
|                         const NodeID node, | ||||
|                         const EdgeWeight weight, | ||||
|                         const EdgeWeight duration, | ||||
| @ -69,7 +72,7 @@ void relaxOutgoingEdges(const datafacade::ContiguousInternalMemoryDataFacade<alg | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void forwardRoutingStep(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, | ||||
| void forwardRoutingStep(const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade, | ||||
|                         const unsigned row_idx, | ||||
|                         const unsigned number_of_targets, | ||||
|                         ManyToManyQueryHeap &query_heap, | ||||
| @ -126,11 +129,10 @@ void forwardRoutingStep(const datafacade::ContiguousInternalMemoryDataFacade<alg | ||||
|     relaxOutgoingEdges<FORWARD_DIRECTION>(facade, node, source_weight, source_duration, query_heap); | ||||
| } | ||||
| 
 | ||||
| void backwardRoutingStep( | ||||
|     const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, | ||||
|     const unsigned column_idx, | ||||
|     ManyToManyQueryHeap &query_heap, | ||||
|     SearchSpaceWithBuckets &search_space_with_buckets) | ||||
| void backwardRoutingStep(const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade, | ||||
|                          const unsigned column_idx, | ||||
|                          ManyToManyQueryHeap &query_heap, | ||||
|                          SearchSpaceWithBuckets &search_space_with_buckets) | ||||
| { | ||||
|     const NodeID node = query_heap.DeleteMin(); | ||||
|     const EdgeWeight target_weight = query_heap.GetKey(node); | ||||
| @ -150,7 +152,7 @@ void backwardRoutingStep( | ||||
| 
 | ||||
| std::vector<EdgeWeight> | ||||
| manyToManySearch(SearchEngineData &engine_working_data, | ||||
|                  const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, | ||||
|                  const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade, | ||||
|                  const std::vector<PhantomNode> &phantom_nodes, | ||||
|                  const std::vector<std::size_t> &source_indices, | ||||
|                  const std::vector<std::size_t> &target_indices) | ||||
| @ -240,6 +242,7 @@ manyToManySearch(SearchEngineData &engine_working_data, | ||||
|     return durations_table; | ||||
| } | ||||
| 
 | ||||
| } // namespace ch
 | ||||
| } // namespace routing_algorithms
 | ||||
| } // namespace engine
 | ||||
| } // namespace osrm
 | ||||
|  | ||||
| @ -419,14 +419,15 @@ mapMatchingImpl(SearchEngineData &engine_working_data, | ||||
|     return sub_matchings; | ||||
| } | ||||
| 
 | ||||
| SubMatchingList | ||||
| mapMatching(SearchEngineData &engine_working_data, | ||||
|             const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, | ||||
|             const CandidateLists &candidates_list, | ||||
|             const std::vector<util::Coordinate> &trace_coordinates, | ||||
|             const std::vector<unsigned> &trace_timestamps, | ||||
|             const std::vector<boost::optional<double>> &trace_gps_precision, | ||||
|             const bool use_tidying) | ||||
| namespace ch | ||||
| { | ||||
| SubMatchingList mapMatching(SearchEngineData &engine_working_data, | ||||
|                             const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade, | ||||
|                             const CandidateLists &candidates_list, | ||||
|                             const std::vector<util::Coordinate> &trace_coordinates, | ||||
|                             const std::vector<unsigned> &trace_timestamps, | ||||
|                             const std::vector<boost::optional<double>> &trace_gps_precision, | ||||
|                             const bool use_tidying) | ||||
| { | ||||
|     return mapMatchingImpl(engine_working_data, | ||||
|                            facade, | ||||
| @ -436,15 +437,17 @@ mapMatching(SearchEngineData &engine_working_data, | ||||
|                            trace_gps_precision, | ||||
|                            use_tidying); | ||||
| } | ||||
| } | ||||
| 
 | ||||
| SubMatchingList | ||||
| mapMatching(SearchEngineData &engine_working_data, | ||||
|             const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CoreCH> &facade, | ||||
|             const CandidateLists &candidates_list, | ||||
|             const std::vector<util::Coordinate> &trace_coordinates, | ||||
|             const std::vector<unsigned> &trace_timestamps, | ||||
|             const std::vector<boost::optional<double>> &trace_gps_precision, | ||||
|             const bool use_tidying) | ||||
| namespace corech | ||||
| { | ||||
| SubMatchingList mapMatching(SearchEngineData &engine_working_data, | ||||
|                             const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade, | ||||
|                             const CandidateLists &candidates_list, | ||||
|                             const std::vector<util::Coordinate> &trace_coordinates, | ||||
|                             const std::vector<unsigned> &trace_timestamps, | ||||
|                             const std::vector<boost::optional<double>> &trace_gps_precision, | ||||
|                             const bool use_tidying) | ||||
| { | ||||
| 
 | ||||
|     return mapMatchingImpl(engine_working_data, | ||||
| @ -455,6 +458,7 @@ mapMatching(SearchEngineData &engine_working_data, | ||||
|                            trace_gps_precision, | ||||
|                            use_tidying); | ||||
| } | ||||
| } | ||||
| 
 | ||||
| } // namespace routing_algorithms
 | ||||
| } // namespace engine
 | ||||
|  | ||||
| @ -16,7 +16,7 @@ namespace ch | ||||
|  * @param to the node the CH edge finishes at | ||||
|  * @param unpacked_path the sequence of original NodeIDs that make up the expanded CH edge | ||||
|  */ | ||||
| void unpackEdge(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, | ||||
| void unpackEdge(const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade, | ||||
|                 const NodeID from, | ||||
|                 const NodeID to, | ||||
|                 std::vector<NodeID> &unpacked_path) | ||||
| @ -71,7 +71,7 @@ void retrievePackedPathFromSingleHeap(const SearchEngineData::QueryHeap &search_ | ||||
| // && source_phantom.GetForwardWeightPlusOffset() > target_phantom.GetForwardWeightPlusOffset())
 | ||||
| // requires
 | ||||
| // a force loop, if the heaps have been initialized with positive offsets.
 | ||||
| void search(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, | ||||
| void search(const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade, | ||||
|             SearchEngineData::QueryHeap &forward_heap, | ||||
|             SearchEngineData::QueryHeap &reverse_heap, | ||||
|             EdgeWeight &weight, | ||||
| @ -139,190 +139,6 @@ void search(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| // assumes that heaps are already setup correctly.
 | ||||
| // A forced loop might be necessary, if source and target are on the same segment.
 | ||||
| // If this is the case and the offsets of the respective direction are larger for the source
 | ||||
| // than the target
 | ||||
| // then a force loop is required (e.g. source_phantom.forward_segment_id ==
 | ||||
| // target_phantom.forward_segment_id
 | ||||
| // && source_phantom.GetForwardWeightPlusOffset() > target_phantom.GetForwardWeightPlusOffset())
 | ||||
| // requires
 | ||||
| // a force loop, if the heaps have been initialized with positive offsets.
 | ||||
| void search(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CoreCH> &facade, | ||||
|             SearchEngineData::QueryHeap &forward_heap, | ||||
|             SearchEngineData::QueryHeap &reverse_heap, | ||||
|             SearchEngineData::QueryHeap &forward_core_heap, | ||||
|             SearchEngineData::QueryHeap &reverse_core_heap, | ||||
|             EdgeWeight &weight, | ||||
|             std::vector<NodeID> &packed_leg, | ||||
|             const bool force_loop_forward, | ||||
|             const bool force_loop_reverse, | ||||
|             EdgeWeight weight_upper_bound) | ||||
| { | ||||
|     NodeID middle = SPECIAL_NODEID; | ||||
|     weight = weight_upper_bound; | ||||
| 
 | ||||
|     using CoreEntryPoint = std::tuple<NodeID, EdgeWeight, NodeID>; | ||||
|     std::vector<CoreEntryPoint> forward_entry_points; | ||||
|     std::vector<CoreEntryPoint> reverse_entry_points; | ||||
| 
 | ||||
|     // get offset to account for offsets on phantom nodes on compressed edges
 | ||||
|     const auto min_edge_offset = std::min(0, forward_heap.MinKey()); | ||||
|     // we only every insert negative offsets for nodes in the forward heap
 | ||||
|     BOOST_ASSERT(reverse_heap.MinKey() >= 0); | ||||
| 
 | ||||
|     // run two-Target Dijkstra routing step.
 | ||||
|     while (0 < (forward_heap.Size() + reverse_heap.Size())) | ||||
|     { | ||||
|         if (!forward_heap.Empty()) | ||||
|         { | ||||
|             if (facade.IsCoreNode(forward_heap.Min())) | ||||
|             { | ||||
|                 const NodeID node = forward_heap.DeleteMin(); | ||||
|                 const EdgeWeight key = forward_heap.GetKey(node); | ||||
|                 forward_entry_points.emplace_back(node, key, forward_heap.GetData(node).parent); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 routingStep<FORWARD_DIRECTION>(facade, | ||||
|                                                forward_heap, | ||||
|                                                reverse_heap, | ||||
|                                                middle, | ||||
|                                                weight, | ||||
|                                                min_edge_offset, | ||||
|                                                force_loop_forward, | ||||
|                                                force_loop_reverse); | ||||
|             } | ||||
|         } | ||||
|         if (!reverse_heap.Empty()) | ||||
|         { | ||||
|             if (facade.IsCoreNode(reverse_heap.Min())) | ||||
|             { | ||||
|                 const NodeID node = reverse_heap.DeleteMin(); | ||||
|                 const EdgeWeight key = reverse_heap.GetKey(node); | ||||
|                 reverse_entry_points.emplace_back(node, key, reverse_heap.GetData(node).parent); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 routingStep<REVERSE_DIRECTION>(facade, | ||||
|                                                reverse_heap, | ||||
|                                                forward_heap, | ||||
|                                                middle, | ||||
|                                                weight, | ||||
|                                                min_edge_offset, | ||||
|                                                force_loop_reverse, | ||||
|                                                force_loop_forward); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     const auto insertInCoreHeap = [](const CoreEntryPoint &p, | ||||
|                                      SearchEngineData::QueryHeap &core_heap) { | ||||
|         NodeID id; | ||||
|         EdgeWeight weight; | ||||
|         NodeID parent; | ||||
|         // TODO this should use std::apply when we get c++17 support
 | ||||
|         std::tie(id, weight, parent) = p; | ||||
|         core_heap.Insert(id, weight, parent); | ||||
|     }; | ||||
| 
 | ||||
|     forward_core_heap.Clear(); | ||||
|     for (const auto &p : forward_entry_points) | ||||
|     { | ||||
|         insertInCoreHeap(p, forward_core_heap); | ||||
|     } | ||||
| 
 | ||||
|     reverse_core_heap.Clear(); | ||||
|     for (const auto &p : reverse_entry_points) | ||||
|     { | ||||
|         insertInCoreHeap(p, reverse_core_heap); | ||||
|     } | ||||
| 
 | ||||
|     // get offset to account for offsets on phantom nodes on compressed edges
 | ||||
|     EdgeWeight min_core_edge_offset = 0; | ||||
|     if (forward_core_heap.Size() > 0) | ||||
|     { | ||||
|         min_core_edge_offset = std::min(min_core_edge_offset, forward_core_heap.MinKey()); | ||||
|     } | ||||
|     if (reverse_core_heap.Size() > 0 && reverse_core_heap.MinKey() < 0) | ||||
|     { | ||||
|         min_core_edge_offset = std::min(min_core_edge_offset, reverse_core_heap.MinKey()); | ||||
|     } | ||||
|     BOOST_ASSERT(min_core_edge_offset <= 0); | ||||
| 
 | ||||
|     // run two-target Dijkstra routing step on core with termination criterion
 | ||||
|     while (0 < forward_core_heap.Size() && 0 < reverse_core_heap.Size() && | ||||
|            weight > (forward_core_heap.MinKey() + reverse_core_heap.MinKey())) | ||||
|     { | ||||
|         routingStep<FORWARD_DIRECTION, DISABLE_STALLING>(facade, | ||||
|                                                          forward_core_heap, | ||||
|                                                          reverse_core_heap, | ||||
|                                                          middle, | ||||
|                                                          weight, | ||||
|                                                          min_core_edge_offset, | ||||
|                                                          force_loop_forward, | ||||
|                                                          force_loop_reverse); | ||||
| 
 | ||||
|         routingStep<REVERSE_DIRECTION, DISABLE_STALLING>(facade, | ||||
|                                                          reverse_core_heap, | ||||
|                                                          forward_core_heap, | ||||
|                                                          middle, | ||||
|                                                          weight, | ||||
|                                                          min_core_edge_offset, | ||||
|                                                          force_loop_reverse, | ||||
|                                                          force_loop_forward); | ||||
|     } | ||||
| 
 | ||||
|     // No path found for both target nodes?
 | ||||
|     if (weight_upper_bound <= weight || SPECIAL_NODEID == middle) | ||||
|     { | ||||
|         weight = INVALID_EDGE_WEIGHT; | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     // Was a paths over one of the forward/reverse nodes not found?
 | ||||
|     BOOST_ASSERT_MSG((SPECIAL_NODEID != middle && INVALID_EDGE_WEIGHT != weight), "no path found"); | ||||
| 
 | ||||
|     // we need to unpack sub path from core heaps
 | ||||
|     if (facade.IsCoreNode(middle)) | ||||
|     { | ||||
|         if (weight != forward_core_heap.GetKey(middle) + reverse_core_heap.GetKey(middle)) | ||||
|         { | ||||
|             // self loop
 | ||||
|             BOOST_ASSERT(forward_core_heap.GetData(middle).parent == middle && | ||||
|                          reverse_core_heap.GetData(middle).parent == middle); | ||||
|             packed_leg.push_back(middle); | ||||
|             packed_leg.push_back(middle); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             std::vector<NodeID> packed_core_leg; | ||||
|             retrievePackedPathFromHeap( | ||||
|                 forward_core_heap, reverse_core_heap, middle, packed_core_leg); | ||||
|             BOOST_ASSERT(packed_core_leg.size() > 0); | ||||
|             retrievePackedPathFromSingleHeap(forward_heap, packed_core_leg.front(), packed_leg); | ||||
|             std::reverse(packed_leg.begin(), packed_leg.end()); | ||||
|             packed_leg.insert(packed_leg.end(), packed_core_leg.begin(), packed_core_leg.end()); | ||||
|             retrievePackedPathFromSingleHeap(reverse_heap, packed_core_leg.back(), packed_leg); | ||||
|         } | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         if (weight != forward_heap.GetKey(middle) + reverse_heap.GetKey(middle)) | ||||
|         { | ||||
|             // self loop
 | ||||
|             BOOST_ASSERT(forward_heap.GetData(middle).parent == middle && | ||||
|                          reverse_heap.GetData(middle).parent == middle); | ||||
|             packed_leg.push_back(middle); | ||||
|             packed_leg.push_back(middle); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             retrievePackedPathFromHeap(forward_heap, reverse_heap, middle, packed_leg); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| bool needsLoopForward(const PhantomNode &source_phantom, const PhantomNode &target_phantom) | ||||
| { | ||||
|     return source_phantom.forward_segment_id.enabled && target_phantom.forward_segment_id.enabled && | ||||
| @ -339,7 +155,7 @@ bool needsLoopBackwards(const PhantomNode &source_phantom, const PhantomNode &ta | ||||
|                target_phantom.GetReverseWeightPlusOffset(); | ||||
| } | ||||
| 
 | ||||
| double getPathDistance(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, | ||||
| double getPathDistance(const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade, | ||||
|                        const std::vector<NodeID> &packed_path, | ||||
|                        const PhantomNode &source_phantom, | ||||
|                        const PhantomNode &target_phantom) | ||||
| @ -398,54 +214,12 @@ double getPathDistance(const datafacade::ContiguousInternalMemoryDataFacade<algo | ||||
| // Requires the heaps for be empty
 | ||||
| // If heaps should be adjusted to be initialized outside of this function,
 | ||||
| // the addition of force_loop parameters might be required
 | ||||
| double | ||||
| getNetworkDistance(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CoreCH> &facade, | ||||
|                    SearchEngineData::QueryHeap &forward_heap, | ||||
|                    SearchEngineData::QueryHeap &reverse_heap, | ||||
|                    SearchEngineData::QueryHeap &forward_core_heap, | ||||
|                    SearchEngineData::QueryHeap &reverse_core_heap, | ||||
|                    const PhantomNode &source_phantom, | ||||
|                    const PhantomNode &target_phantom, | ||||
|                    EdgeWeight weight_upper_bound) | ||||
| { | ||||
|     forward_heap.Clear(); | ||||
|     reverse_heap.Clear(); | ||||
|     forward_core_heap.Clear(); | ||||
|     reverse_core_heap.Clear(); | ||||
| 
 | ||||
|     insertNodesInHeaps(forward_heap, reverse_heap, {source_phantom, target_phantom}); | ||||
| 
 | ||||
|     EdgeWeight weight = INVALID_EDGE_WEIGHT; | ||||
|     std::vector<NodeID> packed_path; | ||||
|     search(facade, | ||||
|            forward_heap, | ||||
|            reverse_heap, | ||||
|            forward_core_heap, | ||||
|            reverse_core_heap, | ||||
|            weight, | ||||
|            packed_path, | ||||
|            DO_NOT_FORCE_LOOPS, | ||||
|            DO_NOT_FORCE_LOOPS, | ||||
|            weight_upper_bound); | ||||
| 
 | ||||
|     double distance = std::numeric_limits<double>::max(); | ||||
|     if (weight != INVALID_EDGE_WEIGHT) | ||||
|     { | ||||
|         return getPathDistance(facade, packed_path, source_phantom, target_phantom); | ||||
|     } | ||||
|     return distance; | ||||
| } | ||||
| 
 | ||||
| // Requires the heaps for be empty
 | ||||
| // If heaps should be adjusted to be initialized outside of this function,
 | ||||
| // the addition of force_loop parameters might be required
 | ||||
| double | ||||
| getNetworkDistance(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, | ||||
|                    SearchEngineData::QueryHeap &forward_heap, | ||||
|                    SearchEngineData::QueryHeap &reverse_heap, | ||||
|                    const PhantomNode &source_phantom, | ||||
|                    const PhantomNode &target_phantom, | ||||
|                    EdgeWeight weight_upper_bound) | ||||
| double getNetworkDistance(const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade, | ||||
|                           SearchEngineData::QueryHeap &forward_heap, | ||||
|                           SearchEngineData::QueryHeap &reverse_heap, | ||||
|                           const PhantomNode &source_phantom, | ||||
|                           const PhantomNode &target_phantom, | ||||
|                           EdgeWeight weight_upper_bound) | ||||
| { | ||||
|     forward_heap.Clear(); | ||||
|     reverse_heap.Clear(); | ||||
| @ -494,8 +268,235 @@ getNetworkDistance(const datafacade::ContiguousInternalMemoryDataFacade<algorith | ||||
| 
 | ||||
|     return getPathDistance(facade, packed_path, source_phantom, target_phantom); | ||||
| } | ||||
| 
 | ||||
| } // namespace ch
 | ||||
| 
 | ||||
| namespace corech | ||||
| { | ||||
| // Assumes that heaps are already setup correctly.
 | ||||
| // A forced loop might be necessary, if source and target are on the same segment.
 | ||||
| // If this is the case and the offsets of the respective direction are larger for the source
 | ||||
| // than the target
 | ||||
| // then a force loop is required (e.g. source_phantom.forward_segment_id ==
 | ||||
| // target_phantom.forward_segment_id
 | ||||
| // && source_phantom.GetForwardWeightPlusOffset() > target_phantom.GetForwardWeightPlusOffset())
 | ||||
| // requires
 | ||||
| // a force loop, if the heaps have been initialized with positive offsets.
 | ||||
| void search(const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade, | ||||
|             SearchEngineData::QueryHeap &forward_heap, | ||||
|             SearchEngineData::QueryHeap &reverse_heap, | ||||
|             SearchEngineData::QueryHeap &forward_core_heap, | ||||
|             SearchEngineData::QueryHeap &reverse_core_heap, | ||||
|             EdgeWeight &weight, | ||||
|             std::vector<NodeID> &packed_leg, | ||||
|             const bool force_loop_forward, | ||||
|             const bool force_loop_reverse, | ||||
|             EdgeWeight weight_upper_bound) | ||||
| { | ||||
|     NodeID middle = SPECIAL_NODEID; | ||||
|     weight = weight_upper_bound; | ||||
| 
 | ||||
|     using CoreEntryPoint = std::tuple<NodeID, EdgeWeight, NodeID>; | ||||
|     std::vector<CoreEntryPoint> forward_entry_points; | ||||
|     std::vector<CoreEntryPoint> reverse_entry_points; | ||||
| 
 | ||||
|     // get offset to account for offsets on phantom nodes on compressed edges
 | ||||
|     const auto min_edge_offset = std::min(0, forward_heap.MinKey()); | ||||
|     // we only every insert negative offsets for nodes in the forward heap
 | ||||
|     BOOST_ASSERT(reverse_heap.MinKey() >= 0); | ||||
| 
 | ||||
|     // run two-Target Dijkstra routing step.
 | ||||
|     while (0 < (forward_heap.Size() + reverse_heap.Size())) | ||||
|     { | ||||
|         if (!forward_heap.Empty()) | ||||
|         { | ||||
|             if (facade.IsCoreNode(forward_heap.Min())) | ||||
|             { | ||||
|                 const NodeID node = forward_heap.DeleteMin(); | ||||
|                 const EdgeWeight key = forward_heap.GetKey(node); | ||||
|                 forward_entry_points.emplace_back(node, key, forward_heap.GetData(node).parent); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 ch::routingStep<FORWARD_DIRECTION>(facade, | ||||
|                                                    forward_heap, | ||||
|                                                    reverse_heap, | ||||
|                                                    middle, | ||||
|                                                    weight, | ||||
|                                                    min_edge_offset, | ||||
|                                                    force_loop_forward, | ||||
|                                                    force_loop_reverse); | ||||
|             } | ||||
|         } | ||||
|         if (!reverse_heap.Empty()) | ||||
|         { | ||||
|             if (facade.IsCoreNode(reverse_heap.Min())) | ||||
|             { | ||||
|                 const NodeID node = reverse_heap.DeleteMin(); | ||||
|                 const EdgeWeight key = reverse_heap.GetKey(node); | ||||
|                 reverse_entry_points.emplace_back(node, key, reverse_heap.GetData(node).parent); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 ch::routingStep<REVERSE_DIRECTION>(facade, | ||||
|                                                    reverse_heap, | ||||
|                                                    forward_heap, | ||||
|                                                    middle, | ||||
|                                                    weight, | ||||
|                                                    min_edge_offset, | ||||
|                                                    force_loop_reverse, | ||||
|                                                    force_loop_forward); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     const auto insertInCoreHeap = [](const CoreEntryPoint &p, | ||||
|                                      SearchEngineData::QueryHeap &core_heap) { | ||||
|         NodeID id; | ||||
|         EdgeWeight weight; | ||||
|         NodeID parent; | ||||
|         // TODO this should use std::apply when we get c++17 support
 | ||||
|         std::tie(id, weight, parent) = p; | ||||
|         core_heap.Insert(id, weight, parent); | ||||
|     }; | ||||
| 
 | ||||
|     forward_core_heap.Clear(); | ||||
|     for (const auto &p : forward_entry_points) | ||||
|     { | ||||
|         insertInCoreHeap(p, forward_core_heap); | ||||
|     } | ||||
| 
 | ||||
|     reverse_core_heap.Clear(); | ||||
|     for (const auto &p : reverse_entry_points) | ||||
|     { | ||||
|         insertInCoreHeap(p, reverse_core_heap); | ||||
|     } | ||||
| 
 | ||||
|     // get offset to account for offsets on phantom nodes on compressed edges
 | ||||
|     EdgeWeight min_core_edge_offset = 0; | ||||
|     if (forward_core_heap.Size() > 0) | ||||
|     { | ||||
|         min_core_edge_offset = std::min(min_core_edge_offset, forward_core_heap.MinKey()); | ||||
|     } | ||||
|     if (reverse_core_heap.Size() > 0 && reverse_core_heap.MinKey() < 0) | ||||
|     { | ||||
|         min_core_edge_offset = std::min(min_core_edge_offset, reverse_core_heap.MinKey()); | ||||
|     } | ||||
|     BOOST_ASSERT(min_core_edge_offset <= 0); | ||||
| 
 | ||||
|     // run two-target Dijkstra routing step on core with termination criterion
 | ||||
|     while (0 < forward_core_heap.Size() && 0 < reverse_core_heap.Size() && | ||||
|            weight > (forward_core_heap.MinKey() + reverse_core_heap.MinKey())) | ||||
|     { | ||||
|         ch::routingStep<FORWARD_DIRECTION, ch::DISABLE_STALLING>(facade, | ||||
|                                                                  forward_core_heap, | ||||
|                                                                  reverse_core_heap, | ||||
|                                                                  middle, | ||||
|                                                                  weight, | ||||
|                                                                  min_core_edge_offset, | ||||
|                                                                  force_loop_forward, | ||||
|                                                                  force_loop_reverse); | ||||
| 
 | ||||
|         ch::routingStep<REVERSE_DIRECTION, ch::DISABLE_STALLING>(facade, | ||||
|                                                                  reverse_core_heap, | ||||
|                                                                  forward_core_heap, | ||||
|                                                                  middle, | ||||
|                                                                  weight, | ||||
|                                                                  min_core_edge_offset, | ||||
|                                                                  force_loop_reverse, | ||||
|                                                                  force_loop_forward); | ||||
|     } | ||||
| 
 | ||||
|     // No path found for both target nodes?
 | ||||
|     if (weight_upper_bound <= weight || SPECIAL_NODEID == middle) | ||||
|     { | ||||
|         weight = INVALID_EDGE_WEIGHT; | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     // Was a paths over one of the forward/reverse nodes not found?
 | ||||
|     BOOST_ASSERT_MSG((SPECIAL_NODEID != middle && INVALID_EDGE_WEIGHT != weight), "no path found"); | ||||
| 
 | ||||
|     // we need to unpack sub path from core heaps
 | ||||
|     if (facade.IsCoreNode(middle)) | ||||
|     { | ||||
|         if (weight != forward_core_heap.GetKey(middle) + reverse_core_heap.GetKey(middle)) | ||||
|         { | ||||
|             // self loop
 | ||||
|             BOOST_ASSERT(forward_core_heap.GetData(middle).parent == middle && | ||||
|                          reverse_core_heap.GetData(middle).parent == middle); | ||||
|             packed_leg.push_back(middle); | ||||
|             packed_leg.push_back(middle); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             std::vector<NodeID> packed_core_leg; | ||||
|             ch::retrievePackedPathFromHeap( | ||||
|                 forward_core_heap, reverse_core_heap, middle, packed_core_leg); | ||||
|             BOOST_ASSERT(packed_core_leg.size() > 0); | ||||
|             ch::retrievePackedPathFromSingleHeap(forward_heap, packed_core_leg.front(), packed_leg); | ||||
|             std::reverse(packed_leg.begin(), packed_leg.end()); | ||||
|             packed_leg.insert(packed_leg.end(), packed_core_leg.begin(), packed_core_leg.end()); | ||||
|             ch::retrievePackedPathFromSingleHeap(reverse_heap, packed_core_leg.back(), packed_leg); | ||||
|         } | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         if (weight != forward_heap.GetKey(middle) + reverse_heap.GetKey(middle)) | ||||
|         { | ||||
|             // self loop
 | ||||
|             BOOST_ASSERT(forward_heap.GetData(middle).parent == middle && | ||||
|                          reverse_heap.GetData(middle).parent == middle); | ||||
|             packed_leg.push_back(middle); | ||||
|             packed_leg.push_back(middle); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             ch::retrievePackedPathFromHeap(forward_heap, reverse_heap, middle, packed_leg); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| // Requires the heaps for be empty
 | ||||
| // If heaps should be adjusted to be initialized outside of this function,
 | ||||
| // the addition of force_loop parameters might be required
 | ||||
| double getNetworkDistance(const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade, | ||||
|                           SearchEngineData::QueryHeap &forward_heap, | ||||
|                           SearchEngineData::QueryHeap &reverse_heap, | ||||
|                           SearchEngineData::QueryHeap &forward_core_heap, | ||||
|                           SearchEngineData::QueryHeap &reverse_core_heap, | ||||
|                           const PhantomNode &source_phantom, | ||||
|                           const PhantomNode &target_phantom, | ||||
|                           EdgeWeight weight_upper_bound) | ||||
| { | ||||
|     forward_heap.Clear(); | ||||
|     reverse_heap.Clear(); | ||||
|     forward_core_heap.Clear(); | ||||
|     reverse_core_heap.Clear(); | ||||
| 
 | ||||
|     insertNodesInHeaps(forward_heap, reverse_heap, {source_phantom, target_phantom}); | ||||
| 
 | ||||
|     EdgeWeight weight = INVALID_EDGE_WEIGHT; | ||||
|     std::vector<NodeID> packed_path; | ||||
|     search(facade, | ||||
|            forward_heap, | ||||
|            reverse_heap, | ||||
|            forward_core_heap, | ||||
|            reverse_core_heap, | ||||
|            weight, | ||||
|            packed_path, | ||||
|            DO_NOT_FORCE_LOOPS, | ||||
|            DO_NOT_FORCE_LOOPS, | ||||
|            weight_upper_bound); | ||||
| 
 | ||||
|     double distance = std::numeric_limits<double>::max(); | ||||
|     if (weight != INVALID_EDGE_WEIGHT) | ||||
|     { | ||||
|         return ch::getPathDistance(facade, packed_path, source_phantom, target_phantom); | ||||
|     } | ||||
|     return distance; | ||||
| } | ||||
| } // namespace corech
 | ||||
| 
 | ||||
| } // namespace routing_algorithms
 | ||||
| } // namespace engine
 | ||||
| } // namespace osrm
 | ||||
|  | ||||
| @ -198,7 +198,7 @@ void search(const datafacade::ContiguousInternalMemoryDataFacade<AlgorithmT> &fa | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void unpackLegs(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, | ||||
| void unpackLegs(const datafacade::ContiguousInternalMemoryDataFacade<ch::Algorithm> &facade, | ||||
|                 const std::vector<PhantomNodes> &phantom_nodes_vector, | ||||
|                 const std::vector<NodeID> &total_packed_path, | ||||
|                 const std::vector<std::size_t> &packed_leg_begin, | ||||
| @ -486,7 +486,7 @@ shortestPathSearchImpl(SearchEngineData &engine_working_data, | ||||
| 
 | ||||
| InternalRouteResult | ||||
| shortestPathSearch(SearchEngineData &engine_working_data, | ||||
|                    const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, | ||||
|                    const datafacade::ContiguousInternalMemoryDataFacade<ch::Algorithm> &facade, | ||||
|                    const std::vector<PhantomNodes> &phantom_nodes_vector, | ||||
|                    const boost::optional<bool> continue_straight_at_waypoint) | ||||
| { | ||||
| @ -496,7 +496,7 @@ shortestPathSearch(SearchEngineData &engine_working_data, | ||||
| 
 | ||||
| InternalRouteResult | ||||
| shortestPathSearch(SearchEngineData &engine_working_data, | ||||
|                    const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CoreCH> &facade, | ||||
|                    const datafacade::ContiguousInternalMemoryDataFacade<corech::Algorithm> &facade, | ||||
|                    const std::vector<PhantomNodes> &phantom_nodes_vector, | ||||
|                    const boost::optional<bool> continue_straight_at_waypoint) | ||||
| { | ||||
|  | ||||
| @ -8,7 +8,7 @@ namespace routing_algorithms | ||||
| { | ||||
| 
 | ||||
| std::vector<TurnData> | ||||
| getTileTurns(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, | ||||
| getTileTurns(const datafacade::ContiguousInternalMemoryDataFacade<ch::Algorithm> &facade, | ||||
|              const std::vector<RTreeLeaf> &edges, | ||||
|              const std::vector<std::size_t> &sorted_edge_indexes) | ||||
| { | ||||
|  | ||||
| @ -18,11 +18,14 @@ namespace osrm | ||||
| 
 | ||||
| OSRM::OSRM(engine::EngineConfig &config) | ||||
| { | ||||
|     using CH = engine::routing_algorithms::ch::Algorithm; | ||||
|     using CoreCH = engine::routing_algorithms::corech::Algorithm; | ||||
|     using MLD = engine::routing_algorithms::mld::Algorithm; | ||||
| 
 | ||||
|     if (config.algorithm == EngineConfig::Algorithm::CoreCH || | ||||
|         config.algorithm == EngineConfig::Algorithm::CH) | ||||
|     { | ||||
|         bool corech_compatible = | ||||
|             engine::Engine<engine::algorithm::CoreCH>::CheckCompability(config); | ||||
|         bool corech_compatible = engine::Engine<CoreCH>::CheckCompability(config); | ||||
| 
 | ||||
|         // Activate CoreCH if we can because it is faster
 | ||||
|         if (config.algorithm == EngineConfig::Algorithm::CH && corech_compatible) | ||||
| @ -40,13 +43,13 @@ OSRM::OSRM(engine::EngineConfig &config) | ||||
|     switch (config.algorithm) | ||||
|     { | ||||
|     case EngineConfig::Algorithm::CH: | ||||
|         engine_ = std::make_unique<engine::Engine<engine::algorithm::CH>>(config); | ||||
|         engine_ = std::make_unique<engine::Engine<CH>>(config); | ||||
|         break; | ||||
|     case EngineConfig::Algorithm::CoreCH: | ||||
|         engine_ = std::make_unique<engine::Engine<engine::algorithm::CoreCH>>(config); | ||||
|         engine_ = std::make_unique<engine::Engine<CoreCH>>(config); | ||||
|         break; | ||||
|     case EngineConfig::Algorithm::MLD: | ||||
|         engine_ = std::make_unique<engine::Engine<engine::algorithm::MLD>>(config); | ||||
|         engine_ = std::make_unique<engine::Engine<MLD>>(config); | ||||
|         break; | ||||
|     default: | ||||
|         util::exception("Algorithm not implemented!"); | ||||
|  | ||||
| @ -43,7 +43,7 @@ BOOST_AUTO_TEST_CASE(hint_encoding_decoding_roundtrip) | ||||
| 
 | ||||
|     const Coordinate coordinate; | ||||
|     const PhantomNode phantom; | ||||
|     const osrm::test::MockDataFacade<osrm::engine::algorithm::CH> facade{}; | ||||
|     const osrm::test::MockDataFacade<osrm::engine::datafacade::CH> facade{}; | ||||
| 
 | ||||
|     const Hint hint{phantom, facade.GetCheckSum()}; | ||||
| 
 | ||||
| @ -64,7 +64,7 @@ BOOST_AUTO_TEST_CASE(hint_encoding_decoding_roundtrip_bytewise) | ||||
| 
 | ||||
|     const Coordinate coordinate; | ||||
|     const PhantomNode phantom; | ||||
|     const osrm::test::MockDataFacade<osrm::engine::algorithm::CH> facade{}; | ||||
|     const osrm::test::MockDataFacade<osrm::engine::datafacade::CH> facade{}; | ||||
| 
 | ||||
|     const Hint hint{phantom, facade.GetCheckSum()}; | ||||
| 
 | ||||
|  | ||||
| @ -238,8 +238,8 @@ class MockBaseDataFacade : public engine::datafacade::BaseDataFacade | ||||
| template <typename AlgorithmT> class MockAlgorithmDataFacade; | ||||
| 
 | ||||
| template <> | ||||
| class MockAlgorithmDataFacade<engine::algorithm::CH> | ||||
|     : public engine::datafacade::AlgorithmDataFacade<engine::algorithm::CH> | ||||
| class MockAlgorithmDataFacade<engine::datafacade::CH> | ||||
|     : public engine::datafacade::AlgorithmDataFacade<engine::datafacade::CH> | ||||
| { | ||||
|   private: | ||||
|     EdgeData foo; | ||||
| @ -281,8 +281,8 @@ class MockAlgorithmDataFacade<engine::algorithm::CH> | ||||
| }; | ||||
| 
 | ||||
| template <> | ||||
| class MockAlgorithmDataFacade<engine::algorithm::CoreCH> | ||||
|     : public engine::datafacade::AlgorithmDataFacade<engine::algorithm::CoreCH> | ||||
| class MockAlgorithmDataFacade<engine::datafacade::CoreCH> | ||||
|     : public engine::datafacade::AlgorithmDataFacade<engine::datafacade::CoreCH> | ||||
| { | ||||
|   private: | ||||
|     EdgeData foo; | ||||
| @ -297,10 +297,10 @@ class MockDataFacade final : public MockBaseDataFacade, public MockAlgorithmData | ||||
| }; | ||||
| 
 | ||||
| template <> | ||||
| class MockDataFacade<engine::algorithm::CoreCH> final | ||||
| class MockDataFacade<engine::datafacade::CoreCH> final | ||||
|     : public MockBaseDataFacade, | ||||
|       public MockAlgorithmDataFacade<engine::algorithm::CH>, | ||||
|       public MockAlgorithmDataFacade<engine::algorithm::CoreCH> | ||||
|       public MockAlgorithmDataFacade<engine::datafacade::CH>, | ||||
|       public MockAlgorithmDataFacade<engine::datafacade::CoreCH> | ||||
| { | ||||
| }; | ||||
| 
 | ||||
|  | ||||
| @ -360,8 +360,8 @@ BOOST_AUTO_TEST_CASE(radius_regression_test) | ||||
|     std::string nodes_path; | ||||
|     build_rtree<GraphFixture, MiniStaticRTree>("test_angle", &fixture, leaves_path, nodes_path); | ||||
|     MiniStaticRTree rtree(nodes_path, leaves_path, fixture.coords); | ||||
|     MockDataFacade<engine::algorithm::CH> mockfacade; | ||||
|     engine::GeospatialQuery<MiniStaticRTree, MockDataFacade<engine::algorithm::CH>> query( | ||||
|     MockDataFacade<engine::datafacade::CH> mockfacade; | ||||
|     engine::GeospatialQuery<MiniStaticRTree, MockDataFacade<engine::datafacade::CH>> query( | ||||
|         rtree, fixture.coords, mockfacade); | ||||
| 
 | ||||
|     Coordinate input(FloatLongitude{5.2}, FloatLatitude{5.0}); | ||||
| @ -387,8 +387,8 @@ BOOST_AUTO_TEST_CASE(bearing_tests) | ||||
|     std::string nodes_path; | ||||
|     build_rtree<GraphFixture, MiniStaticRTree>("test_bearing", &fixture, leaves_path, nodes_path); | ||||
|     MiniStaticRTree rtree(nodes_path, leaves_path, fixture.coords); | ||||
|     MockDataFacade<engine::algorithm::CH> mockfacade; | ||||
|     engine::GeospatialQuery<MiniStaticRTree, MockDataFacade<engine::algorithm::CH>> query( | ||||
|     MockDataFacade<engine::datafacade::CH> mockfacade; | ||||
|     engine::GeospatialQuery<MiniStaticRTree, MockDataFacade<engine::datafacade::CH>> query( | ||||
|         rtree, fixture.coords, mockfacade); | ||||
| 
 | ||||
|     Coordinate input(FloatLongitude{5.1}, FloatLatitude{5.0}); | ||||
| @ -461,8 +461,8 @@ BOOST_AUTO_TEST_CASE(bbox_search_tests) | ||||
|     std::string nodes_path; | ||||
|     build_rtree<GraphFixture, MiniStaticRTree>("test_bbox", &fixture, leaves_path, nodes_path); | ||||
|     MiniStaticRTree rtree(nodes_path, leaves_path, fixture.coords); | ||||
|     MockDataFacade<engine::algorithm::CH> mockfacade; | ||||
|     engine::GeospatialQuery<MiniStaticRTree, MockDataFacade<engine::algorithm::CH>> query( | ||||
|     MockDataFacade<engine::datafacade::CH> mockfacade; | ||||
|     engine::GeospatialQuery<MiniStaticRTree, MockDataFacade<engine::datafacade::CH>> query( | ||||
|         rtree, fixture.coords, mockfacade); | ||||
| 
 | ||||
|     { | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user