format code
This commit is contained in:
@@ -62,8 +62,9 @@ void alternativeRoutingStep(const DataFacade<Algorithm> &facade,
|
||||
QueryHeap &forward_heap = DIRECTION == FORWARD_DIRECTION ? heap1 : heap2;
|
||||
QueryHeap &reverse_heap = DIRECTION == FORWARD_DIRECTION ? heap2 : heap1;
|
||||
|
||||
// Take a copy (no ref &) of the extracted node because otherwise could be modified later if toHeapNode is the same
|
||||
const auto heapNode=forward_heap.DeleteMinGetHeapNode();
|
||||
// Take a copy (no ref &) of the extracted node because otherwise could be modified later if
|
||||
// toHeapNode is the same
|
||||
const auto heapNode = forward_heap.DeleteMinGetHeapNode();
|
||||
|
||||
const auto scaled_weight =
|
||||
static_cast<EdgeWeight>((heapNode.weight + min_edge_offset) / (1. + VIAPATH_EPSILON));
|
||||
@@ -76,7 +77,7 @@ void alternativeRoutingStep(const DataFacade<Algorithm> &facade,
|
||||
|
||||
search_space.emplace_back(heapNode.data.parent, heapNode.node);
|
||||
|
||||
const auto reverseHeapNode= reverse_heap.GetHeapNodeIfWasInserted(heapNode.node);
|
||||
const auto reverseHeapNode = reverse_heap.GetHeapNodeIfWasInserted(heapNode.node);
|
||||
if (reverseHeapNode)
|
||||
{
|
||||
search_space_intersection.emplace_back(heapNode.node);
|
||||
@@ -114,7 +115,7 @@ void alternativeRoutingStep(const DataFacade<Algorithm> &facade,
|
||||
BOOST_ASSERT(edge_weight > 0);
|
||||
const EdgeWeight to_weight = heapNode.weight + edge_weight;
|
||||
|
||||
const auto toHeapNode= forward_heap.GetHeapNodeIfWasInserted(to);
|
||||
const auto toHeapNode = forward_heap.GetHeapNodeIfWasInserted(to);
|
||||
// New Node discovered -> Add to Heap + Node Info Storage
|
||||
if (!toHeapNode)
|
||||
{
|
||||
@@ -126,7 +127,7 @@ void alternativeRoutingStep(const DataFacade<Algorithm> &facade,
|
||||
// new parent
|
||||
toHeapNode->data.parent = heapNode.node;
|
||||
// decreased weight
|
||||
toHeapNode->weight=to_weight;
|
||||
toHeapNode->weight = to_weight;
|
||||
forward_heap.DecreaseKey(*toHeapNode);
|
||||
}
|
||||
}
|
||||
@@ -561,7 +562,7 @@ bool viaNodeCandidatePassesTTest(SearchEngineData<Algorithm> &engine_working_dat
|
||||
}
|
||||
return (upper_bound <= t_test_path_weight);
|
||||
}
|
||||
} // anon. namespace
|
||||
} // namespace
|
||||
|
||||
InternalManyRoutesResult alternativePathSearch(SearchEngineData<Algorithm> &engine_working_data,
|
||||
const DataFacade<Algorithm> &facade,
|
||||
@@ -856,4 +857,4 @@ InternalManyRoutesResult alternativePathSearch(SearchEngineData<Algorithm> &engi
|
||||
|
||||
} // namespace routing_algorithms
|
||||
} // namespace engine
|
||||
} // namespace osrm}
|
||||
} // namespace osrm
|
||||
|
||||
@@ -45,10 +45,11 @@ inline bool addLoopWeight(const DataFacade<ch::Algorithm> &facade,
|
||||
}
|
||||
|
||||
template <bool DIRECTION>
|
||||
void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
|
||||
const typename SearchEngineData<Algorithm>::ManyToManyQueryHeap::HeapNode& heapNode,
|
||||
typename SearchEngineData<Algorithm>::ManyToManyQueryHeap &query_heap,
|
||||
const PhantomNode &)
|
||||
void relaxOutgoingEdges(
|
||||
const DataFacade<Algorithm> &facade,
|
||||
const typename SearchEngineData<Algorithm>::ManyToManyQueryHeap::HeapNode &heapNode,
|
||||
typename SearchEngineData<Algorithm>::ManyToManyQueryHeap &query_heap,
|
||||
const PhantomNode &)
|
||||
{
|
||||
if (stallAtNode<DIRECTION>(facade, heapNode, query_heap))
|
||||
{
|
||||
@@ -71,7 +72,7 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
|
||||
const auto to_duration = heapNode.data.duration + edge_duration;
|
||||
const auto to_distance = heapNode.data.distance + edge_distance;
|
||||
|
||||
const auto toHeapNode= query_heap.GetHeapNodeIfWasInserted(to);
|
||||
const auto toHeapNode = query_heap.GetHeapNodeIfWasInserted(to);
|
||||
// New Node discovered -> Add to Heap + Node Info Storage
|
||||
if (!toHeapNode)
|
||||
{
|
||||
@@ -82,7 +83,7 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
|
||||
std::tie(toHeapNode->weight, toHeapNode->data.duration))
|
||||
{
|
||||
toHeapNode->data = {heapNode.node, to_duration, to_distance};
|
||||
toHeapNode->weight=to_weight;
|
||||
toHeapNode->weight = to_weight;
|
||||
query_heap.DecreaseKey(*toHeapNode);
|
||||
}
|
||||
}
|
||||
@@ -100,8 +101,9 @@ void forwardRoutingStep(const DataFacade<Algorithm> &facade,
|
||||
std::vector<NodeID> &middle_nodes_table,
|
||||
const PhantomNode &phantom_node)
|
||||
{
|
||||
// Take a copy of the extracted node because otherwise could be modified later if toHeapNode is the same
|
||||
const auto heapNode=query_heap.DeleteMinGetHeapNode();
|
||||
// Take a copy of the extracted node because otherwise could be modified later if toHeapNode is
|
||||
// the same
|
||||
const auto heapNode = query_heap.DeleteMinGetHeapNode();
|
||||
|
||||
// Check if each encountered node has an entry
|
||||
const auto &bucket_list = std::equal_range(search_space_with_buckets.begin(),
|
||||
@@ -149,8 +151,7 @@ void forwardRoutingStep(const DataFacade<Algorithm> &facade,
|
||||
}
|
||||
}
|
||||
|
||||
relaxOutgoingEdges<FORWARD_DIRECTION>(
|
||||
facade, heapNode, query_heap, phantom_node);
|
||||
relaxOutgoingEdges<FORWARD_DIRECTION>(facade, heapNode, query_heap, phantom_node);
|
||||
}
|
||||
|
||||
void backwardRoutingStep(const DataFacade<Algorithm> &facade,
|
||||
@@ -159,15 +160,19 @@ void backwardRoutingStep(const DataFacade<Algorithm> &facade,
|
||||
std::vector<NodeBucket> &search_space_with_buckets,
|
||||
const PhantomNode &phantom_node)
|
||||
{
|
||||
// Take a copy (no ref &) of the extracted node because otherwise could be modified later if toHeapNode is the same
|
||||
const auto heapNode=query_heap.DeleteMinGetHeapNode();
|
||||
// Take a copy (no ref &) of the extracted node because otherwise could be modified later if
|
||||
// toHeapNode is the same
|
||||
const auto heapNode = query_heap.DeleteMinGetHeapNode();
|
||||
|
||||
// Store settled nodes in search space bucket
|
||||
search_space_with_buckets.emplace_back(
|
||||
heapNode.node, heapNode.data.parent, column_index, heapNode.weight, heapNode.data.duration, heapNode.data.distance);
|
||||
search_space_with_buckets.emplace_back(heapNode.node,
|
||||
heapNode.data.parent,
|
||||
column_index,
|
||||
heapNode.weight,
|
||||
heapNode.data.duration,
|
||||
heapNode.data.distance);
|
||||
|
||||
relaxOutgoingEdges<REVERSE_DIRECTION>(
|
||||
facade, heapNode, query_heap, phantom_node);
|
||||
relaxOutgoingEdges<REVERSE_DIRECTION>(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.GetHeapNodeIfWasInserted(to);
|
||||
const auto toHeapNode = query_heap.GetHeapNodeIfWasInserted(to);
|
||||
if (!toHeapNode)
|
||||
{
|
||||
query_heap.Insert(to, to_weight, {node, false, to_duration, to_distance});
|
||||
@@ -84,7 +84,7 @@ void relaxBorderEdges(const DataFacade<mld::Algorithm> &facade,
|
||||
toHeapNode->data.parent))
|
||||
{
|
||||
toHeapNode->data = {node, false, to_duration, to_distance};
|
||||
toHeapNode->weight=to_weight;
|
||||
toHeapNode->weight = to_weight;
|
||||
query_heap.DecreaseKey(*toHeapNode);
|
||||
}
|
||||
}
|
||||
@@ -92,10 +92,11 @@ void relaxBorderEdges(const DataFacade<mld::Algorithm> &facade,
|
||||
}
|
||||
|
||||
template <bool DIRECTION, typename... Args>
|
||||
void relaxOutgoingEdges(const DataFacade<mld::Algorithm> &facade,
|
||||
const typename SearchEngineData<mld::Algorithm>::ManyToManyQueryHeap::HeapNode& heapNode,
|
||||
typename SearchEngineData<mld::Algorithm>::ManyToManyQueryHeap &query_heap,
|
||||
Args... args)
|
||||
void relaxOutgoingEdges(
|
||||
const DataFacade<mld::Algorithm> &facade,
|
||||
const typename SearchEngineData<mld::Algorithm>::ManyToManyQueryHeap::HeapNode &heapNode,
|
||||
typename SearchEngineData<mld::Algorithm>::ManyToManyQueryHeap &query_heap,
|
||||
Args... args)
|
||||
{
|
||||
BOOST_ASSERT(!facade.ExcludeNode(node));
|
||||
|
||||
@@ -110,7 +111,6 @@ void relaxOutgoingEdges(const DataFacade<mld::Algorithm> &facade,
|
||||
const auto &cells = facade.GetCellStorage();
|
||||
const auto &metric = facade.GetCellMetric();
|
||||
|
||||
|
||||
if (level >= 1 && !heapNode.data.from_clique_arc)
|
||||
{
|
||||
const auto &cell = cells.GetCell(metric, level, partition.GetCell(level, heapNode.node));
|
||||
@@ -130,11 +130,12 @@ void relaxOutgoingEdges(const DataFacade<mld::Algorithm> &facade,
|
||||
{
|
||||
const auto to_weight = heapNode.weight + shortcut_weight;
|
||||
const auto to_duration = heapNode.data.duration + shortcut_durations.front();
|
||||
const auto to_distance = heapNode.data.distance + shortcut_distances.front();
|
||||
const auto toHeapNode= query_heap.GetHeapNodeIfWasInserted(to);
|
||||
const auto to_distance = heapNode.data.distance + shortcut_distances.front();
|
||||
const auto toHeapNode = query_heap.GetHeapNodeIfWasInserted(to);
|
||||
if (!toHeapNode)
|
||||
{
|
||||
query_heap.Insert(to, to_weight, {heapNode.node, true, to_duration, to_distance});
|
||||
query_heap.Insert(
|
||||
to, to_weight, {heapNode.node, true, to_duration, to_distance});
|
||||
}
|
||||
else if (std::tie(to_weight, to_duration, to_distance, heapNode.node) <
|
||||
std::tie(toHeapNode->weight,
|
||||
@@ -143,7 +144,7 @@ void relaxOutgoingEdges(const DataFacade<mld::Algorithm> &facade,
|
||||
toHeapNode->data.parent))
|
||||
{
|
||||
toHeapNode->data = {heapNode.node, true, to_duration, to_distance};
|
||||
toHeapNode->weight=to_weight;
|
||||
toHeapNode->weight = to_weight;
|
||||
query_heap.DecreaseKey(*toHeapNode);
|
||||
}
|
||||
}
|
||||
@@ -169,12 +170,13 @@ void relaxOutgoingEdges(const DataFacade<mld::Algorithm> &facade,
|
||||
if (shortcut_weight != INVALID_EDGE_WEIGHT && heapNode.node != to)
|
||||
{
|
||||
const auto to_weight = heapNode.weight + shortcut_weight;
|
||||
const auto to_duration = heapNode.data.duration + shortcut_durations.front();
|
||||
const auto to_distance = heapNode.data.distance + shortcut_distances.front();
|
||||
const auto toHeapNode= query_heap.GetHeapNodeIfWasInserted(to);
|
||||
const auto to_duration = heapNode.data.duration + shortcut_durations.front();
|
||||
const auto to_distance = heapNode.data.distance + shortcut_distances.front();
|
||||
const auto toHeapNode = query_heap.GetHeapNodeIfWasInserted(to);
|
||||
if (!toHeapNode)
|
||||
{
|
||||
query_heap.Insert(to, to_weight, {heapNode.node, true, to_duration, to_distance});
|
||||
query_heap.Insert(
|
||||
to, to_weight, {heapNode.node, true, to_duration, to_distance});
|
||||
}
|
||||
else if (std::tie(to_weight, to_duration, to_distance, heapNode.node) <
|
||||
std::tie(toHeapNode->weight,
|
||||
@@ -183,7 +185,7 @@ void relaxOutgoingEdges(const DataFacade<mld::Algorithm> &facade,
|
||||
toHeapNode->data.parent))
|
||||
{
|
||||
toHeapNode->data = {heapNode.node, true, to_duration, to_distance};
|
||||
toHeapNode->weight=to_weight;
|
||||
toHeapNode->weight = to_weight;
|
||||
query_heap.DecreaseKey(*toHeapNode);
|
||||
}
|
||||
}
|
||||
@@ -196,7 +198,13 @@ void relaxOutgoingEdges(const DataFacade<mld::Algorithm> &facade,
|
||||
}
|
||||
}
|
||||
|
||||
relaxBorderEdges<DIRECTION>(facade, heapNode.node, heapNode.weight, heapNode.data.duration, heapNode.data.distance, query_heap, level);
|
||||
relaxBorderEdges<DIRECTION>(facade,
|
||||
heapNode.node,
|
||||
heapNode.weight,
|
||||
heapNode.data.duration,
|
||||
heapNode.data.distance,
|
||||
query_heap,
|
||||
level);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -373,18 +381,15 @@ oneToManySearch(SearchEngineData<Algorithm> &engine_working_data,
|
||||
{
|
||||
// Extract node from the heap. Take a copy (no ref) because otherwise can be modified later
|
||||
// if toHeapNode is the same
|
||||
const auto heapNode=query_heap.DeleteMinGetHeapNode();
|
||||
const auto heapNode = query_heap.DeleteMinGetHeapNode();
|
||||
|
||||
// Update values
|
||||
update_values(heapNode.node, heapNode.weight, heapNode.data.duration, heapNode.data.distance);
|
||||
update_values(
|
||||
heapNode.node, heapNode.weight, heapNode.data.duration, heapNode.data.distance);
|
||||
|
||||
// Relax outgoing edges
|
||||
relaxOutgoingEdges<DIRECTION>(facade,
|
||||
heapNode,
|
||||
query_heap,
|
||||
phantom_nodes,
|
||||
phantom_index,
|
||||
phantom_indices);
|
||||
relaxOutgoingEdges<DIRECTION>(
|
||||
facade, heapNode, query_heap, phantom_nodes, phantom_index, phantom_indices);
|
||||
}
|
||||
|
||||
return std::make_pair(durations, distances_table);
|
||||
@@ -406,8 +411,9 @@ void forwardRoutingStep(const DataFacade<Algorithm> &facade,
|
||||
std::vector<NodeID> &middle_nodes_table,
|
||||
const PhantomNode &phantom_node)
|
||||
{
|
||||
// Take a copy of the extracted node because otherwise could be modified later if toHeapNode is the same
|
||||
const auto heapNode=query_heap.DeleteMinGetHeapNode();
|
||||
// Take a copy of the extracted node because otherwise could be modified later if toHeapNode is
|
||||
// the same
|
||||
const auto heapNode = query_heap.DeleteMinGetHeapNode();
|
||||
|
||||
// Check if each encountered node has an entry
|
||||
const auto &bucket_list = std::equal_range(search_space_with_buckets.begin(),
|
||||
@@ -439,9 +445,8 @@ void forwardRoutingStep(const DataFacade<Algorithm> &facade,
|
||||
auto new_duration = heapNode.data.duration + target_duration;
|
||||
auto new_distance = heapNode.data.distance + target_distance;
|
||||
|
||||
if (new_weight >= 0 &&
|
||||
std::tie(new_weight, new_duration, new_distance) <
|
||||
std::tie(current_weight, current_duration, current_distance))
|
||||
if (new_weight >= 0 && std::tie(new_weight, new_duration, new_distance) <
|
||||
std::tie(current_weight, current_duration, current_distance))
|
||||
{
|
||||
current_weight = new_weight;
|
||||
current_duration = new_duration;
|
||||
@@ -450,8 +455,7 @@ void forwardRoutingStep(const DataFacade<Algorithm> &facade,
|
||||
}
|
||||
}
|
||||
|
||||
relaxOutgoingEdges<DIRECTION>(
|
||||
facade, heapNode, query_heap, phantom_node);
|
||||
relaxOutgoingEdges<DIRECTION>(facade, heapNode, query_heap, phantom_node);
|
||||
}
|
||||
|
||||
template <bool DIRECTION>
|
||||
@@ -461,21 +465,23 @@ void backwardRoutingStep(const DataFacade<Algorithm> &facade,
|
||||
std::vector<NodeBucket> &search_space_with_buckets,
|
||||
const PhantomNode &phantom_node)
|
||||
{
|
||||
// Take a copy of the extracted node because otherwise could be modified later if toHeapNode is the same
|
||||
const auto heapNode=query_heap.DeleteMinGetHeapNode();
|
||||
// Take a copy of the extracted node because otherwise could be modified later if toHeapNode is
|
||||
// the same
|
||||
const auto heapNode = query_heap.DeleteMinGetHeapNode();
|
||||
|
||||
// Store settled nodes in search space bucket
|
||||
search_space_with_buckets.emplace_back(
|
||||
heapNode.node, heapNode.data.parent, heapNode.data.from_clique_arc, column_idx, heapNode.weight, heapNode.data.duration, heapNode.data.distance);
|
||||
search_space_with_buckets.emplace_back(heapNode.node,
|
||||
heapNode.data.parent,
|
||||
heapNode.data.from_clique_arc,
|
||||
column_idx,
|
||||
heapNode.weight,
|
||||
heapNode.data.duration,
|
||||
heapNode.data.distance);
|
||||
|
||||
const auto &partition = facade.GetMultiLevelPartition();
|
||||
const auto maximal_level = partition.GetNumberOfLevels() - 1;
|
||||
|
||||
relaxOutgoingEdges<!DIRECTION>(facade,
|
||||
heapNode,
|
||||
query_heap,
|
||||
phantom_node,
|
||||
maximal_level);
|
||||
relaxOutgoingEdges<!DIRECTION>(facade, heapNode, query_heap, phantom_node, maximal_level);
|
||||
}
|
||||
|
||||
template <bool DIRECTION>
|
||||
|
||||
Reference in New Issue
Block a user