renamed: Util/* -> util/*
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
|
||||
Copyright (c) 2014, Project OSRM, Dennis Luxen, others
|
||||
Copyright (c) 2015, Project OSRM, Dennis Luxen, others
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
@@ -30,8 +30,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include "routing_base.hpp"
|
||||
#include "../data_structures/search_engine_data.hpp"
|
||||
#include "../Util/integer_range.hpp"
|
||||
#include "../Util/container.hpp"
|
||||
#include "../util/integer_range.hpp"
|
||||
#include "../util/container.hpp"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
@@ -44,7 +44,8 @@ const double VIAPATH_ALPHA = 0.10;
|
||||
const double VIAPATH_EPSILON = 0.15; // alternative at most 15% longer
|
||||
const double VIAPATH_GAMMA = 0.75; // alternative shares at most 75% with the shortest.
|
||||
|
||||
template <class DataFacadeT> class AlternativeRouting final : private BasicRoutingInterface<DataFacadeT>
|
||||
template <class DataFacadeT>
|
||||
class AlternativeRouting final : private BasicRoutingInterface<DataFacadeT>
|
||||
{
|
||||
using super = BasicRoutingInterface<DataFacadeT>;
|
||||
using EdgeData = typename DataFacadeT::EdgeData;
|
||||
@@ -148,22 +149,16 @@ template <class DataFacadeT> class AlternativeRouting final : private BasicRouti
|
||||
{
|
||||
if (0 < forward_heap1.Size())
|
||||
{
|
||||
AlternativeRoutingStep<true>(forward_heap1,
|
||||
reverse_heap1,
|
||||
&middle_node,
|
||||
AlternativeRoutingStep<true>(forward_heap1, reverse_heap1, &middle_node,
|
||||
&upper_bound_to_shortest_path_distance,
|
||||
via_node_candidate_list,
|
||||
forward_search_space,
|
||||
via_node_candidate_list, forward_search_space,
|
||||
min_edge_offset);
|
||||
}
|
||||
if (0 < reverse_heap1.Size())
|
||||
{
|
||||
AlternativeRoutingStep<false>(reverse_heap1,
|
||||
forward_heap1,
|
||||
&middle_node,
|
||||
AlternativeRoutingStep<false>(reverse_heap1, forward_heap1, &middle_node,
|
||||
&upper_bound_to_shortest_path_distance,
|
||||
via_node_candidate_list,
|
||||
reverse_search_space,
|
||||
via_node_candidate_list, reverse_search_space,
|
||||
min_edge_offset);
|
||||
}
|
||||
}
|
||||
@@ -274,19 +269,16 @@ template <class DataFacadeT> class AlternativeRouting final : private BasicRouti
|
||||
std::vector<NodeID> &packed_shortest_path = packed_forward_path;
|
||||
std::reverse(packed_shortest_path.begin(), packed_shortest_path.end());
|
||||
packed_shortest_path.emplace_back(middle_node);
|
||||
packed_shortest_path.insert(
|
||||
packed_shortest_path.end(), packed_reverse_path.begin(), packed_reverse_path.end());
|
||||
packed_shortest_path.insert(packed_shortest_path.end(), packed_reverse_path.begin(),
|
||||
packed_reverse_path.end());
|
||||
std::vector<RankedCandidateNode> ranked_candidates_list;
|
||||
|
||||
// prioritizing via nodes for deep inspection
|
||||
for (const NodeID node : preselected_node_list)
|
||||
{
|
||||
int length_of_via_path = 0, sharing_of_via_path = 0;
|
||||
ComputeLengthAndSharingOfViaPath(node,
|
||||
&length_of_via_path,
|
||||
&sharing_of_via_path,
|
||||
packed_shortest_path,
|
||||
min_edge_offset);
|
||||
ComputeLengthAndSharingOfViaPath(node, &length_of_via_path, &sharing_of_via_path,
|
||||
packed_shortest_path, min_edge_offset);
|
||||
const int maximum_allowed_sharing =
|
||||
static_cast<int>(upper_bound_to_shortest_path_distance * VIAPATH_GAMMA);
|
||||
if (sharing_of_via_path <= maximum_allowed_sharing &&
|
||||
@@ -302,16 +294,10 @@ template <class DataFacadeT> class AlternativeRouting final : private BasicRouti
|
||||
NodeID s_v_middle = SPECIAL_NODEID, v_t_middle = SPECIAL_NODEID;
|
||||
for (const RankedCandidateNode &candidate : ranked_candidates_list)
|
||||
{
|
||||
if (ViaNodeCandidatePassesTTest(forward_heap1,
|
||||
reverse_heap1,
|
||||
forward_heap2,
|
||||
reverse_heap2,
|
||||
candidate,
|
||||
upper_bound_to_shortest_path_distance,
|
||||
&length_of_via_path,
|
||||
&s_v_middle,
|
||||
&v_t_middle,
|
||||
min_edge_offset))
|
||||
if (ViaNodeCandidatePassesTTest(
|
||||
forward_heap1, reverse_heap1, forward_heap2, reverse_heap2, candidate,
|
||||
upper_bound_to_shortest_path_distance, &length_of_via_path, &s_v_middle,
|
||||
&v_t_middle, min_edge_offset))
|
||||
{
|
||||
// select first admissable
|
||||
selected_via_node = candidate.node;
|
||||
@@ -343,13 +329,8 @@ template <class DataFacadeT> class AlternativeRouting final : private BasicRouti
|
||||
{
|
||||
std::vector<NodeID> packed_alternate_path;
|
||||
// retrieve alternate path
|
||||
RetrievePackedAlternatePath(forward_heap1,
|
||||
reverse_heap1,
|
||||
forward_heap2,
|
||||
reverse_heap2,
|
||||
s_v_middle,
|
||||
v_t_middle,
|
||||
packed_alternate_path);
|
||||
RetrievePackedAlternatePath(forward_heap1, reverse_heap1, forward_heap2, reverse_heap2,
|
||||
s_v_middle, v_t_middle, packed_alternate_path);
|
||||
|
||||
raw_route_data.alt_source_traversed_in_reverse.push_back((
|
||||
packed_alternate_path.front() != phantom_node_pair.source_phantom.forward_node_id));
|
||||
@@ -357,8 +338,8 @@ template <class DataFacadeT> class AlternativeRouting final : private BasicRouti
|
||||
(packed_alternate_path.back() != phantom_node_pair.target_phantom.forward_node_id));
|
||||
|
||||
// unpack the alternate path
|
||||
super::UnpackPath(
|
||||
packed_alternate_path, phantom_node_pair, raw_route_data.unpacked_alternative);
|
||||
super::UnpackPath(packed_alternate_path, phantom_node_pair,
|
||||
raw_route_data.unpacked_alternative);
|
||||
|
||||
raw_route_data.alternative_path_length = length_of_via_path;
|
||||
}
|
||||
@@ -384,8 +365,8 @@ template <class DataFacadeT> class AlternativeRouting final : private BasicRouti
|
||||
packed_path.pop_back(); // remove middle node. It's in both half-paths
|
||||
|
||||
// fetch patched path [v,t]
|
||||
super::RetrievePackedPathFromHeap(
|
||||
forward_heap2, reverse_heap1, v_t_middle, packed_v_t_path);
|
||||
super::RetrievePackedPathFromHeap(forward_heap2, reverse_heap1, v_t_middle,
|
||||
packed_v_t_path);
|
||||
|
||||
packed_path.insert(packed_path.end(), packed_v_t_path.begin(), packed_v_t_path.end());
|
||||
}
|
||||
@@ -420,12 +401,8 @@ template <class DataFacadeT> class AlternativeRouting final : private BasicRouti
|
||||
// compute path <s,..,v> by reusing forward search from s
|
||||
while (!new_reverse_heap.Empty())
|
||||
{
|
||||
super::RoutingStep(new_reverse_heap,
|
||||
existing_forward_heap,
|
||||
&s_v_middle,
|
||||
&upper_bound_s_v_path_length,
|
||||
min_edge_offset,
|
||||
false);
|
||||
super::RoutingStep(new_reverse_heap, existing_forward_heap, &s_v_middle,
|
||||
&upper_bound_s_v_path_length, min_edge_offset, false);
|
||||
}
|
||||
// compute path <v,..,t> by reusing backward search from node t
|
||||
NodeID v_t_middle = SPECIAL_NODEID;
|
||||
@@ -433,12 +410,8 @@ template <class DataFacadeT> class AlternativeRouting final : private BasicRouti
|
||||
new_forward_heap.Insert(via_node, 0, via_node);
|
||||
while (!new_forward_heap.Empty())
|
||||
{
|
||||
super::RoutingStep(new_forward_heap,
|
||||
existing_reverse_heap,
|
||||
&v_t_middle,
|
||||
&upper_bound_of_v_t_path_length,
|
||||
min_edge_offset,
|
||||
true);
|
||||
super::RoutingStep(new_forward_heap, existing_reverse_heap, &v_t_middle,
|
||||
&upper_bound_of_v_t_path_length, min_edge_offset, true);
|
||||
}
|
||||
*real_length_of_via_path = upper_bound_s_v_path_length + upper_bound_of_v_t_path_length;
|
||||
|
||||
@@ -448,10 +421,10 @@ template <class DataFacadeT> class AlternativeRouting final : private BasicRouti
|
||||
}
|
||||
|
||||
// retrieve packed paths
|
||||
super::RetrievePackedPathFromHeap(
|
||||
existing_forward_heap, new_reverse_heap, s_v_middle, packed_s_v_path);
|
||||
super::RetrievePackedPathFromHeap(
|
||||
new_forward_heap, existing_reverse_heap, v_t_middle, packed_v_t_path);
|
||||
super::RetrievePackedPathFromHeap(existing_forward_heap, new_reverse_heap, s_v_middle,
|
||||
packed_s_v_path);
|
||||
super::RetrievePackedPathFromHeap(new_forward_heap, existing_reverse_heap, v_t_middle,
|
||||
packed_v_t_path);
|
||||
|
||||
// partial unpacking, compute sharing
|
||||
// First partially unpack s-->v until paths deviate, note length of common path.
|
||||
@@ -484,12 +457,11 @@ template <class DataFacadeT> class AlternativeRouting final : private BasicRouti
|
||||
const int64_t packed_path_length =
|
||||
std::min(partially_unpacked_via_path.size(), partially_unpacked_shortest_path.size()) -
|
||||
1;
|
||||
for (int64_t current_node = 0;
|
||||
(current_node < packed_path_length) &&
|
||||
(partially_unpacked_via_path[current_node] ==
|
||||
partially_unpacked_shortest_path[current_node] &&
|
||||
partially_unpacked_via_path[current_node + 1] ==
|
||||
partially_unpacked_shortest_path[current_node + 1]);
|
||||
for (int64_t current_node = 0; (current_node < packed_path_length) &&
|
||||
(partially_unpacked_via_path[current_node] ==
|
||||
partially_unpacked_shortest_path[current_node] &&
|
||||
partially_unpacked_via_path[current_node + 1] ==
|
||||
partially_unpacked_shortest_path[current_node + 1]);
|
||||
++current_node)
|
||||
{
|
||||
EdgeID selected_edge =
|
||||
@@ -517,8 +489,7 @@ template <class DataFacadeT> class AlternativeRouting final : private BasicRouti
|
||||
if (packed_v_t_path[via_path_index] == packed_shortest_path[shortest_path_index])
|
||||
{
|
||||
super::UnpackEdge(packed_v_t_path[via_path_index - 1],
|
||||
packed_v_t_path[via_path_index],
|
||||
partially_unpacked_via_path);
|
||||
packed_v_t_path[via_path_index], partially_unpacked_via_path);
|
||||
super::UnpackEdge(packed_shortest_path[shortest_path_index - 1],
|
||||
packed_shortest_path[shortest_path_index],
|
||||
partially_unpacked_shortest_path);
|
||||
@@ -696,12 +667,8 @@ template <class DataFacadeT> class AlternativeRouting final : private BasicRouti
|
||||
new_reverse_heap.Insert(candidate.node, 0, candidate.node);
|
||||
while (new_reverse_heap.Size() > 0)
|
||||
{
|
||||
super::RoutingStep(new_reverse_heap,
|
||||
existing_forward_heap,
|
||||
s_v_middle,
|
||||
&upper_bound_s_v_path_length,
|
||||
min_edge_offset,
|
||||
false);
|
||||
super::RoutingStep(new_reverse_heap, existing_forward_heap, s_v_middle,
|
||||
&upper_bound_s_v_path_length, min_edge_offset, false);
|
||||
}
|
||||
|
||||
if (INVALID_EDGE_WEIGHT == upper_bound_s_v_path_length)
|
||||
@@ -715,12 +682,8 @@ template <class DataFacadeT> class AlternativeRouting final : private BasicRouti
|
||||
new_forward_heap.Insert(candidate.node, 0, candidate.node);
|
||||
while (new_forward_heap.Size() > 0)
|
||||
{
|
||||
super::RoutingStep(new_forward_heap,
|
||||
existing_reverse_heap,
|
||||
v_t_middle,
|
||||
&upper_bound_of_v_t_path_length,
|
||||
min_edge_offset,
|
||||
true);
|
||||
super::RoutingStep(new_forward_heap, existing_reverse_heap, v_t_middle,
|
||||
&upper_bound_of_v_t_path_length, min_edge_offset, true);
|
||||
}
|
||||
|
||||
if (INVALID_EDGE_WEIGHT == upper_bound_of_v_t_path_length)
|
||||
@@ -731,11 +694,11 @@ template <class DataFacadeT> class AlternativeRouting final : private BasicRouti
|
||||
*length_of_via_path = upper_bound_s_v_path_length + upper_bound_of_v_t_path_length;
|
||||
|
||||
// retrieve packed paths
|
||||
super::RetrievePackedPathFromHeap(
|
||||
existing_forward_heap, new_reverse_heap, *s_v_middle, packed_s_v_path);
|
||||
super::RetrievePackedPathFromHeap(existing_forward_heap, new_reverse_heap, *s_v_middle,
|
||||
packed_s_v_path);
|
||||
|
||||
super::RetrievePackedPathFromHeap(
|
||||
new_forward_heap, existing_reverse_heap, *v_t_middle, packed_v_t_path);
|
||||
super::RetrievePackedPathFromHeap(new_forward_heap, existing_reverse_heap, *v_t_middle,
|
||||
packed_v_t_path);
|
||||
|
||||
NodeID s_P = *s_v_middle, t_P = *v_t_middle;
|
||||
if (SPECIAL_NODEID == s_P)
|
||||
@@ -815,8 +778,7 @@ template <class DataFacadeT> class AlternativeRouting final : private BasicRouti
|
||||
// Traverse path s-->v
|
||||
BOOST_ASSERT(!packed_v_t_path.empty());
|
||||
for (unsigned i = 0, packed_path_length = static_cast<unsigned>(packed_v_t_path.size() - 1);
|
||||
(i < packed_path_length) && unpack_stack.empty();
|
||||
++i)
|
||||
(i < packed_path_length) && unpack_stack.empty(); ++i)
|
||||
{
|
||||
const EdgeID edgeID =
|
||||
facade->FindEdgeInEitherDirection(packed_v_t_path[i], packed_v_t_path[i + 1]);
|
||||
@@ -888,13 +850,13 @@ template <class DataFacadeT> class AlternativeRouting final : private BasicRouti
|
||||
{
|
||||
if (!forward_heap3.Empty())
|
||||
{
|
||||
super::RoutingStep(
|
||||
forward_heap3, reverse_heap3, &middle, &upper_bound, min_edge_offset, true);
|
||||
super::RoutingStep(forward_heap3, reverse_heap3, &middle, &upper_bound,
|
||||
min_edge_offset, true);
|
||||
}
|
||||
if (!reverse_heap3.Empty())
|
||||
{
|
||||
super::RoutingStep(
|
||||
reverse_heap3, forward_heap3, &middle, &upper_bound, min_edge_offset, false);
|
||||
super::RoutingStep(reverse_heap3, forward_heap3, &middle, &upper_bound,
|
||||
min_edge_offset, false);
|
||||
}
|
||||
}
|
||||
return (upper_bound <= t_test_path_length);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
|
||||
Copyright (c) 2014, Project OSRM, Dennis Luxen, others
|
||||
Copyright (c) 2015, Project OSRM, Dennis Luxen, others
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
@@ -31,7 +31,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "../data_structures/internal_route_result.hpp"
|
||||
#include "../data_structures/search_engine_data.hpp"
|
||||
#include "../data_structures/turn_instructions.hpp"
|
||||
// #include "../Util/simple_logger.hpp"
|
||||
// #include "../util/simple_logger.hpp"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
@@ -56,7 +56,7 @@ template <class DataFacadeT> class BasicRoutingInterface
|
||||
BasicRoutingInterface() = delete;
|
||||
BasicRoutingInterface(const BasicRoutingInterface &) = delete;
|
||||
explicit BasicRoutingInterface(DataFacadeT *facade) : facade(facade) {}
|
||||
virtual ~BasicRoutingInterface() {};
|
||||
virtual ~BasicRoutingInterface(){};
|
||||
|
||||
inline void RoutingStep(SearchEngineData::QueryHeap &forward_heap,
|
||||
SearchEngineData::QueryHeap &reverse_heap,
|
||||
@@ -69,7 +69,8 @@ template <class DataFacadeT> class BasicRoutingInterface
|
||||
const int distance = forward_heap.GetKey(node);
|
||||
|
||||
// const NodeID parentnode = forward_heap.GetData(node).parent;
|
||||
// SimpleLogger().Write() << (forward_direction ? "[fwd] " : "[rev] ") << "settled edge (" << parentnode << "," << node << "), dist: " << distance;
|
||||
// SimpleLogger().Write() << (forward_direction ? "[fwd] " : "[rev] ") << "settled edge ("
|
||||
// << parentnode << "," << node << "), dist: " << distance;
|
||||
|
||||
if (reverse_heap.WasInserted(node))
|
||||
{
|
||||
@@ -80,9 +81,11 @@ template <class DataFacadeT> class BasicRoutingInterface
|
||||
{
|
||||
*middle_node_id = node;
|
||||
*upper_bound = new_distance;
|
||||
// SimpleLogger().Write() << "accepted middle node " << node << " at distance " << new_distance;
|
||||
// } else {
|
||||
// SimpleLogger().Write() << "discared middle node " << node << " at distance " << new_distance;
|
||||
// SimpleLogger().Write() << "accepted middle node " << node << " at
|
||||
// distance " << new_distance;
|
||||
// } else {
|
||||
// SimpleLogger().Write() << "discared middle node " << node << " at
|
||||
// distance " << new_distance;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -228,15 +231,11 @@ template <class DataFacadeT> class BasicRoutingInterface
|
||||
const TurnInstruction turn_instruction = facade->GetTurnInstructionForEdgeID(ed.id);
|
||||
const TravelMode travel_mode = facade->GetTravelModeForEdgeID(ed.id);
|
||||
|
||||
|
||||
if (!facade->EdgeIsCompressed(ed.id))
|
||||
{
|
||||
BOOST_ASSERT(!facade->EdgeIsCompressed(ed.id));
|
||||
unpacked_path.emplace_back(facade->GetGeometryIndexForEdgeID(ed.id),
|
||||
name_index,
|
||||
turn_instruction,
|
||||
ed.distance,
|
||||
travel_mode);
|
||||
unpacked_path.emplace_back(facade->GetGeometryIndexForEdgeID(ed.id), name_index,
|
||||
turn_instruction, ed.distance, travel_mode);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -257,7 +256,8 @@ template <class DataFacadeT> class BasicRoutingInterface
|
||||
BOOST_ASSERT(start_index <= end_index);
|
||||
for (std::size_t i = start_index; i < end_index; ++i)
|
||||
{
|
||||
unpacked_path.emplace_back(id_vector[i], name_index, TurnInstruction::NoTurn, 0, travel_mode);
|
||||
unpacked_path.emplace_back(id_vector[i], name_index,
|
||||
TurnInstruction::NoTurn, 0, travel_mode);
|
||||
}
|
||||
unpacked_path.back().turn_instruction = turn_instruction;
|
||||
unpacked_path.back().segment_duration = ed.distance;
|
||||
@@ -294,18 +294,19 @@ template <class DataFacadeT> class BasicRoutingInterface
|
||||
|
||||
if (start_index > end_index)
|
||||
{
|
||||
start_index = std::min(start_index, id_vector.size()-1);
|
||||
start_index = std::min(start_index, id_vector.size() - 1);
|
||||
}
|
||||
|
||||
for (std::size_t i = start_index; i != end_index; (start_index < end_index ? ++i : --i))
|
||||
{
|
||||
BOOST_ASSERT(i < id_vector.size());
|
||||
BOOST_ASSERT(phantom_node_pair.target_phantom.forward_travel_mode>0 );
|
||||
unpacked_path.emplace_back(PathData{id_vector[i],
|
||||
phantom_node_pair.target_phantom.name_id,
|
||||
TurnInstruction::NoTurn,
|
||||
0,
|
||||
phantom_node_pair.target_phantom.forward_travel_mode});
|
||||
BOOST_ASSERT(phantom_node_pair.target_phantom.forward_travel_mode > 0);
|
||||
unpacked_path.emplace_back(
|
||||
PathData{id_vector[i],
|
||||
phantom_node_pair.target_phantom.name_id,
|
||||
TurnInstruction::NoTurn,
|
||||
0,
|
||||
phantom_node_pair.target_phantom.forward_travel_mode});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,7 +368,8 @@ template <class DataFacadeT> class BasicRoutingInterface
|
||||
}
|
||||
}
|
||||
}
|
||||
BOOST_ASSERT_MSG(edge_weight != std::numeric_limits<EdgeWeight>::max(), "edge weight invalid");
|
||||
BOOST_ASSERT_MSG(edge_weight != std::numeric_limits<EdgeWeight>::max(),
|
||||
"edge weight invalid");
|
||||
|
||||
const EdgeData &ed = facade->GetEdgeData(smaller_edge_id);
|
||||
if (ed.shortcut)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
|
||||
Copyright (c) 2014, Project OSRM, Dennis Luxen, others
|
||||
Copyright (c) 2015, Project OSRM, Dennis Luxen, others
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
@@ -32,10 +32,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include "routing_base.hpp"
|
||||
#include "../data_structures/search_engine_data.hpp"
|
||||
#include "../Util/integer_range.hpp"
|
||||
#include "../util/integer_range.hpp"
|
||||
#include "../typedefs.h"
|
||||
|
||||
template <class DataFacadeT> class ShortestPathRouting final : public BasicRoutingInterface<DataFacadeT>
|
||||
template <class DataFacadeT>
|
||||
class ShortestPathRouting final : public BasicRoutingInterface<DataFacadeT>
|
||||
{
|
||||
using super = BasicRoutingInterface<DataFacadeT>;
|
||||
using QueryHeap = SearchEngineData::QueryHeap;
|
||||
@@ -88,7 +89,8 @@ template <class DataFacadeT> class ShortestPathRouting final : public BasicRouti
|
||||
middle1 = SPECIAL_NODEID;
|
||||
middle2 = SPECIAL_NODEID;
|
||||
|
||||
const bool allow_u_turn = current_leg > 0 && uturn_indicators.size() > current_leg && uturn_indicators[current_leg-1];
|
||||
const bool allow_u_turn = current_leg > 0 && uturn_indicators.size() > current_leg &&
|
||||
uturn_indicators[current_leg - 1];
|
||||
EdgeWeight min_edge_offset = 0;
|
||||
|
||||
// insert new starting nodes into forward heap, adjusted by previous distances.
|
||||
@@ -97,35 +99,58 @@ template <class DataFacadeT> class ShortestPathRouting final : public BasicRouti
|
||||
{
|
||||
forward_heap1.Insert(
|
||||
phantom_node_pair.source_phantom.forward_node_id,
|
||||
(allow_u_turn ? 0 : distance1) - phantom_node_pair.source_phantom.GetForwardWeightPlusOffset(),
|
||||
(allow_u_turn ? 0 : distance1) -
|
||||
phantom_node_pair.source_phantom.GetForwardWeightPlusOffset(),
|
||||
phantom_node_pair.source_phantom.forward_node_id);
|
||||
min_edge_offset = std::min(min_edge_offset, (allow_u_turn ? 0 : distance1) - phantom_node_pair.source_phantom.GetForwardWeightPlusOffset());
|
||||
// SimpleLogger().Write(logDEBUG) << "fwd-a2 insert: " << phantom_node_pair.source_phantom.forward_node_id << ", w: " << (allow_u_turn ? 0 : distance1) - phantom_node_pair.source_phantom.GetForwardWeightPlusOffset();
|
||||
min_edge_offset =
|
||||
std::min(min_edge_offset,
|
||||
(allow_u_turn ? 0 : distance1) -
|
||||
phantom_node_pair.source_phantom.GetForwardWeightPlusOffset());
|
||||
// SimpleLogger().Write(logDEBUG) << "fwd-a2 insert: " <<
|
||||
// phantom_node_pair.source_phantom.forward_node_id << ", w: " << (allow_u_turn ? 0
|
||||
// : distance1) - phantom_node_pair.source_phantom.GetForwardWeightPlusOffset();
|
||||
forward_heap2.Insert(
|
||||
phantom_node_pair.source_phantom.forward_node_id,
|
||||
(allow_u_turn ? 0 : distance1) - phantom_node_pair.source_phantom.GetForwardWeightPlusOffset(),
|
||||
(allow_u_turn ? 0 : distance1) -
|
||||
phantom_node_pair.source_phantom.GetForwardWeightPlusOffset(),
|
||||
phantom_node_pair.source_phantom.forward_node_id);
|
||||
min_edge_offset = std::min(min_edge_offset, (allow_u_turn ? 0 : distance1) - phantom_node_pair.source_phantom.GetForwardWeightPlusOffset());
|
||||
// SimpleLogger().Write(logDEBUG) << "fwd-b2 insert: " << phantom_node_pair.source_phantom.forward_node_id << ", w: " << (allow_u_turn ? 0 : distance1) - phantom_node_pair.source_phantom.GetForwardWeightPlusOffset();
|
||||
|
||||
min_edge_offset =
|
||||
std::min(min_edge_offset,
|
||||
(allow_u_turn ? 0 : distance1) -
|
||||
phantom_node_pair.source_phantom.GetForwardWeightPlusOffset());
|
||||
// SimpleLogger().Write(logDEBUG) << "fwd-b2 insert: " <<
|
||||
// phantom_node_pair.source_phantom.forward_node_id << ", w: " << (allow_u_turn ? 0
|
||||
// : distance1) - phantom_node_pair.source_phantom.GetForwardWeightPlusOffset();
|
||||
}
|
||||
if ((allow_u_turn || search_from_2nd_node) &&
|
||||
phantom_node_pair.source_phantom.reverse_node_id != SPECIAL_NODEID)
|
||||
{
|
||||
forward_heap1.Insert(
|
||||
phantom_node_pair.source_phantom.reverse_node_id,
|
||||
(allow_u_turn ? 0 : distance2) - phantom_node_pair.source_phantom.GetReverseWeightPlusOffset(),
|
||||
(allow_u_turn ? 0 : distance2) -
|
||||
phantom_node_pair.source_phantom.GetReverseWeightPlusOffset(),
|
||||
phantom_node_pair.source_phantom.reverse_node_id);
|
||||
min_edge_offset = std::min(min_edge_offset, (allow_u_turn ? 0 : distance2) - phantom_node_pair.source_phantom.GetReverseWeightPlusOffset());
|
||||
// SimpleLogger().Write(logDEBUG) << "fwd-a2 insert: " << phantom_node_pair.source_phantom.reverse_node_id <<
|
||||
// ", w: " << (allow_u_turn ? 0 : distance2) - phantom_node_pair.source_phantom.GetReverseWeightPlusOffset();
|
||||
min_edge_offset =
|
||||
std::min(min_edge_offset,
|
||||
(allow_u_turn ? 0 : distance2) -
|
||||
phantom_node_pair.source_phantom.GetReverseWeightPlusOffset());
|
||||
// SimpleLogger().Write(logDEBUG) << "fwd-a2 insert: " <<
|
||||
// phantom_node_pair.source_phantom.reverse_node_id <<
|
||||
// ", w: " << (allow_u_turn ? 0 : distance2) -
|
||||
// phantom_node_pair.source_phantom.GetReverseWeightPlusOffset();
|
||||
forward_heap2.Insert(
|
||||
phantom_node_pair.source_phantom.reverse_node_id,
|
||||
(allow_u_turn ? 0 : distance2) - phantom_node_pair.source_phantom.GetReverseWeightPlusOffset(),
|
||||
(allow_u_turn ? 0 : distance2) -
|
||||
phantom_node_pair.source_phantom.GetReverseWeightPlusOffset(),
|
||||
phantom_node_pair.source_phantom.reverse_node_id);
|
||||
min_edge_offset = std::min(min_edge_offset, (allow_u_turn ? 0 : distance2) - phantom_node_pair.source_phantom.GetReverseWeightPlusOffset());
|
||||
// SimpleLogger().Write(logDEBUG) << "fwd-b2 insert: " << phantom_node_pair.source_phantom.reverse_node_id <<
|
||||
// ", w: " << (allow_u_turn ? 0 : distance2) - phantom_node_pair.source_phantom.GetReverseWeightPlusOffset();
|
||||
min_edge_offset =
|
||||
std::min(min_edge_offset,
|
||||
(allow_u_turn ? 0 : distance2) -
|
||||
phantom_node_pair.source_phantom.GetReverseWeightPlusOffset());
|
||||
// SimpleLogger().Write(logDEBUG) << "fwd-b2 insert: " <<
|
||||
// phantom_node_pair.source_phantom.reverse_node_id <<
|
||||
// ", w: " << (allow_u_turn ? 0 : distance2) -
|
||||
// phantom_node_pair.source_phantom.GetReverseWeightPlusOffset();
|
||||
}
|
||||
|
||||
// insert new backward nodes into backward heap, unadjusted.
|
||||
@@ -134,17 +159,21 @@ template <class DataFacadeT> class ShortestPathRouting final : public BasicRouti
|
||||
reverse_heap1.Insert(phantom_node_pair.target_phantom.forward_node_id,
|
||||
phantom_node_pair.target_phantom.GetForwardWeightPlusOffset(),
|
||||
phantom_node_pair.target_phantom.forward_node_id);
|
||||
// SimpleLogger().Write(logDEBUG) << "rev-a insert: " << phantom_node_pair.target_phantom.forward_node_id <<
|
||||
// ", w: " << phantom_node_pair.target_phantom.GetForwardWeightPlusOffset();
|
||||
}
|
||||
// SimpleLogger().Write(logDEBUG) << "rev-a insert: " <<
|
||||
// phantom_node_pair.target_phantom.forward_node_id <<
|
||||
// ", w: " <<
|
||||
// phantom_node_pair.target_phantom.GetForwardWeightPlusOffset();
|
||||
}
|
||||
|
||||
if (phantom_node_pair.target_phantom.reverse_node_id != SPECIAL_NODEID)
|
||||
{
|
||||
reverse_heap2.Insert(phantom_node_pair.target_phantom.reverse_node_id,
|
||||
phantom_node_pair.target_phantom.GetReverseWeightPlusOffset(),
|
||||
phantom_node_pair.target_phantom.reverse_node_id);
|
||||
// SimpleLogger().Write(logDEBUG) << "rev-a insert: " << phantom_node_pair.target_phantom.reverse_node_id <<
|
||||
// ", w: " << phantom_node_pair.target_phantom.GetReverseWeightPlusOffset();
|
||||
// SimpleLogger().Write(logDEBUG) << "rev-a insert: " <<
|
||||
// phantom_node_pair.target_phantom.reverse_node_id <<
|
||||
// ", w: " <<
|
||||
// phantom_node_pair.target_phantom.GetReverseWeightPlusOffset();
|
||||
}
|
||||
|
||||
// run two-Target Dijkstra routing step.
|
||||
@@ -152,13 +181,13 @@ template <class DataFacadeT> class ShortestPathRouting final : public BasicRouti
|
||||
{
|
||||
if (!forward_heap1.Empty())
|
||||
{
|
||||
super::RoutingStep(
|
||||
forward_heap1, reverse_heap1, &middle1, &local_upper_bound1, min_edge_offset, true);
|
||||
super::RoutingStep(forward_heap1, reverse_heap1, &middle1, &local_upper_bound1,
|
||||
min_edge_offset, true);
|
||||
}
|
||||
if (!reverse_heap1.Empty())
|
||||
{
|
||||
super::RoutingStep(
|
||||
reverse_heap1, forward_heap1, &middle1, &local_upper_bound1, min_edge_offset, false);
|
||||
super::RoutingStep(reverse_heap1, forward_heap1, &middle1, &local_upper_bound1,
|
||||
min_edge_offset, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,13 +197,13 @@ template <class DataFacadeT> class ShortestPathRouting final : public BasicRouti
|
||||
{
|
||||
if (!forward_heap2.Empty())
|
||||
{
|
||||
super::RoutingStep(
|
||||
forward_heap2, reverse_heap2, &middle2, &local_upper_bound2, min_edge_offset, true);
|
||||
super::RoutingStep(forward_heap2, reverse_heap2, &middle2,
|
||||
&local_upper_bound2, min_edge_offset, true);
|
||||
}
|
||||
if (!reverse_heap2.Empty())
|
||||
{
|
||||
super::RoutingStep(
|
||||
reverse_heap2, forward_heap2, &middle2, &local_upper_bound2, min_edge_offset, false);
|
||||
super::RoutingStep(reverse_heap2, forward_heap2, &middle2,
|
||||
&local_upper_bound2, min_edge_offset, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -200,7 +229,8 @@ template <class DataFacadeT> class ShortestPathRouting final : public BasicRouti
|
||||
}
|
||||
|
||||
// Was at most one of the two paths not found?
|
||||
BOOST_ASSERT_MSG((INVALID_EDGE_WEIGHT != distance1 || INVALID_EDGE_WEIGHT != distance2), "no path found");
|
||||
BOOST_ASSERT_MSG((INVALID_EDGE_WEIGHT != distance1 || INVALID_EDGE_WEIGHT != distance2),
|
||||
"no path found");
|
||||
|
||||
// Unpack paths if they exist
|
||||
std::vector<NodeID> temporary_packed_leg1;
|
||||
@@ -211,18 +241,19 @@ template <class DataFacadeT> class ShortestPathRouting final : public BasicRouti
|
||||
|
||||
if (INVALID_EDGE_WEIGHT != local_upper_bound1)
|
||||
{
|
||||
super::RetrievePackedPathFromHeap(
|
||||
forward_heap1, reverse_heap1, middle1, temporary_packed_leg1);
|
||||
super::RetrievePackedPathFromHeap(forward_heap1, reverse_heap1, middle1,
|
||||
temporary_packed_leg1);
|
||||
}
|
||||
|
||||
if (INVALID_EDGE_WEIGHT != local_upper_bound2)
|
||||
{
|
||||
super::RetrievePackedPathFromHeap(
|
||||
forward_heap2, reverse_heap2, middle2, temporary_packed_leg2);
|
||||
super::RetrievePackedPathFromHeap(forward_heap2, reverse_heap2, middle2,
|
||||
temporary_packed_leg2);
|
||||
}
|
||||
|
||||
// if one of the paths was not found, replace it with the other one.
|
||||
if ((allow_u_turn && local_upper_bound1 > local_upper_bound2) || temporary_packed_leg1.empty())
|
||||
if ((allow_u_turn && local_upper_bound1 > local_upper_bound2) ||
|
||||
temporary_packed_leg1.empty())
|
||||
{
|
||||
temporary_packed_leg1.clear();
|
||||
temporary_packed_leg1.insert(temporary_packed_leg1.end(),
|
||||
@@ -230,7 +261,8 @@ template <class DataFacadeT> class ShortestPathRouting final : public BasicRouti
|
||||
temporary_packed_leg2.end());
|
||||
local_upper_bound1 = local_upper_bound2;
|
||||
}
|
||||
if ((allow_u_turn && local_upper_bound2 > local_upper_bound1) || temporary_packed_leg2.empty())
|
||||
if ((allow_u_turn && local_upper_bound2 > local_upper_bound1) ||
|
||||
temporary_packed_leg2.empty())
|
||||
{
|
||||
temporary_packed_leg2.clear();
|
||||
temporary_packed_leg2.insert(temporary_packed_leg2.end(),
|
||||
@@ -287,7 +319,8 @@ template <class DataFacadeT> class ShortestPathRouting final : public BasicRouti
|
||||
temporary_packed_leg2.end());
|
||||
BOOST_ASSERT(packed_legs2[current_leg].size() == temporary_packed_leg2.size());
|
||||
|
||||
if (!allow_u_turn && (packed_legs1[current_leg].back() == packed_legs2[current_leg].back()) &&
|
||||
if (!allow_u_turn &&
|
||||
(packed_legs1[current_leg].back() == packed_legs2[current_leg].back()) &&
|
||||
phantom_node_pair.target_phantom.is_bidirected())
|
||||
{
|
||||
const NodeID last_node_id = packed_legs2[current_leg].back();
|
||||
@@ -324,9 +357,11 @@ template <class DataFacadeT> class ShortestPathRouting final : public BasicRouti
|
||||
raw_route_data.unpacked_path_segments[index]);
|
||||
|
||||
raw_route_data.source_traversed_in_reverse.push_back(
|
||||
(packed_legs1[index].front() != phantom_nodes_vector[index].source_phantom.forward_node_id));
|
||||
(packed_legs1[index].front() !=
|
||||
phantom_nodes_vector[index].source_phantom.forward_node_id));
|
||||
raw_route_data.target_traversed_in_reverse.push_back(
|
||||
(packed_legs1[index].back() != phantom_nodes_vector[index].target_phantom.forward_node_id));
|
||||
(packed_legs1[index].back() !=
|
||||
phantom_nodes_vector[index].target_phantom.forward_node_id));
|
||||
}
|
||||
raw_route_data.shortest_path_length = std::min(distance1, distance2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user