Make explicit fallback to CH heaps in CoreCH algorithms
This commit is contained in:
parent
1de031ed06
commit
e498ad3ee7
@ -132,7 +132,7 @@ template <typename Algorithm> class Engine final : public EngineInterface
|
||||
|
||||
private:
|
||||
std::unique_ptr<DataFacadeProvider<Algorithm>> facade_provider;
|
||||
mutable SearchEngineData<Algorithm> heaps;
|
||||
mutable SearchEngineData<typename RoutingAlgorithms<Algorithm>::HeapAlgorithm> heaps;
|
||||
|
||||
const plugins::ViaRoutePlugin route_plugin;
|
||||
const plugins::TablePlugin table_plugin;
|
||||
|
@ -57,7 +57,16 @@ class RoutingAlgorithmsInterface
|
||||
template <typename Algorithm> class RoutingAlgorithms final : public RoutingAlgorithmsInterface
|
||||
{
|
||||
public:
|
||||
RoutingAlgorithms(SearchEngineData<Algorithm> &heaps,
|
||||
// HeapAlgorithm is an explicit heap algorithm type to be used with Algorithm
|
||||
// - CH algorithms use CH heap
|
||||
// - CoreCH algorithms use CH heap
|
||||
// - MLD algorithms use MLD heap
|
||||
using HeapAlgorithm = typename std::conditional<
|
||||
std::is_same<Algorithm, routing_algorithms::corech::Algorithm>::value,
|
||||
routing_algorithms::ch::Algorithm,
|
||||
Algorithm>::type;
|
||||
|
||||
RoutingAlgorithms(SearchEngineData<HeapAlgorithm> &heaps,
|
||||
const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade)
|
||||
: heaps(heaps), facade(facade)
|
||||
{
|
||||
@ -122,7 +131,8 @@ template <typename Algorithm> class RoutingAlgorithms final : public RoutingAlgo
|
||||
}
|
||||
|
||||
private:
|
||||
SearchEngineData<Algorithm> &heaps;
|
||||
SearchEngineData<HeapAlgorithm> &heaps;
|
||||
|
||||
// Owned by shared-ptr passed to the query
|
||||
const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade;
|
||||
};
|
||||
|
@ -21,10 +21,14 @@ namespace routing_algorithms
|
||||
/// by the previous route.
|
||||
/// This variation is only an optimazation for graphs with slow queries, for example
|
||||
/// not fully contracted graphs.
|
||||
template <typename Algorithm>
|
||||
InternalRouteResult
|
||||
directShortestPathSearch(SearchEngineData<Algorithm> &engine_working_data,
|
||||
const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade,
|
||||
InternalRouteResult directShortestPathSearch(
|
||||
SearchEngineData<ch::Algorithm> &engine_working_data,
|
||||
const datafacade::ContiguousInternalMemoryDataFacade<ch::Algorithm> &facade,
|
||||
const PhantomNodes &phantom_nodes);
|
||||
|
||||
InternalRouteResult directShortestPathSearch(
|
||||
SearchEngineData<ch::Algorithm> &engine_working_data,
|
||||
const datafacade::ContiguousInternalMemoryDataFacade<corech::Algorithm> &facade,
|
||||
const PhantomNodes &phantom_nodes);
|
||||
|
||||
InternalRouteResult directShortestPathSearch(
|
||||
|
@ -22,8 +22,8 @@ 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
|
||||
template <typename Algorithm>
|
||||
SubMatchingList mapMatching(SearchEngineData<Algorithm> &engine_working_data,
|
||||
template <typename Algorithm, typename SearchEngineData>
|
||||
SubMatchingList mapMatching(SearchEngineData &engine_working_data,
|
||||
const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade,
|
||||
const CandidateLists &candidates_list,
|
||||
const std::vector<util::Coordinate> &trace_coordinates,
|
||||
|
@ -388,8 +388,8 @@ namespace corech
|
||||
// a force loop, if the heaps have been initialized with positive offsets.
|
||||
void search(SearchEngineData<Algorithm> &engine_working_data,
|
||||
const datafacade::ContiguousInternalMemoryDataFacade<corech::Algorithm> &facade,
|
||||
SearchEngineData<Algorithm>::QueryHeap &forward_heap,
|
||||
SearchEngineData<Algorithm>::QueryHeap &reverse_heap,
|
||||
SearchEngineData<ch::Algorithm>::QueryHeap &forward_heap,
|
||||
SearchEngineData<ch::Algorithm>::QueryHeap &reverse_heap,
|
||||
int &weight,
|
||||
std::vector<NodeID> &packed_leg,
|
||||
const bool force_loop_forward,
|
||||
@ -403,8 +403,8 @@ void search(SearchEngineData<Algorithm> &engine_working_data,
|
||||
double
|
||||
getNetworkDistance(SearchEngineData<Algorithm> &engine_working_data,
|
||||
const datafacade::ContiguousInternalMemoryDataFacade<corech::Algorithm> &facade,
|
||||
SearchEngineData<Algorithm>::QueryHeap &forward_heap,
|
||||
SearchEngineData<Algorithm>::QueryHeap &reverse_heap,
|
||||
SearchEngineData<ch::Algorithm>::QueryHeap &forward_heap,
|
||||
SearchEngineData<ch::Algorithm>::QueryHeap &reverse_heap,
|
||||
const PhantomNode &source_phantom,
|
||||
const PhantomNode &target_phantom,
|
||||
int duration_upper_bound = INVALID_EDGE_WEIGHT);
|
||||
|
@ -13,9 +13,9 @@ namespace engine
|
||||
namespace routing_algorithms
|
||||
{
|
||||
|
||||
template <typename Algorithm>
|
||||
template <typename Algorithm, typename SearchEngineData>
|
||||
InternalRouteResult
|
||||
shortestPathSearch(SearchEngineData<Algorithm> &engine_working_data,
|
||||
shortestPathSearch(SearchEngineData &engine_working_data,
|
||||
const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade,
|
||||
const std::vector<PhantomNodes> &phantom_nodes_vector,
|
||||
const boost::optional<bool> continue_straight_at_waypoint);
|
||||
|
@ -55,9 +55,9 @@ namespace detail
|
||||
/// by the previous route.
|
||||
/// This variation is only an optimazation for graphs with slow queries, for example
|
||||
/// not fully contracted graphs.
|
||||
template <typename Algorithm>
|
||||
template <typename Algorithm, typename SearchEngineData>
|
||||
InternalRouteResult directShortestPathSearchImpl(
|
||||
SearchEngineData<Algorithm> &engine_working_data,
|
||||
SearchEngineData &engine_working_data,
|
||||
const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade,
|
||||
const PhantomNodes &phantom_nodes)
|
||||
{
|
||||
@ -101,16 +101,14 @@ InternalRouteResult directShortestPathSearchImpl(
|
||||
|
||||
} // namespace ch
|
||||
|
||||
template <>
|
||||
InternalRouteResult directShortestPathSearch(
|
||||
SearchEngineData<corech::Algorithm> &engine_working_data,
|
||||
SearchEngineData<ch::Algorithm> &engine_working_data,
|
||||
const datafacade::ContiguousInternalMemoryDataFacade<corech::Algorithm> &facade,
|
||||
const PhantomNodes &phantom_nodes)
|
||||
{
|
||||
return detail::directShortestPathSearchImpl(engine_working_data, facade, phantom_nodes);
|
||||
}
|
||||
|
||||
template <>
|
||||
InternalRouteResult directShortestPathSearch(
|
||||
SearchEngineData<ch::Algorithm> &engine_working_data,
|
||||
const datafacade::ContiguousInternalMemoryDataFacade<ch::Algorithm> &facade,
|
||||
|
@ -48,8 +48,8 @@ unsigned getMedianSampleTime(const std::vector<unsigned> ×tamps)
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Algorithm>
|
||||
SubMatchingList mapMatching(SearchEngineData<Algorithm> &engine_working_data,
|
||||
template <typename Algorithm, typename SearchEngineData>
|
||||
SubMatchingList mapMatching(SearchEngineData &engine_working_data,
|
||||
const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade,
|
||||
const CandidateLists &candidates_list,
|
||||
const std::vector<util::Coordinate> &trace_coordinates,
|
||||
@ -426,7 +426,7 @@ mapMatching(SearchEngineData<ch::Algorithm> &engine_working_data,
|
||||
const bool allow_splitting);
|
||||
|
||||
template SubMatchingList
|
||||
mapMatching(SearchEngineData<corech::Algorithm> &engine_working_data,
|
||||
mapMatching(SearchEngineData<ch::Algorithm> &engine_working_data,
|
||||
const datafacade::ContiguousInternalMemoryDataFacade<corech::Algorithm> &facade,
|
||||
const CandidateLists &candidates_list,
|
||||
const std::vector<util::Coordinate> &trace_coordinates,
|
||||
|
@ -221,10 +221,10 @@ namespace corech
|
||||
// && source_phantom.GetForwardWeightPlusOffset() > target_phantom.GetForwardWeightPlusOffset())
|
||||
// requires
|
||||
// a force loop, if the heaps have been initialized with positive offsets.
|
||||
void search(SearchEngineData<Algorithm> &engine_working_data,
|
||||
void search(SearchEngineData<ch::Algorithm> &engine_working_data,
|
||||
const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade,
|
||||
SearchEngineData<Algorithm>::QueryHeap &forward_heap,
|
||||
SearchEngineData<Algorithm>::QueryHeap &reverse_heap,
|
||||
SearchEngineData<ch::Algorithm>::QueryHeap &forward_heap,
|
||||
SearchEngineData<ch::Algorithm>::QueryHeap &reverse_heap,
|
||||
EdgeWeight &weight,
|
||||
std::vector<NodeID> &packed_leg,
|
||||
const bool force_loop_forward,
|
||||
@ -289,8 +289,7 @@ void search(SearchEngineData<Algorithm> &engine_working_data,
|
||||
}
|
||||
}
|
||||
|
||||
const auto insertInCoreHeap = [](const CoreEntryPoint &p,
|
||||
SearchEngineData<Algorithm>::QueryHeap &core_heap) {
|
||||
const auto insertInCoreHeap = [](const CoreEntryPoint &p, auto &core_heap) {
|
||||
NodeID id;
|
||||
EdgeWeight weight;
|
||||
NodeID parent;
|
||||
@ -402,7 +401,7 @@ void search(SearchEngineData<Algorithm> &engine_working_data,
|
||||
// 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(SearchEngineData<Algorithm> &engine_working_data,
|
||||
double getNetworkDistance(SearchEngineData<ch::Algorithm> &engine_working_data,
|
||||
const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade,
|
||||
SearchEngineData<ch::Algorithm>::QueryHeap &forward_heap,
|
||||
SearchEngineData<ch::Algorithm>::QueryHeap &reverse_heap,
|
||||
|
@ -20,11 +20,11 @@ const static constexpr bool DO_NOT_FORCE_LOOP = false;
|
||||
|
||||
// allows a uturn at the target_phantom
|
||||
// searches source forward/reverse -> target forward/reverse
|
||||
template <typename Algorithm>
|
||||
void searchWithUTurn(SearchEngineData<Algorithm> &engine_working_data,
|
||||
template <typename Algorithm, typename SearchEngineData>
|
||||
void searchWithUTurn(SearchEngineData &engine_working_data,
|
||||
const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade,
|
||||
typename SearchEngineData<Algorithm>::QueryHeap &forward_heap,
|
||||
typename SearchEngineData<Algorithm>::QueryHeap &reverse_heap,
|
||||
typename SearchEngineData::QueryHeap &forward_heap,
|
||||
typename SearchEngineData::QueryHeap &reverse_heap,
|
||||
const bool search_from_forward_node,
|
||||
const bool search_from_reverse_node,
|
||||
const bool search_to_forward_node,
|
||||
@ -94,11 +94,11 @@ void searchWithUTurn(SearchEngineData<Algorithm> &engine_working_data,
|
||||
// searches shortest path between:
|
||||
// source forward/reverse -> target forward
|
||||
// source forward/reverse -> target reverse
|
||||
template <typename Algorithm>
|
||||
void search(SearchEngineData<Algorithm> &engine_working_data,
|
||||
template <typename Algorithm, typename SearchEngineData>
|
||||
void search(SearchEngineData &engine_working_data,
|
||||
const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade,
|
||||
typename SearchEngineData<Algorithm>::QueryHeap &forward_heap,
|
||||
typename SearchEngineData<Algorithm>::QueryHeap &reverse_heap,
|
||||
typename SearchEngineData::QueryHeap &forward_heap,
|
||||
typename SearchEngineData::QueryHeap &reverse_heap,
|
||||
const bool search_from_forward_node,
|
||||
const bool search_from_reverse_node,
|
||||
const bool search_to_forward_node,
|
||||
@ -215,9 +215,9 @@ void unpackLegs(const datafacade::ContiguousInternalMemoryDataFacade<Algorithm>
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Algorithm>
|
||||
template <typename Algorithm, typename SearchEngineData>
|
||||
InternalRouteResult
|
||||
shortestPathSearch(SearchEngineData<Algorithm> &engine_working_data,
|
||||
shortestPathSearch(SearchEngineData &engine_working_data,
|
||||
const datafacade::ContiguousInternalMemoryDataFacade<Algorithm> &facade,
|
||||
const std::vector<PhantomNodes> &phantom_nodes_vector,
|
||||
const boost::optional<bool> continue_straight_at_waypoint)
|
||||
@ -474,7 +474,7 @@ shortestPathSearch(SearchEngineData<ch::Algorithm> &engine_working_data,
|
||||
const boost::optional<bool> continue_straight_at_waypoint);
|
||||
|
||||
template InternalRouteResult
|
||||
shortestPathSearch(SearchEngineData<corech::Algorithm> &engine_working_data,
|
||||
shortestPathSearch(SearchEngineData<ch::Algorithm> &engine_working_data,
|
||||
const datafacade::ContiguousInternalMemoryDataFacade<corech::Algorithm> &facade,
|
||||
const std::vector<PhantomNodes> &phantom_nodes_vector,
|
||||
const boost::optional<bool> continue_straight_at_waypoint);
|
||||
|
Loading…
Reference in New Issue
Block a user