From e318be6a8849b9c48552174932d087a3785d1831 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Tue, 24 Sep 2013 10:58:24 +0200 Subject: [PATCH] call function in parent class --- RoutingAlgorithms/AlternativePathRouting.h | 81 ++++++++++++++-------- RoutingAlgorithms/ShortestPathRouting.h | 8 +-- 2 files changed, 56 insertions(+), 33 deletions(-) diff --git a/RoutingAlgorithms/AlternativePathRouting.h b/RoutingAlgorithms/AlternativePathRouting.h index c08854a6e..f19411a72 100644 --- a/RoutingAlgorithms/AlternativePathRouting.h +++ b/RoutingAlgorithms/AlternativePathRouting.h @@ -42,12 +42,17 @@ const double VIAPATH_GAMMA = 0.75; //alternative shares at most 75% with the s template class AlternativeRouting : private BasicRoutingInterface { typedef BasicRoutingInterface super; - typedef typename super::EdgeData EdgeData; + typedef typename DataFacadeT::EdgeData EdgeData; typedef SearchEngineData::QueryHeap QueryHeap; typedef std::pair SearchSpaceEdge; struct RankedCandidateNode { - RankedCandidateNode(const NodeID n, const int l, const int s) : node(n), length(l), sharing(s) {} + RankedCandidateNode(const NodeID n, const int l, const int s) : + node(n), + length(l), + sharing(s) + { } + NodeID node; int length; int sharing; @@ -70,18 +75,23 @@ public: ~AlternativeRouting() {} - void operator()(const PhantomNodes & phantomNodePair, RawRouteData & rawRouteData) { - if(!phantomNodePair.AtLeastOnePhantomNodeIsUINTMAX() || phantomNodePair.PhantomNodesHaveEqualLocation()) { - rawRouteData.lengthOfShortestPath = rawRouteData.lengthOfAlternativePath = INT_MAX; + void operator()( + const PhantomNodes & phantom_node_pair, + RawRouteData & raw_route_data) { + if( (!phantom_node_pair.AtLeastOnePhantomNodeIsUINTMAX()) || + phantom_node_pair.PhantomNodesHaveEqualLocation() + ) { + raw_route_data.lengthOfShortestPath = INT_MAX; + raw_route_data.lengthOfAlternativePath = INT_MAX; return; } - std::vector alternativePath; - std::vector viaNodeCandidates; + std::vector alternative_path; + std::vector via_node_candidate_list; std::vector forward_search_space; std::vector reverse_search_space; - //Initialize Queues, semi-expensive because access to TSS invokes a system call + //Init queues, semi-expensive because access to TSS invokes a sys-call engine_working_data.InitializeOrClearFirstThreadLocalStorage( super::facade->GetNumberOfNodes() ); @@ -99,28 +109,45 @@ public: int upper_bound_to_shortest_path_distance = INT_MAX; NodeID middle_node = UINT_MAX; - forward_heap1.Insert(phantomNodePair.startPhantom.edgeBasedNode, -phantomNodePair.startPhantom.weight1, phantomNodePair.startPhantom.edgeBasedNode); - if(phantomNodePair.startPhantom.isBidirected() ) { - forward_heap1.Insert(phantomNodePair.startPhantom.edgeBasedNode+1, -phantomNodePair.startPhantom.weight2, phantomNodePair.startPhantom.edgeBasedNode+1); - } - reverse_heap1.Insert(phantomNodePair.targetPhantom.edgeBasedNode, phantomNodePair.targetPhantom.weight1, phantomNodePair.targetPhantom.edgeBasedNode); - if(phantomNodePair.targetPhantom.isBidirected() ) { - reverse_heap1.Insert(phantomNodePair.targetPhantom.edgeBasedNode+1, phantomNodePair.targetPhantom.weight2, phantomNodePair.targetPhantom.edgeBasedNode+1); + forward_heap1.Insert( + phantom_node_pair.startPhantom.edgeBasedNode, + -phantom_node_pair.startPhantom.weight1, + phantom_node_pair.startPhantom.edgeBasedNode + ); + if(phantom_node_pair.startPhantom.isBidirected() ) { + forward_heap1.Insert( + phantom_node_pair.startPhantom.edgeBasedNode+1, + -phantom_node_pair.startPhantom.weight2, + phantom_node_pair.startPhantom.edgeBasedNode+1 + ); } - const int forward_offset = phantomNodePair.startPhantom.weight1 + (phantomNodePair.startPhantom.isBidirected() ? phantomNodePair.startPhantom.weight2 : 0); - const int reverse_offset = phantomNodePair.targetPhantom.weight1 + (phantomNodePair.targetPhantom.isBidirected() ? phantomNodePair.targetPhantom.weight2 : 0); + reverse_heap1.Insert( + phantom_node_pair.targetPhantom.edgeBasedNode, + phantom_node_pair.targetPhantom.weight1, + phantom_node_pair.targetPhantom.edgeBasedNode + ); + if(phantom_node_pair.targetPhantom.isBidirected() ) { + reverse_heap1.Insert( + phantom_node_pair.targetPhantom.edgeBasedNode+1, + phantom_node_pair.targetPhantom.weight2, + phantom_node_pair.targetPhantom.edgeBasedNode+1 + ); + } + + const int forward_offset = super::ComputeEdgeOffset(phantom_node_pair.startPhantom);// phantom_node_pair.startPhantom.weight1 + (phantom_node_pair.startPhantom.isBidirected() ? phantom_node_pair.startPhantom.weight2 : 0); + const int reverse_offset = super::ComputeEdgeOffset(phantom_node_pair.targetPhantom);//phantom_node_pair.targetPhantom.weight1 + (phantom_node_pair.targetPhantom.isBidirected() ? phantom_node_pair.targetPhantom.weight2 : 0); //exploration dijkstra from nodes s and t until deletemin/(1+epsilon) > _lengthOfShortestPath while(0 < (forward_heap1.Size() + reverse_heap1.Size())){ if(0 < forward_heap1.Size()){ - AlternativeRoutingStep(forward_heap1, reverse_heap1, &middle_node, &upper_bound_to_shortest_path_distance, viaNodeCandidates, forward_search_space, forward_offset); + AlternativeRoutingStep(forward_heap1, reverse_heap1, &middle_node, &upper_bound_to_shortest_path_distance, via_node_candidate_list, forward_search_space, forward_offset); } if(0 < reverse_heap1.Size()){ - AlternativeRoutingStep(reverse_heap1, forward_heap1, &middle_node, &upper_bound_to_shortest_path_distance, viaNodeCandidates, reverse_search_space, reverse_offset); + AlternativeRoutingStep(reverse_heap1, forward_heap1, &middle_node, &upper_bound_to_shortest_path_distance, via_node_candidate_list, reverse_search_space, reverse_offset); } } - sort_unique_resize(viaNodeCandidates); + sort_unique_resize(via_node_candidate_list); std::vector packed_forward_path; std::vector packed_reverse_path; @@ -160,7 +187,7 @@ public: } } std::vector nodes_that_passed_preselection; - BOOST_FOREACH(const NodeID node, viaNodeCandidates) { + BOOST_FOREACH(const NodeID node, via_node_candidate_list) { int approximated_sharing = approximated_forward_sharing[node] + approximated_reverse_sharing[node]; int approximated_length = forward_heap1.GetKey(node)+reverse_heap1.GetKey(node); bool lengthPassed = (approximated_length < upper_bound_to_shortest_path_distance*(1+VIAPATH_EPSILON)); @@ -201,17 +228,17 @@ public: //Unpack shortest path and alternative, if they exist if(INT_MAX != upper_bound_to_shortest_path_distance) { - super::UnpackPath(packedShortestPath, rawRouteData.computedShortestPath); - rawRouteData.lengthOfShortestPath = upper_bound_to_shortest_path_distance; + super::UnpackPath(packedShortestPath, raw_route_data.computedShortestPath); + raw_route_data.lengthOfShortestPath = upper_bound_to_shortest_path_distance; } else { - rawRouteData.lengthOfShortestPath = INT_MAX; + raw_route_data.lengthOfShortestPath = INT_MAX; } if(selectedViaNode != UINT_MAX) { - retrievePackedViaPath(forward_heap1, reverse_heap1, forward_heap2, reverse_heap2, s_v_middle, v_t_middle, rawRouteData.computedAlternativePath); - rawRouteData.lengthOfAlternativePath = lengthOfViaPath; + retrievePackedViaPath(forward_heap1, reverse_heap1, forward_heap2, reverse_heap2, s_v_middle, v_t_middle, raw_route_data.computedAlternativePath); + raw_route_data.lengthOfAlternativePath = lengthOfViaPath; } else { - rawRouteData.lengthOfAlternativePath = INT_MAX; + raw_route_data.lengthOfAlternativePath = INT_MAX; } } diff --git a/RoutingAlgorithms/ShortestPathRouting.h b/RoutingAlgorithms/ShortestPathRouting.h index 2d07e521f..0936ce140 100644 --- a/RoutingAlgorithms/ShortestPathRouting.h +++ b/RoutingAlgorithms/ShortestPathRouting.h @@ -39,10 +39,6 @@ class ShortestPathRouting : public BasicRoutingInterface{ typedef SearchEngineData::QueryHeap QueryHeap; SearchEngineData & engine_working_data; - int ComputeEdgeOffset(const PhantomNode & phantom) const { - return phantom.weight1 + (phantom.isBidirected() ? phantom.weight2 : 0); - } - public: ShortestPathRouting( DataFacadeT * facade, @@ -151,10 +147,10 @@ public: ); // INFO("rv2: " << phantom_node_pair.targetPhantom.edgeBasedNode+1 << ", w;" << phantom_node_pair.targetPhantom.weight2 ); } - const int forward_offset = ComputeEdgeOffset( + const int forward_offset = super::ComputeEdgeOffset( phantom_node_pair.startPhantom ); - const int reverse_offset = ComputeEdgeOffset( + const int reverse_offset = super::ComputeEdgeOffset( phantom_node_pair.targetPhantom );