call function in parent class
This commit is contained in:
parent
1dab0ebc25
commit
e318be6a88
@ -42,12 +42,17 @@ const double VIAPATH_GAMMA = 0.75; //alternative shares at most 75% with the s
|
|||||||
template<class DataFacadeT>
|
template<class DataFacadeT>
|
||||||
class AlternativeRouting : private BasicRoutingInterface<DataFacadeT> {
|
class AlternativeRouting : private BasicRoutingInterface<DataFacadeT> {
|
||||||
typedef BasicRoutingInterface<DataFacadeT> super;
|
typedef BasicRoutingInterface<DataFacadeT> super;
|
||||||
typedef typename super::EdgeData EdgeData;
|
typedef typename DataFacadeT::EdgeData EdgeData;
|
||||||
typedef SearchEngineData::QueryHeap QueryHeap;
|
typedef SearchEngineData::QueryHeap QueryHeap;
|
||||||
typedef std::pair<NodeID, NodeID> SearchSpaceEdge;
|
typedef std::pair<NodeID, NodeID> SearchSpaceEdge;
|
||||||
|
|
||||||
struct RankedCandidateNode {
|
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;
|
NodeID node;
|
||||||
int length;
|
int length;
|
||||||
int sharing;
|
int sharing;
|
||||||
@ -70,18 +75,23 @@ public:
|
|||||||
|
|
||||||
~AlternativeRouting() {}
|
~AlternativeRouting() {}
|
||||||
|
|
||||||
void operator()(const PhantomNodes & phantomNodePair, RawRouteData & rawRouteData) {
|
void operator()(
|
||||||
if(!phantomNodePair.AtLeastOnePhantomNodeIsUINTMAX() || phantomNodePair.PhantomNodesHaveEqualLocation()) {
|
const PhantomNodes & phantom_node_pair,
|
||||||
rawRouteData.lengthOfShortestPath = rawRouteData.lengthOfAlternativePath = INT_MAX;
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<NodeID> alternativePath;
|
std::vector<NodeID> alternative_path;
|
||||||
std::vector<NodeID> viaNodeCandidates;
|
std::vector<NodeID> via_node_candidate_list;
|
||||||
std::vector<SearchSpaceEdge> forward_search_space;
|
std::vector<SearchSpaceEdge> forward_search_space;
|
||||||
std::vector<SearchSpaceEdge> reverse_search_space;
|
std::vector<SearchSpaceEdge> 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(
|
engine_working_data.InitializeOrClearFirstThreadLocalStorage(
|
||||||
super::facade->GetNumberOfNodes()
|
super::facade->GetNumberOfNodes()
|
||||||
);
|
);
|
||||||
@ -99,28 +109,45 @@ public:
|
|||||||
|
|
||||||
int upper_bound_to_shortest_path_distance = INT_MAX;
|
int upper_bound_to_shortest_path_distance = INT_MAX;
|
||||||
NodeID middle_node = UINT_MAX;
|
NodeID middle_node = UINT_MAX;
|
||||||
forward_heap1.Insert(phantomNodePair.startPhantom.edgeBasedNode, -phantomNodePair.startPhantom.weight1, phantomNodePair.startPhantom.edgeBasedNode);
|
forward_heap1.Insert(
|
||||||
if(phantomNodePair.startPhantom.isBidirected() ) {
|
phantom_node_pair.startPhantom.edgeBasedNode,
|
||||||
forward_heap1.Insert(phantomNodePair.startPhantom.edgeBasedNode+1, -phantomNodePair.startPhantom.weight2, phantomNodePair.startPhantom.edgeBasedNode+1);
|
-phantom_node_pair.startPhantom.weight1,
|
||||||
}
|
phantom_node_pair.startPhantom.edgeBasedNode
|
||||||
reverse_heap1.Insert(phantomNodePair.targetPhantom.edgeBasedNode, phantomNodePair.targetPhantom.weight1, phantomNodePair.targetPhantom.edgeBasedNode);
|
);
|
||||||
if(phantomNodePair.targetPhantom.isBidirected() ) {
|
if(phantom_node_pair.startPhantom.isBidirected() ) {
|
||||||
reverse_heap1.Insert(phantomNodePair.targetPhantom.edgeBasedNode+1, phantomNodePair.targetPhantom.weight2, phantomNodePair.targetPhantom.edgeBasedNode+1);
|
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);
|
reverse_heap1.Insert(
|
||||||
const int reverse_offset = phantomNodePair.targetPhantom.weight1 + (phantomNodePair.targetPhantom.isBidirected() ? phantomNodePair.targetPhantom.weight2 : 0);
|
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
|
//exploration dijkstra from nodes s and t until deletemin/(1+epsilon) > _lengthOfShortestPath
|
||||||
while(0 < (forward_heap1.Size() + reverse_heap1.Size())){
|
while(0 < (forward_heap1.Size() + reverse_heap1.Size())){
|
||||||
if(0 < forward_heap1.Size()){
|
if(0 < forward_heap1.Size()){
|
||||||
AlternativeRoutingStep<true >(forward_heap1, reverse_heap1, &middle_node, &upper_bound_to_shortest_path_distance, viaNodeCandidates, forward_search_space, forward_offset);
|
AlternativeRoutingStep<true >(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()){
|
if(0 < reverse_heap1.Size()){
|
||||||
AlternativeRoutingStep<false>(reverse_heap1, forward_heap1, &middle_node, &upper_bound_to_shortest_path_distance, viaNodeCandidates, reverse_search_space, reverse_offset);
|
AlternativeRoutingStep<false>(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<NodeID> packed_forward_path;
|
std::vector<NodeID> packed_forward_path;
|
||||||
std::vector<NodeID> packed_reverse_path;
|
std::vector<NodeID> packed_reverse_path;
|
||||||
@ -160,7 +187,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::vector<NodeID> nodes_that_passed_preselection;
|
std::vector<NodeID> 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_sharing = approximated_forward_sharing[node] + approximated_reverse_sharing[node];
|
||||||
int approximated_length = forward_heap1.GetKey(node)+reverse_heap1.GetKey(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));
|
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
|
//Unpack shortest path and alternative, if they exist
|
||||||
if(INT_MAX != upper_bound_to_shortest_path_distance) {
|
if(INT_MAX != upper_bound_to_shortest_path_distance) {
|
||||||
super::UnpackPath(packedShortestPath, rawRouteData.computedShortestPath);
|
super::UnpackPath(packedShortestPath, raw_route_data.computedShortestPath);
|
||||||
rawRouteData.lengthOfShortestPath = upper_bound_to_shortest_path_distance;
|
raw_route_data.lengthOfShortestPath = upper_bound_to_shortest_path_distance;
|
||||||
} else {
|
} else {
|
||||||
rawRouteData.lengthOfShortestPath = INT_MAX;
|
raw_route_data.lengthOfShortestPath = INT_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(selectedViaNode != UINT_MAX) {
|
if(selectedViaNode != UINT_MAX) {
|
||||||
retrievePackedViaPath(forward_heap1, reverse_heap1, forward_heap2, reverse_heap2, s_v_middle, v_t_middle, rawRouteData.computedAlternativePath);
|
retrievePackedViaPath(forward_heap1, reverse_heap1, forward_heap2, reverse_heap2, s_v_middle, v_t_middle, raw_route_data.computedAlternativePath);
|
||||||
rawRouteData.lengthOfAlternativePath = lengthOfViaPath;
|
raw_route_data.lengthOfAlternativePath = lengthOfViaPath;
|
||||||
} else {
|
} else {
|
||||||
rawRouteData.lengthOfAlternativePath = INT_MAX;
|
raw_route_data.lengthOfAlternativePath = INT_MAX;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,10 +39,6 @@ class ShortestPathRouting : public BasicRoutingInterface<DataFacadeT>{
|
|||||||
typedef SearchEngineData::QueryHeap QueryHeap;
|
typedef SearchEngineData::QueryHeap QueryHeap;
|
||||||
SearchEngineData & engine_working_data;
|
SearchEngineData & engine_working_data;
|
||||||
|
|
||||||
int ComputeEdgeOffset(const PhantomNode & phantom) const {
|
|
||||||
return phantom.weight1 + (phantom.isBidirected() ? phantom.weight2 : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ShortestPathRouting(
|
ShortestPathRouting(
|
||||||
DataFacadeT * facade,
|
DataFacadeT * facade,
|
||||||
@ -151,10 +147,10 @@ public:
|
|||||||
);
|
);
|
||||||
// INFO("rv2: " << phantom_node_pair.targetPhantom.edgeBasedNode+1 << ", w;" << phantom_node_pair.targetPhantom.weight2 );
|
// 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
|
phantom_node_pair.startPhantom
|
||||||
);
|
);
|
||||||
const int reverse_offset = ComputeEdgeOffset(
|
const int reverse_offset = super::ComputeEdgeOffset(
|
||||||
phantom_node_pair.targetPhantom
|
phantom_node_pair.targetPhantom
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user