Improvements

This commit is contained in:
xlaussel
2020-11-23 23:00:27 +01:00
parent 13067844ee
commit 41af9615cd
7 changed files with 50 additions and 56 deletions
+1 -1
View File
@@ -32,7 +32,7 @@ void relaxNode(ContractorHeap &heap,
}
const EdgeWeight to_weight = node_weight + data.weight;
const auto& toHeapNode=heap.WasInsertedGetHeapNode(to);
const auto& toHeapNode= heap.GetHeapNodeIfWasInserted(to);
// New Node discovered -> Add to Heap + Node Info Storage
if (!toHeapNode)
{
@@ -76,7 +76,7 @@ void alternativeRoutingStep(const DataFacade<Algorithm> &facade,
search_space.emplace_back(heapNode.data.parent, heapNode.node);
const auto& reverseHeapNode=reverse_heap.WasInsertedGetHeapNode(heapNode.node);
const auto& reverseHeapNode= reverse_heap.GetHeapNodeIfWasInserted(heapNode.node);
if (reverseHeapNode)
{
search_space_intersection.emplace_back(heapNode.node);
@@ -114,7 +114,7 @@ void alternativeRoutingStep(const DataFacade<Algorithm> &facade,
BOOST_ASSERT(edge_weight > 0);
const EdgeWeight to_weight = weight + edge_weight;
const auto& toHeapNode=forward_heap.WasInsertedGetHeapNode(to);
const auto& toHeapNode= forward_heap.GetHeapNodeIfWasInserted(to);
// New Node discovered -> Add to Heap + Node Info Storage
if (!toHeapNode)
{
@@ -46,19 +46,16 @@ inline bool addLoopWeight(const DataFacade<ch::Algorithm> &facade,
template <bool DIRECTION>
void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
const NodeID node,
const EdgeWeight weight,
const EdgeDuration duration,
const EdgeDistance distance,
const typename SearchEngineData<Algorithm>::ManyToManyQueryHeap::HeapNode& heapNode,
typename SearchEngineData<Algorithm>::ManyToManyQueryHeap &query_heap,
const PhantomNode &)
{
if (stallAtNode<DIRECTION>(facade, node, weight, query_heap))
if (stallAtNode<DIRECTION>(facade, heapNode, query_heap))
{
return;
}
for (auto edge : facade.GetAdjacentEdgeRange(node))
for (auto edge : facade.GetAdjacentEdgeRange(heapNode.node))
{
const auto &data = facade.GetEdgeData(edge);
if (DIRECTION == FORWARD_DIRECTION ? data.forward : data.backward)
@@ -70,21 +67,21 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
const auto edge_distance = data.distance;
BOOST_ASSERT_MSG(edge_weight > 0, "edge_weight invalid");
const auto to_weight = weight + edge_weight;
const auto to_duration = duration + edge_duration;
const auto to_distance = distance + edge_distance;
const auto to_weight = heapNode.weight + edge_weight;
const auto to_duration = heapNode.data.duration + edge_duration;
const auto to_distance = heapNode.data.distance + edge_distance;
const auto& toHeapNode=query_heap.WasInsertedGetHeapNode(to);
const auto& toHeapNode= query_heap.GetHeapNodeIfWasInserted(to);
// New Node discovered -> Add to Heap + Node Info Storage
if (!toHeapNode)
{
query_heap.Insert(to, to_weight, {node, to_duration, to_distance});
query_heap.Insert(to, to_weight, {heapNode.node, to_duration, to_distance});
}
// Found a shorter Path -> Update weight and set new parent
else if (std::tie(to_weight, to_duration) <
std::tie(query_heap.GetKey(to), query_heap.GetData(to).duration))
{
toHeapNode->data = {node, to_duration, to_distance};
toHeapNode->data = {heapNode.node, to_duration, to_distance};
toHeapNode->weight=to_weight;
query_heap.DecreaseKey(*toHeapNode);
}
@@ -155,7 +152,7 @@ void forwardRoutingStep(const DataFacade<Algorithm> &facade,
}
relaxOutgoingEdges<FORWARD_DIRECTION>(
facade, heapNode.node, source_weight, source_duration, source_distance, query_heap, phantom_node);
facade, heapNode, query_heap, phantom_node);
}
void backwardRoutingStep(const DataFacade<Algorithm> &facade,
@@ -175,7 +172,7 @@ void backwardRoutingStep(const DataFacade<Algorithm> &facade,
heapNode.node, parent, column_index, target_weight, target_duration, target_distance);
relaxOutgoingEdges<REVERSE_DIRECTION>(
facade, heapNode.node, target_weight, target_duration, target_distance, query_heap, phantom_node);
facade, heapNode, query_heap, phantom_node);
}
} // namespace ch
@@ -71,7 +71,7 @@ void relaxBorderEdges(const DataFacade<mld::Algorithm> &facade,
const auto to_distance = distance + node_distance;
// New Node discovered -> Add to Heap + Node Info Storage
const auto& toHeapNode=query_heap.WasInsertedGetHeapNode(to);
const auto& toHeapNode= query_heap.GetHeapNodeIfWasInserted(to);
if (!toHeapNode)
{
query_heap.Insert(to, to_weight, {node, false, to_duration, to_distance});
@@ -134,7 +134,7 @@ void relaxOutgoingEdges(const DataFacade<mld::Algorithm> &facade,
const auto to_weight = weight + shortcut_weight;
const auto to_duration = duration + shortcut_durations.front();
const auto to_distance = distance + shortcut_distances.front();
const auto& toHeapNode=query_heap.WasInsertedGetHeapNode(to);
const auto& toHeapNode= query_heap.GetHeapNodeIfWasInserted(to);
if (!toHeapNode)
{
query_heap.Insert(to, to_weight, {node, true, to_duration, to_distance});
@@ -174,7 +174,7 @@ void relaxOutgoingEdges(const DataFacade<mld::Algorithm> &facade,
const auto to_weight = weight + shortcut_weight;
const auto to_duration = duration + shortcut_durations.front();
const auto to_distance = distance + shortcut_distances.front();
const auto& toHeapNode=query_heap.WasInsertedGetHeapNode(to);
const auto& toHeapNode= query_heap.GetHeapNodeIfWasInserted(to);
if (!toHeapNode)
{
query_heap.Insert(to, to_weight, {node, true, to_duration, to_distance});