use constexpr if
This commit is contained in:
parent
7e2fd63f0a
commit
6b4665c7b2
@ -269,6 +269,25 @@ retrievePackedPathFromHeap(const SearchEngineData<Algorithm>::QueryHeap &forward
|
|||||||
return packed_path;
|
return packed_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename Heap>
|
||||||
|
void insertOrUpdate(Heap &heap,
|
||||||
|
const NodeID node,
|
||||||
|
const EdgeWeight weight,
|
||||||
|
const typename Heap::DataType &data)
|
||||||
|
{
|
||||||
|
const auto heapNode = heap.GetHeapNodeIfWasInserted(node);
|
||||||
|
if (!heapNode)
|
||||||
|
{
|
||||||
|
heap.Insert(node, weight, data);
|
||||||
|
}
|
||||||
|
else if (weight < heapNode->weight)
|
||||||
|
{
|
||||||
|
heapNode->data = data;
|
||||||
|
heapNode->weight = weight;
|
||||||
|
heap.DecreaseKey(*heapNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template <bool DIRECTION, typename Algorithm, typename Heap, typename... Args>
|
template <bool DIRECTION, typename Algorithm, typename Heap, typename... Args>
|
||||||
void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
|
void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
|
||||||
Heap &forward_heap,
|
Heap &forward_heap,
|
||||||
@ -316,36 +335,18 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
|
|||||||
{
|
{
|
||||||
const EdgeWeight to_weight = heapNode.weight + shortcut_weight;
|
const EdgeWeight to_weight = heapNode.weight + shortcut_weight;
|
||||||
BOOST_ASSERT(to_weight >= heapNode.weight);
|
BOOST_ASSERT(to_weight >= heapNode.weight);
|
||||||
const auto toHeapNode = forward_heap.GetHeapNodeIfWasInserted(to);
|
|
||||||
if (!toHeapNode)
|
if constexpr (std::is_same_v<typename SearchEngineData<
|
||||||
|
mld::Algorithm>::MapMatchingQueryHeap,
|
||||||
|
Heap>)
|
||||||
{
|
{
|
||||||
if constexpr (std::is_same_v<typename SearchEngineData<
|
const EdgeDistance to_distance = heapNode.data.distance + *distance;
|
||||||
mld::Algorithm>::MapMatchingQueryHeap,
|
insertOrUpdate(
|
||||||
Heap>)
|
forward_heap, to, to_weight, {heapNode.node, true, to_distance});
|
||||||
{
|
|
||||||
const EdgeDistance to_distance = heapNode.data.distance + *distance;
|
|
||||||
forward_heap.Insert(to, to_weight, {heapNode.node, true, to_distance});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
forward_heap.Insert(to, to_weight, {heapNode.node, true});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (to_weight < toHeapNode->weight)
|
else
|
||||||
{
|
{
|
||||||
if constexpr (std::is_same_v<typename SearchEngineData<
|
insertOrUpdate(forward_heap, to, to_weight, {heapNode.node, true});
|
||||||
mld::Algorithm>::MapMatchingQueryHeap,
|
|
||||||
Heap>)
|
|
||||||
{
|
|
||||||
const EdgeDistance to_distance = heapNode.data.distance + *distance;
|
|
||||||
toHeapNode->data = {heapNode.node, true, to_distance};
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
toHeapNode->data = {heapNode.node, true};
|
|
||||||
}
|
|
||||||
toHeapNode->weight = to_weight;
|
|
||||||
forward_heap.DecreaseKey(*toHeapNode);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
++destination;
|
++destination;
|
||||||
@ -384,36 +385,17 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
|
|||||||
{
|
{
|
||||||
const EdgeWeight to_weight = heapNode.weight + shortcut_weight;
|
const EdgeWeight to_weight = heapNode.weight + shortcut_weight;
|
||||||
BOOST_ASSERT(to_weight >= heapNode.weight);
|
BOOST_ASSERT(to_weight >= heapNode.weight);
|
||||||
const auto toHeapNode = forward_heap.GetHeapNodeIfWasInserted(to);
|
if constexpr (std::is_same_v<typename SearchEngineData<
|
||||||
if (!toHeapNode)
|
mld::Algorithm>::MapMatchingQueryHeap,
|
||||||
|
Heap>)
|
||||||
{
|
{
|
||||||
if constexpr (std::is_same_v<typename SearchEngineData<
|
const EdgeDistance to_distance = heapNode.data.distance + *distance;
|
||||||
mld::Algorithm>::MapMatchingQueryHeap,
|
insertOrUpdate(
|
||||||
Heap>)
|
forward_heap, to, to_weight, {heapNode.node, true, to_distance});
|
||||||
{
|
|
||||||
const EdgeDistance to_distance = heapNode.data.distance + *distance;
|
|
||||||
forward_heap.Insert(to, to_weight, {heapNode.node, true, to_distance});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
forward_heap.Insert(to, to_weight, {heapNode.node, true});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (to_weight < toHeapNode->weight)
|
else
|
||||||
{
|
{
|
||||||
if constexpr (std::is_same_v<typename SearchEngineData<
|
insertOrUpdate(forward_heap, to, to_weight, {heapNode.node, true});
|
||||||
mld::Algorithm>::MapMatchingQueryHeap,
|
|
||||||
Heap>)
|
|
||||||
{
|
|
||||||
const EdgeDistance to_distance = heapNode.data.distance + *distance;
|
|
||||||
toHeapNode->data = {heapNode.node, true, to_distance};
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
toHeapNode->data = {heapNode.node, true};
|
|
||||||
}
|
|
||||||
toHeapNode->weight = to_weight;
|
|
||||||
forward_heap.DecreaseKey(*toHeapNode);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
++source;
|
++source;
|
||||||
@ -444,42 +426,20 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
|
|||||||
const EdgeWeight to_weight =
|
const EdgeWeight to_weight =
|
||||||
heapNode.weight + node_weight + alias_cast<EdgeWeight>(turn_penalty);
|
heapNode.weight + node_weight + alias_cast<EdgeWeight>(turn_penalty);
|
||||||
|
|
||||||
const auto toHeapNode = forward_heap.GetHeapNodeIfWasInserted(to);
|
if constexpr (std::is_same_v<
|
||||||
if (!toHeapNode)
|
typename SearchEngineData<mld::Algorithm>::MapMatchingQueryHeap,
|
||||||
|
Heap>)
|
||||||
{
|
{
|
||||||
if constexpr (std::is_same_v<typename SearchEngineData<
|
const auto node_distance =
|
||||||
mld::Algorithm>::MapMatchingQueryHeap,
|
facade.GetNodeDistance(DIRECTION == FORWARD_DIRECTION ? heapNode.node : to);
|
||||||
Heap>)
|
|
||||||
{
|
|
||||||
const auto node_distance = facade.GetNodeDistance(
|
|
||||||
DIRECTION == FORWARD_DIRECTION ? heapNode.node : to);
|
|
||||||
|
|
||||||
const EdgeDistance to_distance = heapNode.data.distance + node_distance;
|
const EdgeDistance to_distance = heapNode.data.distance + node_distance;
|
||||||
forward_heap.Insert(to, to_weight, {heapNode.node, false, to_distance});
|
insertOrUpdate(
|
||||||
}
|
forward_heap, to, to_weight, {heapNode.node, false, to_distance});
|
||||||
else
|
|
||||||
{
|
|
||||||
forward_heap.Insert(to, to_weight, {heapNode.node, false});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (to_weight < toHeapNode->weight)
|
else
|
||||||
{
|
{
|
||||||
if constexpr (std::is_same_v<typename SearchEngineData<
|
insertOrUpdate(forward_heap, to, to_weight, {heapNode.node, false});
|
||||||
mld::Algorithm>::MapMatchingQueryHeap,
|
|
||||||
Heap>)
|
|
||||||
{
|
|
||||||
const auto node_distance = facade.GetNodeDistance(
|
|
||||||
DIRECTION == FORWARD_DIRECTION ? heapNode.node : to);
|
|
||||||
|
|
||||||
const EdgeDistance to_distance = heapNode.data.distance + node_distance;
|
|
||||||
toHeapNode->data = {heapNode.node, false, to_distance};
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
toHeapNode->data = {heapNode.node, false};
|
|
||||||
}
|
|
||||||
toHeapNode->weight = to_weight;
|
|
||||||
forward_heap.DecreaseKey(*toHeapNode);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -601,9 +561,6 @@ UnpackedPath search(SearchEngineData<Algorithm> &engine_working_data,
|
|||||||
|
|
||||||
const auto &partition = facade.GetMultiLevelPartition();
|
const auto &partition = facade.GetMultiLevelPartition();
|
||||||
|
|
||||||
// std::cerr << "Distance = " << forward_heap.GetData(middle).distance << " " <<
|
|
||||||
// reverse_heap.GetData(middle).distance << std::endl;
|
|
||||||
|
|
||||||
// Get packed path as edges {from node ID, to node ID, from_clique_arc}
|
// Get packed path as edges {from node ID, to node ID, from_clique_arc}
|
||||||
auto packed_path = retrievePackedPathFromHeap(forward_heap, reverse_heap, middle);
|
auto packed_path = retrievePackedPathFromHeap(forward_heap, reverse_heap, middle);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user