Rename increasingly inaccuratly named distance member of QueryEdge to weight
This commit is contained in:
parent
1d994da12b
commit
b8795c7341
@ -37,22 +37,22 @@ class GraphContractor
|
||||
struct ContractorEdgeData
|
||||
{
|
||||
ContractorEdgeData()
|
||||
: distance(0), id(0), originalEdges(0), shortcut(0), forward(0), backward(0),
|
||||
: weight(0), id(0), originalEdges(0), shortcut(0), forward(0), backward(0),
|
||||
is_original_via_node_ID(false)
|
||||
{
|
||||
}
|
||||
ContractorEdgeData(unsigned distance,
|
||||
ContractorEdgeData(unsigned weight,
|
||||
unsigned original_edges,
|
||||
unsigned id,
|
||||
bool shortcut,
|
||||
bool forward,
|
||||
bool backward)
|
||||
: distance(distance), id(id),
|
||||
originalEdges(std::min((unsigned)1 << 28, original_edges)), shortcut(shortcut),
|
||||
forward(forward), backward(backward), is_original_via_node_ID(false)
|
||||
: weight(weight), id(id), originalEdges(std::min((unsigned)1 << 28, original_edges)),
|
||||
shortcut(shortcut), forward(forward), backward(backward),
|
||||
is_original_via_node_ID(false)
|
||||
{
|
||||
}
|
||||
unsigned distance;
|
||||
unsigned weight;
|
||||
unsigned id;
|
||||
unsigned originalEdges : 28;
|
||||
bool shortcut : 1;
|
||||
@ -153,8 +153,6 @@ class GraphContractor
|
||||
const auto dend = input_edge_list.dend();
|
||||
for (auto diter = input_edge_list.dbegin(); diter != dend; ++diter)
|
||||
{
|
||||
BOOST_ASSERT_MSG(static_cast<unsigned int>(std::max(diter->weight, 1)) > 0,
|
||||
"edge distance < 1");
|
||||
#ifndef NDEBUG
|
||||
if (static_cast<unsigned int>(std::max(diter->weight, 1)) > 24 * 60 * 60 * 10)
|
||||
{
|
||||
@ -210,26 +208,26 @@ class GraphContractor
|
||||
forward_edge.data.shortcut = reverse_edge.data.shortcut = false;
|
||||
forward_edge.data.id = reverse_edge.data.id = id;
|
||||
forward_edge.data.originalEdges = reverse_edge.data.originalEdges = 1;
|
||||
forward_edge.data.distance = reverse_edge.data.distance = INVALID_EDGE_WEIGHT;
|
||||
forward_edge.data.weight = reverse_edge.data.weight = INVALID_EDGE_WEIGHT;
|
||||
// remove parallel edges
|
||||
while (i < edges.size() && edges[i].source == source && edges[i].target == target)
|
||||
{
|
||||
if (edges[i].data.forward)
|
||||
{
|
||||
forward_edge.data.distance =
|
||||
std::min(edges[i].data.distance, forward_edge.data.distance);
|
||||
forward_edge.data.weight =
|
||||
std::min(edges[i].data.weight, forward_edge.data.weight);
|
||||
}
|
||||
if (edges[i].data.backward)
|
||||
{
|
||||
reverse_edge.data.distance =
|
||||
std::min(edges[i].data.distance, reverse_edge.data.distance);
|
||||
reverse_edge.data.weight =
|
||||
std::min(edges[i].data.weight, reverse_edge.data.weight);
|
||||
}
|
||||
++i;
|
||||
}
|
||||
// merge edges (s,t) and (t,s) into bidirectional edge
|
||||
if (forward_edge.data.distance == reverse_edge.data.distance)
|
||||
if (forward_edge.data.weight == reverse_edge.data.weight)
|
||||
{
|
||||
if ((int)forward_edge.data.distance != INVALID_EDGE_WEIGHT)
|
||||
if ((int)forward_edge.data.weight != INVALID_EDGE_WEIGHT)
|
||||
{
|
||||
forward_edge.data.backward = true;
|
||||
edges[edge++] = forward_edge;
|
||||
@ -237,11 +235,11 @@ class GraphContractor
|
||||
}
|
||||
else
|
||||
{ // insert seperate edges
|
||||
if (((int)forward_edge.data.distance) != INVALID_EDGE_WEIGHT)
|
||||
if (((int)forward_edge.data.weight) != INVALID_EDGE_WEIGHT)
|
||||
{
|
||||
edges[edge++] = forward_edge;
|
||||
}
|
||||
if ((int)reverse_edge.data.distance != INVALID_EDGE_WEIGHT)
|
||||
if ((int)reverse_edge.data.weight != INVALID_EDGE_WEIGHT)
|
||||
{
|
||||
edges[edge++] = reverse_edge;
|
||||
}
|
||||
@ -530,7 +528,7 @@ class GraphContractor
|
||||
contractor_graph->GetEdgeData(current_edge_ID);
|
||||
if (current_data.shortcut && edge.data.forward == current_data.forward &&
|
||||
edge.data.backward == current_data.backward &&
|
||||
edge.data.distance < current_data.distance)
|
||||
edge.data.weight < current_data.weight)
|
||||
{
|
||||
// found a duplicate edge with smaller weight, update it.
|
||||
current_data = edge.data;
|
||||
@ -645,7 +643,7 @@ class GraphContractor
|
||||
}
|
||||
BOOST_ASSERT_MSG(SPECIAL_NODEID != new_edge.source, "Source id invalid");
|
||||
BOOST_ASSERT_MSG(SPECIAL_NODEID != new_edge.target, "Target id invalid");
|
||||
new_edge.data.distance = data.distance;
|
||||
new_edge.data.weight = data.weight;
|
||||
new_edge.data.shortcut = data.shortcut;
|
||||
if (!data.is_original_via_node_ID && !orig_node_id_from_new_node_id_map.empty())
|
||||
{
|
||||
@ -677,7 +675,7 @@ class GraphContractor
|
||||
private:
|
||||
inline void RelaxNode(const NodeID node,
|
||||
const NodeID forbidden_node,
|
||||
const int distance,
|
||||
const int weight,
|
||||
ContractorHeap &heap)
|
||||
{
|
||||
const short current_hop = heap.GetData(node).hop + 1;
|
||||
@ -693,23 +691,23 @@ class GraphContractor
|
||||
{
|
||||
continue;
|
||||
}
|
||||
const int to_distance = distance + data.distance;
|
||||
const int to_weight = weight + data.weight;
|
||||
|
||||
// New Node discovered -> Add to Heap + Node Info Storage
|
||||
if (!heap.WasInserted(to))
|
||||
{
|
||||
heap.Insert(to, to_distance, ContractorHeapData{current_hop, false});
|
||||
heap.Insert(to, to_weight, ContractorHeapData{current_hop, false});
|
||||
}
|
||||
// Found a shorter Path -> Update distance
|
||||
else if (to_distance < heap.GetKey(to))
|
||||
// Found a shorter Path -> Update weight
|
||||
else if (to_weight < heap.GetKey(to))
|
||||
{
|
||||
heap.DecreaseKey(to, to_distance);
|
||||
heap.DecreaseKey(to, to_weight);
|
||||
heap.GetData(to).hop = current_hop;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void Dijkstra(const int max_distance,
|
||||
inline void Dijkstra(const int max_weight,
|
||||
const unsigned number_of_targets,
|
||||
const int max_nodes,
|
||||
ContractorThreadData &data,
|
||||
@ -723,12 +721,12 @@ class GraphContractor
|
||||
while (!heap.Empty())
|
||||
{
|
||||
const NodeID node = heap.DeleteMin();
|
||||
const auto distance = heap.GetKey(node);
|
||||
const auto weight = heap.GetKey(node);
|
||||
if (++nodes > max_nodes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (distance > max_distance)
|
||||
if (weight > max_weight)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -743,7 +741,7 @@ class GraphContractor
|
||||
}
|
||||
}
|
||||
|
||||
RelaxNode(node, middle_node, distance, heap);
|
||||
RelaxNode(node, middle_node, weight, heap);
|
||||
}
|
||||
}
|
||||
|
||||
@ -806,7 +804,7 @@ class GraphContractor
|
||||
|
||||
heap.Clear();
|
||||
heap.Insert(source, 0, ContractorHeapData{});
|
||||
int max_distance = 0;
|
||||
int max_weight = 0;
|
||||
unsigned number_of_targets = 0;
|
||||
|
||||
for (auto out_edge : contractor_graph->GetAdjacentEdgeRange(node))
|
||||
@ -820,10 +818,10 @@ class GraphContractor
|
||||
if (node == target)
|
||||
continue;
|
||||
|
||||
const EdgeWeight path_distance = in_data.distance + out_data.distance;
|
||||
const EdgeWeight path_weight = in_data.weight + out_data.weight;
|
||||
if (target == source)
|
||||
{
|
||||
if (path_distance < node_weights[node])
|
||||
if (path_weight < node_weights[node])
|
||||
{
|
||||
if (RUNSIMULATION)
|
||||
{
|
||||
@ -832,7 +830,7 @@ class GraphContractor
|
||||
// CAREFUL: This only works due to the independent node-setting. This
|
||||
// guarantees that source is not connected to another node that is
|
||||
// contracted
|
||||
node_weights[source] = path_distance + 1;
|
||||
node_weights[source] = path_weight + 1;
|
||||
BOOST_ASSERT(stats != nullptr);
|
||||
stats->edges_added_count += 2;
|
||||
stats->original_edges_added_count +=
|
||||
@ -843,10 +841,10 @@ class GraphContractor
|
||||
// CAREFUL: This only works due to the independent node-setting. This
|
||||
// guarantees that source is not connected to another node that is
|
||||
// contracted
|
||||
node_weights[source] = path_distance; // make sure to prune better
|
||||
node_weights[source] = path_weight; // make sure to prune better
|
||||
inserted_edges.emplace_back(source,
|
||||
target,
|
||||
path_distance,
|
||||
path_weight,
|
||||
out_data.originalEdges +
|
||||
in_data.originalEdges,
|
||||
node,
|
||||
@ -856,7 +854,7 @@ class GraphContractor
|
||||
|
||||
inserted_edges.emplace_back(target,
|
||||
source,
|
||||
path_distance,
|
||||
path_weight,
|
||||
out_data.originalEdges +
|
||||
in_data.originalEdges,
|
||||
node,
|
||||
@ -867,7 +865,7 @@ class GraphContractor
|
||||
}
|
||||
continue;
|
||||
}
|
||||
max_distance = std::max(max_distance, path_distance);
|
||||
max_weight = std::max(max_weight, path_weight);
|
||||
if (!heap.WasInserted(target))
|
||||
{
|
||||
heap.Insert(target, INVALID_EDGE_WEIGHT, ContractorHeapData{0, true});
|
||||
@ -878,13 +876,12 @@ class GraphContractor
|
||||
if (RUNSIMULATION)
|
||||
{
|
||||
const int constexpr SIMULATION_SEARCH_SPACE_SIZE = 1000;
|
||||
Dijkstra(
|
||||
max_distance, number_of_targets, SIMULATION_SEARCH_SPACE_SIZE, *data, node);
|
||||
Dijkstra(max_weight, number_of_targets, SIMULATION_SEARCH_SPACE_SIZE, *data, node);
|
||||
}
|
||||
else
|
||||
{
|
||||
const int constexpr FULL_SEARCH_SPACE_SIZE = 2000;
|
||||
Dijkstra(max_distance, number_of_targets, FULL_SEARCH_SPACE_SIZE, *data, node);
|
||||
Dijkstra(max_weight, number_of_targets, FULL_SEARCH_SPACE_SIZE, *data, node);
|
||||
}
|
||||
for (auto out_edge : contractor_graph->GetAdjacentEdgeRange(node))
|
||||
{
|
||||
@ -896,9 +893,9 @@ class GraphContractor
|
||||
const NodeID target = contractor_graph->GetTarget(out_edge);
|
||||
if (target == node)
|
||||
continue;
|
||||
const int path_distance = in_data.distance + out_data.distance;
|
||||
const int distance = heap.GetKey(target);
|
||||
if (path_distance < distance)
|
||||
const int path_weight = in_data.weight + out_data.weight;
|
||||
const int weight = heap.GetKey(target);
|
||||
if (path_weight < weight)
|
||||
{
|
||||
if (RUNSIMULATION)
|
||||
{
|
||||
@ -911,7 +908,7 @@ class GraphContractor
|
||||
{
|
||||
inserted_edges.emplace_back(source,
|
||||
target,
|
||||
path_distance,
|
||||
path_weight,
|
||||
out_data.originalEdges + in_data.originalEdges,
|
||||
node,
|
||||
SHORTCUT_ARC,
|
||||
@ -920,7 +917,7 @@ class GraphContractor
|
||||
|
||||
inserted_edges.emplace_back(target,
|
||||
source,
|
||||
path_distance,
|
||||
path_weight,
|
||||
out_data.originalEdges + in_data.originalEdges,
|
||||
node,
|
||||
SHORTCUT_ARC,
|
||||
@ -948,7 +945,7 @@ class GraphContractor
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (inserted_edges[other].data.distance != inserted_edges[i].data.distance)
|
||||
if (inserted_edges[other].data.weight != inserted_edges[i].data.weight)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -16,11 +16,11 @@ struct QueryEdge
|
||||
NodeID target;
|
||||
struct EdgeData
|
||||
{
|
||||
EdgeData() : id(0), shortcut(false), distance(0), forward(false), backward(false) {}
|
||||
EdgeData() : id(0), shortcut(false), weight(0), forward(false), backward(false) {}
|
||||
|
||||
template <class OtherT> EdgeData(const OtherT &other)
|
||||
{
|
||||
distance = other.distance;
|
||||
weight = other.weight;
|
||||
shortcut = other.shortcut;
|
||||
id = other.id;
|
||||
forward = other.forward;
|
||||
@ -28,7 +28,7 @@ struct QueryEdge
|
||||
}
|
||||
NodeID id : 31;
|
||||
bool shortcut : 1;
|
||||
int distance : 30;
|
||||
int weight : 30;
|
||||
bool forward : 1;
|
||||
bool backward : 1;
|
||||
} data;
|
||||
@ -48,7 +48,7 @@ struct QueryEdge
|
||||
bool operator==(const QueryEdge &right) const
|
||||
{
|
||||
return (source == right.source && target == right.target &&
|
||||
data.distance == right.data.distance && data.shortcut == right.data.shortcut &&
|
||||
data.weight == right.data.weight && data.shortcut == right.data.shortcut &&
|
||||
data.forward == right.data.forward && data.backward == right.data.backward &&
|
||||
data.id == right.data.id);
|
||||
}
|
||||
|
@ -89,7 +89,6 @@ class InternalDataFacade final : public BaseDataFacade
|
||||
util::ShM<EdgeWeight, false>::vector m_geometry_fwd_weight_list;
|
||||
util::ShM<EdgeWeight, false>::vector m_geometry_rev_weight_list;
|
||||
util::ShM<bool, false>::vector m_is_core_node;
|
||||
util::ShM<unsigned, false>::vector m_segment_weights;
|
||||
util::ShM<uint8_t, false>::vector m_datasource_list;
|
||||
util::ShM<std::string, false>::vector m_datasource_names;
|
||||
util::ShM<std::uint32_t, false>::vector m_lane_description_offsets;
|
||||
|
@ -82,7 +82,7 @@ inline void UnpackCHPath(const DataFacadeT &facade,
|
||||
BOOST_ASSERT_MSG(smaller_edge_id != SPECIAL_EDGEID, "Invalid smaller edge ID");
|
||||
|
||||
const auto &data = facade.GetEdgeData(smaller_edge_id);
|
||||
BOOST_ASSERT_MSG(data.distance != std::numeric_limits<EdgeWeight>::max(),
|
||||
BOOST_ASSERT_MSG(data.weight != std::numeric_limits<EdgeWeight>::max(),
|
||||
"edge weight invalid");
|
||||
|
||||
// If the edge is a shortcut, we need to add the two halfs to the stack.
|
||||
|
@ -79,7 +79,7 @@ class AlternativeRouting final
|
||||
QueryHeap &forward_heap2 = *(engine_working_data.forward_heap_2);
|
||||
QueryHeap &reverse_heap2 = *(engine_working_data.reverse_heap_2);
|
||||
|
||||
int upper_bound_to_shortest_path_distance = INVALID_EDGE_WEIGHT;
|
||||
int upper_bound_to_shortest_path_weight = INVALID_EDGE_WEIGHT;
|
||||
NodeID middle_node = SPECIAL_NODEID;
|
||||
const EdgeWeight min_edge_offset =
|
||||
std::min(phantom_node_pair.source_phantom.forward_segment_id.enabled
|
||||
@ -132,7 +132,7 @@ class AlternativeRouting final
|
||||
forward_heap1,
|
||||
reverse_heap1,
|
||||
&middle_node,
|
||||
&upper_bound_to_shortest_path_distance,
|
||||
&upper_bound_to_shortest_path_weight,
|
||||
via_node_candidate_list,
|
||||
forward_search_space,
|
||||
min_edge_offset);
|
||||
@ -143,14 +143,14 @@ class AlternativeRouting final
|
||||
forward_heap1,
|
||||
reverse_heap1,
|
||||
&middle_node,
|
||||
&upper_bound_to_shortest_path_distance,
|
||||
&upper_bound_to_shortest_path_weight,
|
||||
via_node_candidate_list,
|
||||
reverse_search_space,
|
||||
min_edge_offset);
|
||||
}
|
||||
}
|
||||
|
||||
if (INVALID_EDGE_WEIGHT == upper_bound_to_shortest_path_distance)
|
||||
if (INVALID_EDGE_WEIGHT == upper_bound_to_shortest_path_weight)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -163,7 +163,7 @@ class AlternativeRouting final
|
||||
std::vector<NodeID> packed_reverse_path;
|
||||
|
||||
const bool path_is_a_loop =
|
||||
upper_bound_to_shortest_path_distance !=
|
||||
upper_bound_to_shortest_path_weight !=
|
||||
forward_heap1.GetKey(middle_node) + reverse_heap1.GetKey(middle_node);
|
||||
if (path_is_a_loop)
|
||||
{
|
||||
@ -257,14 +257,13 @@ class AlternativeRouting final
|
||||
const int approximated_sharing = fwd_sharing + rev_sharing;
|
||||
const int approximated_length = forward_heap1.GetKey(node) + reverse_heap1.GetKey(node);
|
||||
const bool length_passes =
|
||||
(approximated_length <
|
||||
upper_bound_to_shortest_path_distance * (1 + VIAPATH_EPSILON));
|
||||
(approximated_length < upper_bound_to_shortest_path_weight * (1 + VIAPATH_EPSILON));
|
||||
const bool sharing_passes =
|
||||
(approximated_sharing <= upper_bound_to_shortest_path_distance * VIAPATH_GAMMA);
|
||||
(approximated_sharing <= upper_bound_to_shortest_path_weight * VIAPATH_GAMMA);
|
||||
const bool stretch_passes =
|
||||
(approximated_length - approximated_sharing) <
|
||||
((1. + VIAPATH_ALPHA) *
|
||||
(upper_bound_to_shortest_path_distance - approximated_sharing));
|
||||
(upper_bound_to_shortest_path_weight - approximated_sharing));
|
||||
|
||||
if (length_passes && sharing_passes && stretch_passes)
|
||||
{
|
||||
@ -293,9 +292,9 @@ class AlternativeRouting final
|
||||
packed_shortest_path,
|
||||
min_edge_offset);
|
||||
const int maximum_allowed_sharing =
|
||||
static_cast<int>(upper_bound_to_shortest_path_distance * VIAPATH_GAMMA);
|
||||
static_cast<int>(upper_bound_to_shortest_path_weight * VIAPATH_GAMMA);
|
||||
if (sharing_of_via_path <= maximum_allowed_sharing &&
|
||||
length_of_via_path <= upper_bound_to_shortest_path_distance * (1 + VIAPATH_EPSILON))
|
||||
length_of_via_path <= upper_bound_to_shortest_path_weight * (1 + VIAPATH_EPSILON))
|
||||
{
|
||||
ranked_candidates_list.emplace_back(node, length_of_via_path, sharing_of_via_path);
|
||||
}
|
||||
@ -313,7 +312,7 @@ class AlternativeRouting final
|
||||
forward_heap2,
|
||||
reverse_heap2,
|
||||
candidate,
|
||||
upper_bound_to_shortest_path_distance,
|
||||
upper_bound_to_shortest_path_weight,
|
||||
&length_of_via_path,
|
||||
&s_v_middle,
|
||||
&v_t_middle,
|
||||
@ -326,7 +325,7 @@ class AlternativeRouting final
|
||||
}
|
||||
|
||||
// Unpack shortest path and alternative, if they exist
|
||||
if (INVALID_EDGE_WEIGHT != upper_bound_to_shortest_path_distance)
|
||||
if (INVALID_EDGE_WEIGHT != upper_bound_to_shortest_path_weight)
|
||||
{
|
||||
BOOST_ASSERT(!packed_shortest_path.empty());
|
||||
raw_route_data.unpacked_path_segments.resize(1);
|
||||
@ -345,7 +344,7 @@ class AlternativeRouting final
|
||||
phantom_node_pair,
|
||||
// -- unpacked output
|
||||
raw_route_data.unpacked_path_segments.front());
|
||||
raw_route_data.shortest_path_length = upper_bound_to_shortest_path_distance;
|
||||
raw_route_data.shortest_path_length = upper_bound_to_shortest_path_weight;
|
||||
}
|
||||
|
||||
if (SPECIAL_NODEID != selected_via_node)
|
||||
@ -488,7 +487,7 @@ class AlternativeRouting final
|
||||
{
|
||||
EdgeID edgeID = facade.FindEdgeInEitherDirection(packed_s_v_path[current_node],
|
||||
packed_s_v_path[current_node + 1]);
|
||||
*sharing_of_via_path += facade.GetEdgeData(edgeID).distance;
|
||||
*sharing_of_via_path += facade.GetEdgeData(edgeID).weight;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -521,7 +520,7 @@ class AlternativeRouting final
|
||||
EdgeID selected_edge =
|
||||
facade.FindEdgeInEitherDirection(partially_unpacked_via_path[current_node],
|
||||
partially_unpacked_via_path[current_node + 1]);
|
||||
*sharing_of_via_path += facade.GetEdgeData(selected_edge).distance;
|
||||
*sharing_of_via_path += facade.GetEdgeData(selected_edge).weight;
|
||||
}
|
||||
|
||||
// Second, partially unpack v-->t in reverse order until paths deviate and note lengths
|
||||
@ -536,7 +535,7 @@ class AlternativeRouting final
|
||||
{
|
||||
EdgeID edgeID = facade.FindEdgeInEitherDirection(
|
||||
packed_v_t_path[via_path_index - 1], packed_v_t_path[via_path_index]);
|
||||
*sharing_of_via_path += facade.GetEdgeData(edgeID).distance;
|
||||
*sharing_of_via_path += facade.GetEdgeData(edgeID).weight;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -568,7 +567,7 @@ class AlternativeRouting final
|
||||
EdgeID edgeID = facade.FindEdgeInEitherDirection(
|
||||
partially_unpacked_via_path[via_path_index - 1],
|
||||
partially_unpacked_via_path[via_path_index]);
|
||||
*sharing_of_via_path += facade.GetEdgeData(edgeID).distance;
|
||||
*sharing_of_via_path += facade.GetEdgeData(edgeID).weight;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -606,7 +605,7 @@ class AlternativeRouting final
|
||||
// packed_alternate_path[aindex] << "," << packed_alternate_path[aindex+1] << ")";
|
||||
// EdgeID edgeID = facade->FindEdgeInEitherDirection(packed_alternate_path[aindex],
|
||||
// packed_alternate_path[aindex+1]);
|
||||
// sharing += facade->GetEdgeData(edgeID).distance;
|
||||
// sharing += facade->GetEdgeData(edgeID).weight;
|
||||
// ++aindex;
|
||||
// }
|
||||
|
||||
@ -618,7 +617,7 @@ class AlternativeRouting final
|
||||
// packed_shortest_path[bindex-1]) ) {
|
||||
// EdgeID edgeID = facade->FindEdgeInEitherDirection(packed_alternate_path[aindex],
|
||||
// packed_alternate_path[aindex-1]);
|
||||
// sharing += facade->GetEdgeData(edgeID).distance;
|
||||
// sharing += facade->GetEdgeData(edgeID).weight;
|
||||
// --aindex; --bindex;
|
||||
// }
|
||||
// return sharing;
|
||||
@ -630,7 +629,7 @@ class AlternativeRouting final
|
||||
QueryHeap &heap1,
|
||||
QueryHeap &heap2,
|
||||
NodeID *middle_node,
|
||||
int *upper_bound_to_shortest_path_distance,
|
||||
int *upper_bound_to_shortest_path_weight,
|
||||
std::vector<NodeID> &search_space_intersection,
|
||||
std::vector<SearchSpaceEdge> &search_space,
|
||||
const EdgeWeight min_edge_offset) const
|
||||
@ -639,16 +638,16 @@ class AlternativeRouting final
|
||||
QueryHeap &reverse_heap = (is_forward_directed ? heap2 : heap1);
|
||||
|
||||
const NodeID node = forward_heap.DeleteMin();
|
||||
const int distance = forward_heap.GetKey(node);
|
||||
const int weight = forward_heap.GetKey(node);
|
||||
// const NodeID parentnode = forward_heap.GetData(node).parent;
|
||||
// util::SimpleLogger().Write() << (is_forward_directed ? "[fwd] " : "[rev] ") << "settled
|
||||
// edge ("
|
||||
// << parentnode << "," << node << "), dist: " << distance;
|
||||
// << parentnode << "," << node << "), dist: " << weight;
|
||||
|
||||
const int scaled_distance =
|
||||
static_cast<int>((distance + min_edge_offset) / (1. + VIAPATH_EPSILON));
|
||||
if ((INVALID_EDGE_WEIGHT != *upper_bound_to_shortest_path_distance) &&
|
||||
(scaled_distance > *upper_bound_to_shortest_path_distance))
|
||||
const int scaled_weight =
|
||||
static_cast<int>((weight + min_edge_offset) / (1. + VIAPATH_EPSILON));
|
||||
if ((INVALID_EDGE_WEIGHT != *upper_bound_to_shortest_path_weight) &&
|
||||
(scaled_weight > *upper_bound_to_shortest_path_weight))
|
||||
{
|
||||
forward_heap.DeleteAll();
|
||||
return;
|
||||
@ -659,31 +658,31 @@ class AlternativeRouting final
|
||||
if (reverse_heap.WasInserted(node))
|
||||
{
|
||||
search_space_intersection.emplace_back(node);
|
||||
const int new_distance = reverse_heap.GetKey(node) + distance;
|
||||
if (new_distance < *upper_bound_to_shortest_path_distance)
|
||||
const int new_weight = reverse_heap.GetKey(node) + weight;
|
||||
if (new_weight < *upper_bound_to_shortest_path_weight)
|
||||
{
|
||||
if (new_distance >= 0)
|
||||
if (new_weight >= 0)
|
||||
{
|
||||
*middle_node = node;
|
||||
*upper_bound_to_shortest_path_distance = new_distance;
|
||||
*upper_bound_to_shortest_path_weight = new_weight;
|
||||
// util::SimpleLogger().Write() << "accepted middle_node " << *middle_node
|
||||
// << " at
|
||||
// distance " << new_distance;
|
||||
// weight " << new_weight;
|
||||
// } else {
|
||||
// util::SimpleLogger().Write() << "discarded middle_node " << *middle_node
|
||||
// << "
|
||||
// at distance " << new_distance;
|
||||
// at weight " << new_weight;
|
||||
}
|
||||
else
|
||||
{
|
||||
// check whether there is a loop present at the node
|
||||
const auto loop_distance = super::GetLoopWeight(facade, node);
|
||||
const int new_distance_with_loop = new_distance + loop_distance;
|
||||
if (loop_distance != INVALID_EDGE_WEIGHT &&
|
||||
new_distance_with_loop <= *upper_bound_to_shortest_path_distance)
|
||||
const auto loop_weight = super::GetLoopWeight(facade, node);
|
||||
const int new_weight_with_loop = new_weight + loop_weight;
|
||||
if (loop_weight != INVALID_EDGE_WEIGHT &&
|
||||
new_weight_with_loop <= *upper_bound_to_shortest_path_weight)
|
||||
{
|
||||
*middle_node = node;
|
||||
*upper_bound_to_shortest_path_distance = loop_distance;
|
||||
*upper_bound_to_shortest_path_weight = loop_weight;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -696,25 +695,24 @@ class AlternativeRouting final
|
||||
(is_forward_directed ? data.forward : data.backward);
|
||||
if (edge_is_forward_directed)
|
||||
{
|
||||
|
||||
const NodeID to = facade.GetTarget(edge);
|
||||
const int edge_weight = data.distance;
|
||||
const int edge_weight = data.weight;
|
||||
|
||||
BOOST_ASSERT(edge_weight > 0);
|
||||
const int to_distance = distance + edge_weight;
|
||||
const int to_weight = weight + edge_weight;
|
||||
|
||||
// New Node discovered -> Add to Heap + Node Info Storage
|
||||
if (!forward_heap.WasInserted(to))
|
||||
{
|
||||
forward_heap.Insert(to, to_distance, node);
|
||||
forward_heap.Insert(to, to_weight, node);
|
||||
}
|
||||
// Found a shorter Path -> Update distance
|
||||
else if (to_distance < forward_heap.GetKey(to))
|
||||
// Found a shorter Path -> Update weight
|
||||
else if (to_weight < forward_heap.GetKey(to))
|
||||
{
|
||||
// new parent
|
||||
forward_heap.GetData(to).parent = node;
|
||||
// decreased distance
|
||||
forward_heap.DecreaseKey(to, to_distance);
|
||||
// decreased weight
|
||||
forward_heap.DecreaseKey(to, to_weight);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -806,7 +804,7 @@ class AlternativeRouting final
|
||||
return false;
|
||||
}
|
||||
const int T_threshold = static_cast<int>(VIAPATH_EPSILON * length_of_shortest_path);
|
||||
int unpacked_until_distance = 0;
|
||||
int unpacked_until_weight = 0;
|
||||
|
||||
std::stack<SearchSpaceEdge> unpack_stack;
|
||||
// Traverse path s-->v
|
||||
@ -814,14 +812,14 @@ class AlternativeRouting final
|
||||
{
|
||||
const EdgeID current_edge_id =
|
||||
facade.FindEdgeInEitherDirection(packed_s_v_path[i - 1], packed_s_v_path[i]);
|
||||
const int length_of_current_edge = facade.GetEdgeData(current_edge_id).distance;
|
||||
if ((length_of_current_edge + unpacked_until_distance) >= T_threshold)
|
||||
const int length_of_current_edge = facade.GetEdgeData(current_edge_id).weight;
|
||||
if ((length_of_current_edge + unpacked_until_weight) >= T_threshold)
|
||||
{
|
||||
unpack_stack.emplace(packed_s_v_path[i - 1], packed_s_v_path[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
unpacked_until_distance += length_of_current_edge;
|
||||
unpacked_until_weight += length_of_current_edge;
|
||||
s_P = packed_s_v_path[i - 1];
|
||||
}
|
||||
}
|
||||
@ -846,30 +844,30 @@ class AlternativeRouting final
|
||||
const EdgeID second_segment_edge_id =
|
||||
facade.FindEdgeInEitherDirection(via_path_middle_node_id, via_path_edge.second);
|
||||
const int second_segment_length =
|
||||
facade.GetEdgeData(second_segment_edge_id).distance;
|
||||
facade.GetEdgeData(second_segment_edge_id).weight;
|
||||
// attention: !unpacking in reverse!
|
||||
// Check if second segment is the one to go over treshold? if yes add second segment
|
||||
// to stack, else push first segment to stack and add distance of second one.
|
||||
if (unpacked_until_distance + second_segment_length >= T_threshold)
|
||||
// to stack, else push first segment to stack and add weight of second one.
|
||||
if (unpacked_until_weight + second_segment_length >= T_threshold)
|
||||
{
|
||||
unpack_stack.emplace(via_path_middle_node_id, via_path_edge.second);
|
||||
}
|
||||
else
|
||||
{
|
||||
unpacked_until_distance += second_segment_length;
|
||||
unpacked_until_weight += second_segment_length;
|
||||
unpack_stack.emplace(via_path_edge.first, via_path_middle_node_id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// edge is not a shortcut, set the start node for T-Test to end of edge.
|
||||
unpacked_until_distance += current_edge_data.distance;
|
||||
unpacked_until_weight += current_edge_data.weight;
|
||||
s_P = via_path_edge.first;
|
||||
}
|
||||
}
|
||||
|
||||
int t_test_path_length = unpacked_until_distance;
|
||||
unpacked_until_distance = 0;
|
||||
int t_test_path_length = unpacked_until_weight;
|
||||
unpacked_until_weight = 0;
|
||||
// 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);
|
||||
@ -878,14 +876,14 @@ class AlternativeRouting final
|
||||
{
|
||||
const EdgeID edgeID =
|
||||
facade.FindEdgeInEitherDirection(packed_v_t_path[i], packed_v_t_path[i + 1]);
|
||||
int length_of_current_edge = facade.GetEdgeData(edgeID).distance;
|
||||
if (length_of_current_edge + unpacked_until_distance >= T_threshold)
|
||||
int length_of_current_edge = facade.GetEdgeData(edgeID).weight;
|
||||
if (length_of_current_edge + unpacked_until_weight >= T_threshold)
|
||||
{
|
||||
unpack_stack.emplace(packed_v_t_path[i], packed_v_t_path[i + 1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
unpacked_until_distance += length_of_current_edge;
|
||||
unpacked_until_weight += length_of_current_edge;
|
||||
t_P = packed_v_t_path[i + 1];
|
||||
}
|
||||
}
|
||||
@ -908,29 +906,29 @@ class AlternativeRouting final
|
||||
const NodeID middleOfViaPath = current_edge_data.id;
|
||||
EdgeID edgeIDOfFirstSegment =
|
||||
facade.FindEdgeInEitherDirection(via_path_edge.first, middleOfViaPath);
|
||||
int lengthOfFirstSegment = facade.GetEdgeData(edgeIDOfFirstSegment).distance;
|
||||
int lengthOfFirstSegment = facade.GetEdgeData(edgeIDOfFirstSegment).weight;
|
||||
// Check if first segment is the one to go over treshold? if yes first segment to
|
||||
// stack, else push second segment to stack and add distance of first one.
|
||||
if (unpacked_until_distance + lengthOfFirstSegment >= T_threshold)
|
||||
// stack, else push second segment to stack and add weight of first one.
|
||||
if (unpacked_until_weight + lengthOfFirstSegment >= T_threshold)
|
||||
{
|
||||
unpack_stack.emplace(via_path_edge.first, middleOfViaPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
unpacked_until_distance += lengthOfFirstSegment;
|
||||
unpacked_until_weight += lengthOfFirstSegment;
|
||||
unpack_stack.emplace(middleOfViaPath, via_path_edge.second);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// edge is not a shortcut, set the start node for T-Test to end of edge.
|
||||
unpacked_until_distance += current_edge_data.distance;
|
||||
unpacked_until_weight += current_edge_data.weight;
|
||||
t_P = via_path_edge.second;
|
||||
}
|
||||
}
|
||||
|
||||
t_test_path_length += unpacked_until_distance;
|
||||
// Run actual T-Test query and compare if distances equal.
|
||||
t_test_path_length += unpacked_until_weight;
|
||||
// Run actual T-Test query and compare if weight equal.
|
||||
engine_working_data.InitializeOrClearThirdThreadLocalStorage(facade.GetNumberOfNodes());
|
||||
|
||||
QueryHeap &forward_heap3 = *engine_working_data.forward_heap_3;
|
||||
|
@ -43,7 +43,7 @@ class DirectShortestPathRouting final
|
||||
const std::vector<PhantomNodes> &phantom_nodes_vector,
|
||||
InternalRouteResult &raw_route_data) const
|
||||
{
|
||||
// Get distance to next pair of target nodes.
|
||||
// Get weight to next pair of target nodes.
|
||||
BOOST_ASSERT_MSG(1 == phantom_nodes_vector.size(),
|
||||
"Direct Shortest Path Query only accepts a single source and target pair. "
|
||||
"Multiple ones have been specified.");
|
||||
@ -87,7 +87,7 @@ class DirectShortestPathRouting final
|
||||
target_phantom.reverse_segment_id.id);
|
||||
}
|
||||
|
||||
int distance = INVALID_EDGE_WEIGHT;
|
||||
int weight = INVALID_EDGE_WEIGHT;
|
||||
std::vector<NodeID> packed_leg;
|
||||
|
||||
const bool constexpr DO_NOT_FORCE_LOOPS =
|
||||
@ -107,7 +107,7 @@ class DirectShortestPathRouting final
|
||||
reverse_heap,
|
||||
forward_core_heap,
|
||||
reverse_core_heap,
|
||||
distance,
|
||||
weight,
|
||||
packed_leg,
|
||||
DO_NOT_FORCE_LOOPS,
|
||||
DO_NOT_FORCE_LOOPS);
|
||||
@ -117,14 +117,14 @@ class DirectShortestPathRouting final
|
||||
super::Search(facade,
|
||||
forward_heap,
|
||||
reverse_heap,
|
||||
distance,
|
||||
weight,
|
||||
packed_leg,
|
||||
DO_NOT_FORCE_LOOPS,
|
||||
DO_NOT_FORCE_LOOPS);
|
||||
}
|
||||
|
||||
// No path found for both target nodes?
|
||||
if (INVALID_EDGE_WEIGHT == distance)
|
||||
if (INVALID_EDGE_WEIGHT == weight)
|
||||
{
|
||||
raw_route_data.shortest_path_length = INVALID_EDGE_WEIGHT;
|
||||
raw_route_data.alternative_path_length = INVALID_EDGE_WEIGHT;
|
||||
@ -133,7 +133,7 @@ class DirectShortestPathRouting final
|
||||
|
||||
BOOST_ASSERT_MSG(!packed_leg.empty(), "packed path empty");
|
||||
|
||||
raw_route_data.shortest_path_length = distance;
|
||||
raw_route_data.shortest_path_length = weight;
|
||||
raw_route_data.unpacked_path_segments.resize(1);
|
||||
raw_route_data.source_traversed_in_reverse.push_back(
|
||||
(packed_leg.front() != phantom_node_pair.source_phantom.forward_segment_id.id));
|
||||
|
@ -29,10 +29,10 @@ class ManyToManyRouting final
|
||||
|
||||
struct NodeBucket
|
||||
{
|
||||
unsigned target_id; // essentially a row in the distance matrix
|
||||
EdgeWeight distance;
|
||||
NodeBucket(const unsigned target_id, const EdgeWeight distance)
|
||||
: target_id(target_id), distance(distance)
|
||||
unsigned target_id; // essentially a row in the weight matrix
|
||||
EdgeWeight weight;
|
||||
NodeBucket(const unsigned target_id, const EdgeWeight weight)
|
||||
: target_id(target_id), weight(weight)
|
||||
{
|
||||
}
|
||||
};
|
||||
@ -68,7 +68,7 @@ class ManyToManyRouting final
|
||||
unsigned column_idx = 0;
|
||||
const auto search_target_phantom = [&](const PhantomNode &phantom) {
|
||||
query_heap.Clear();
|
||||
// insert target(s) at distance 0
|
||||
// insert target(s) at weight 0
|
||||
|
||||
if (phantom.forward_segment_id.enabled)
|
||||
{
|
||||
@ -95,7 +95,7 @@ class ManyToManyRouting final
|
||||
unsigned row_idx = 0;
|
||||
const auto search_source_phantom = [&](const PhantomNode &phantom) {
|
||||
query_heap.Clear();
|
||||
// insert target(s) at distance 0
|
||||
// insert target(s) at weight 0
|
||||
|
||||
if (phantom.forward_segment_id.enabled)
|
||||
{
|
||||
@ -166,7 +166,7 @@ class ManyToManyRouting final
|
||||
std::vector<EdgeWeight> &result_table) const
|
||||
{
|
||||
const NodeID node = query_heap.DeleteMin();
|
||||
const int source_distance = query_heap.GetKey(node);
|
||||
const int source_weight = query_heap.GetKey(node);
|
||||
|
||||
// check if each encountered node has an entry
|
||||
const auto bucket_iterator = search_space_with_buckets.find(node);
|
||||
@ -178,30 +178,30 @@ class ManyToManyRouting final
|
||||
{
|
||||
// get target id from bucket entry
|
||||
const unsigned column_idx = current_bucket.target_id;
|
||||
const int target_distance = current_bucket.distance;
|
||||
auto ¤t_distance = result_table[row_idx * number_of_targets + column_idx];
|
||||
// check if new distance is better
|
||||
const EdgeWeight new_distance = source_distance + target_distance;
|
||||
if (new_distance < 0)
|
||||
const int target_weight = current_bucket.weight;
|
||||
auto ¤t_weight = result_table[row_idx * number_of_targets + column_idx];
|
||||
// check if new weight is better
|
||||
const EdgeWeight new_weight = source_weight + target_weight;
|
||||
if (new_weight < 0)
|
||||
{
|
||||
const EdgeWeight loop_weight = super::GetLoopWeight(facade, node);
|
||||
const int new_distance_with_loop = new_distance + loop_weight;
|
||||
if (loop_weight != INVALID_EDGE_WEIGHT && new_distance_with_loop >= 0)
|
||||
const int new_weight_with_loop = new_weight + loop_weight;
|
||||
if (loop_weight != INVALID_EDGE_WEIGHT && new_weight_with_loop >= 0)
|
||||
{
|
||||
current_distance = std::min(current_distance, new_distance_with_loop);
|
||||
current_weight = std::min(current_weight, new_weight_with_loop);
|
||||
}
|
||||
}
|
||||
else if (new_distance < current_distance)
|
||||
else if (new_weight < current_weight)
|
||||
{
|
||||
result_table[row_idx * number_of_targets + column_idx] = new_distance;
|
||||
result_table[row_idx * number_of_targets + column_idx] = new_weight;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (StallAtNode<true>(facade, node, source_distance, query_heap))
|
||||
if (StallAtNode<true>(facade, node, source_weight, query_heap))
|
||||
{
|
||||
return;
|
||||
}
|
||||
RelaxOutgoingEdges<true>(facade, node, source_distance, query_heap);
|
||||
RelaxOutgoingEdges<true>(facade, node, source_weight, query_heap);
|
||||
}
|
||||
|
||||
void BackwardRoutingStep(const DataFacadeT &facade,
|
||||
@ -210,23 +210,23 @@ class ManyToManyRouting final
|
||||
SearchSpaceWithBuckets &search_space_with_buckets) const
|
||||
{
|
||||
const NodeID node = query_heap.DeleteMin();
|
||||
const int target_distance = query_heap.GetKey(node);
|
||||
const int target_weight = query_heap.GetKey(node);
|
||||
|
||||
// store settled nodes in search space bucket
|
||||
search_space_with_buckets[node].emplace_back(column_idx, target_distance);
|
||||
search_space_with_buckets[node].emplace_back(column_idx, target_weight);
|
||||
|
||||
if (StallAtNode<false>(facade, node, target_distance, query_heap))
|
||||
if (StallAtNode<false>(facade, node, target_weight, query_heap))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RelaxOutgoingEdges<false>(facade, node, target_distance, query_heap);
|
||||
RelaxOutgoingEdges<false>(facade, node, target_weight, query_heap);
|
||||
}
|
||||
|
||||
template <bool forward_direction>
|
||||
inline void RelaxOutgoingEdges(const DataFacadeT &facade,
|
||||
const NodeID node,
|
||||
const EdgeWeight distance,
|
||||
const EdgeWeight weight,
|
||||
QueryHeap &query_heap) const
|
||||
{
|
||||
for (auto edge : facade.GetAdjacentEdgeRange(node))
|
||||
@ -236,22 +236,22 @@ class ManyToManyRouting final
|
||||
if (direction_flag)
|
||||
{
|
||||
const NodeID to = facade.GetTarget(edge);
|
||||
const int edge_weight = data.distance;
|
||||
const int edge_weight = data.weight;
|
||||
|
||||
BOOST_ASSERT_MSG(edge_weight > 0, "edge_weight invalid");
|
||||
const int to_distance = distance + edge_weight;
|
||||
const int to_weight = weight + edge_weight;
|
||||
|
||||
// New Node discovered -> Add to Heap + Node Info Storage
|
||||
if (!query_heap.WasInserted(to))
|
||||
{
|
||||
query_heap.Insert(to, to_distance, node);
|
||||
query_heap.Insert(to, to_weight, node);
|
||||
}
|
||||
// Found a shorter Path -> Update distance
|
||||
else if (to_distance < query_heap.GetKey(to))
|
||||
// Found a shorter Path -> Update weight
|
||||
else if (to_weight < query_heap.GetKey(to))
|
||||
{
|
||||
// new parent
|
||||
query_heap.GetData(to).parent = node;
|
||||
query_heap.DecreaseKey(to, to_distance);
|
||||
query_heap.DecreaseKey(to, to_weight);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -261,7 +261,7 @@ class ManyToManyRouting final
|
||||
template <bool forward_direction>
|
||||
inline bool StallAtNode(const DataFacadeT &facade,
|
||||
const NodeID node,
|
||||
const EdgeWeight distance,
|
||||
const EdgeWeight weight,
|
||||
QueryHeap &query_heap) const
|
||||
{
|
||||
for (auto edge : facade.GetAdjacentEdgeRange(node))
|
||||
@ -271,11 +271,11 @@ class ManyToManyRouting final
|
||||
if (reverse_flag)
|
||||
{
|
||||
const NodeID to = facade.GetTarget(edge);
|
||||
const int edge_weight = data.distance;
|
||||
const int edge_weight = data.weight;
|
||||
BOOST_ASSERT_MSG(edge_weight > 0, "edge_weight invalid");
|
||||
if (query_heap.WasInserted(to))
|
||||
{
|
||||
if (query_heap.GetKey(to) + edge_weight < distance)
|
||||
if (query_heap.GetKey(to) + edge_weight < weight)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -76,19 +76,19 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
const bool force_loop_reverse) const
|
||||
{
|
||||
const NodeID node = forward_heap.DeleteMin();
|
||||
const std::int32_t distance = forward_heap.GetKey(node);
|
||||
const std::int32_t weight = forward_heap.GetKey(node);
|
||||
|
||||
if (reverse_heap.WasInserted(node))
|
||||
{
|
||||
const std::int32_t new_distance = reverse_heap.GetKey(node) + distance;
|
||||
if (new_distance < upper_bound)
|
||||
const std::int32_t new_weight = reverse_heap.GetKey(node) + weight;
|
||||
if (new_weight < upper_bound)
|
||||
{
|
||||
// if loops are forced, they are so at the source
|
||||
if ((force_loop_forward && forward_heap.GetData(node).parent == node) ||
|
||||
(force_loop_reverse && reverse_heap.GetData(node).parent == node) ||
|
||||
// in this case we are looking at a bi-directional way where the source
|
||||
// and target phantom are on the same edge based node
|
||||
new_distance < 0)
|
||||
new_weight < 0)
|
||||
{
|
||||
// check whether there is a loop present at the node
|
||||
for (const auto edge : facade.GetAdjacentEdgeRange(node))
|
||||
@ -101,12 +101,12 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
const NodeID to = facade.GetTarget(edge);
|
||||
if (to == node)
|
||||
{
|
||||
const EdgeWeight edge_weight = data.distance;
|
||||
const std::int32_t loop_distance = new_distance + edge_weight;
|
||||
if (loop_distance >= 0 && loop_distance < upper_bound)
|
||||
const EdgeWeight edge_weight = data.weight;
|
||||
const std::int32_t loop_weight = new_weight + edge_weight;
|
||||
if (loop_weight >= 0 && loop_weight < upper_bound)
|
||||
{
|
||||
middle_node_id = node;
|
||||
upper_bound = loop_distance;
|
||||
upper_bound = loop_weight;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -114,18 +114,18 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_ASSERT(new_distance >= 0);
|
||||
BOOST_ASSERT(new_weight >= 0);
|
||||
|
||||
middle_node_id = node;
|
||||
upper_bound = new_distance;
|
||||
upper_bound = new_weight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// make sure we don't terminate too early if we initialize the distance
|
||||
// make sure we don't terminate too early if we initialize the weight
|
||||
// for the nodes in the forward heap with the forward/reverse offset
|
||||
BOOST_ASSERT(min_edge_offset <= 0);
|
||||
if (distance + min_edge_offset > upper_bound)
|
||||
if (weight + min_edge_offset > upper_bound)
|
||||
{
|
||||
forward_heap.DeleteAll();
|
||||
return;
|
||||
@ -141,13 +141,13 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
if (reverse_flag)
|
||||
{
|
||||
const NodeID to = facade.GetTarget(edge);
|
||||
const EdgeWeight edge_weight = data.distance;
|
||||
const EdgeWeight edge_weight = data.weight;
|
||||
|
||||
BOOST_ASSERT_MSG(edge_weight > 0, "edge_weight invalid");
|
||||
|
||||
if (forward_heap.WasInserted(to))
|
||||
{
|
||||
if (forward_heap.GetKey(to) + edge_weight < distance)
|
||||
if (forward_heap.GetKey(to) + edge_weight < weight)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -162,24 +162,23 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
bool forward_directionFlag = (forward_direction ? data.forward : data.backward);
|
||||
if (forward_directionFlag)
|
||||
{
|
||||
|
||||
const NodeID to = facade.GetTarget(edge);
|
||||
const EdgeWeight edge_weight = data.distance;
|
||||
const EdgeWeight edge_weight = data.weight;
|
||||
|
||||
BOOST_ASSERT_MSG(edge_weight > 0, "edge_weight invalid");
|
||||
const int to_distance = distance + edge_weight;
|
||||
const int to_weight = weight + edge_weight;
|
||||
|
||||
// New Node discovered -> Add to Heap + Node Info Storage
|
||||
if (!forward_heap.WasInserted(to))
|
||||
{
|
||||
forward_heap.Insert(to, to_distance, node);
|
||||
forward_heap.Insert(to, to_weight, node);
|
||||
}
|
||||
// Found a shorter Path -> Update distance
|
||||
else if (to_distance < forward_heap.GetKey(to))
|
||||
// Found a shorter Path -> Update weight
|
||||
else if (to_weight < forward_heap.GetKey(to))
|
||||
{
|
||||
// new parent
|
||||
forward_heap.GetData(to).parent = node;
|
||||
forward_heap.DecreaseKey(to, to_distance);
|
||||
forward_heap.DecreaseKey(to, to_weight);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -196,7 +195,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
const NodeID to = facade.GetTarget(edge);
|
||||
if (to == node)
|
||||
{
|
||||
loop_weight = std::min(loop_weight, data.distance);
|
||||
loop_weight = std::min(loop_weight, data.weight);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -300,7 +299,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
|
||||
unpacked_path.back().entry_classid = facade.GetEntryClassID(edge_data.id);
|
||||
unpacked_path.back().turn_instruction = turn_instruction;
|
||||
unpacked_path.back().duration_until_turn += (edge_data.distance - total_weight);
|
||||
unpacked_path.back().duration_until_turn += (edge_data.weight - total_weight);
|
||||
unpacked_path.back().pre_turn_bearing = facade.PreTurnBearing(edge_data.id);
|
||||
unpacked_path.back().post_turn_bearing = facade.PostTurnBearing(edge_data.id);
|
||||
});
|
||||
@ -400,7 +399,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
|
||||
// there is no equivalent to a node-based node in an edge-expanded graph.
|
||||
// two equivalent routes may start (or end) at different node-based edges
|
||||
// as they are added with the offset how much "distance" on the edge
|
||||
// as they are added with the offset how much "weight" on the edge
|
||||
// has already been traversed. Depending on offset one needs to remove
|
||||
// the last node.
|
||||
if (unpacked_path.size() > 1)
|
||||
@ -483,14 +482,14 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
void Search(const DataFacadeT &facade,
|
||||
SearchEngineData::QueryHeap &forward_heap,
|
||||
SearchEngineData::QueryHeap &reverse_heap,
|
||||
std::int32_t &distance,
|
||||
std::int32_t &weight,
|
||||
std::vector<NodeID> &packed_leg,
|
||||
const bool force_loop_forward,
|
||||
const bool force_loop_reverse,
|
||||
const int duration_upper_bound = INVALID_EDGE_WEIGHT) const
|
||||
{
|
||||
NodeID middle = SPECIAL_NODEID;
|
||||
distance = duration_upper_bound;
|
||||
weight = duration_upper_bound;
|
||||
|
||||
// get offset to account for offsets on phantom nodes on compressed edges
|
||||
const auto min_edge_offset = std::min(0, forward_heap.MinKey());
|
||||
@ -508,7 +507,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
forward_heap,
|
||||
reverse_heap,
|
||||
middle,
|
||||
distance,
|
||||
weight,
|
||||
min_edge_offset,
|
||||
true,
|
||||
STALLING_ENABLED,
|
||||
@ -521,7 +520,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
reverse_heap,
|
||||
forward_heap,
|
||||
middle,
|
||||
distance,
|
||||
weight,
|
||||
min_edge_offset,
|
||||
false,
|
||||
STALLING_ENABLED,
|
||||
@ -531,18 +530,18 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
}
|
||||
|
||||
// No path found for both target nodes?
|
||||
if (duration_upper_bound <= distance || SPECIAL_NODEID == middle)
|
||||
if (duration_upper_bound <= weight || SPECIAL_NODEID == middle)
|
||||
{
|
||||
distance = INVALID_EDGE_WEIGHT;
|
||||
weight = INVALID_EDGE_WEIGHT;
|
||||
return;
|
||||
}
|
||||
|
||||
// Was a paths over one of the forward/reverse nodes not found?
|
||||
BOOST_ASSERT_MSG((SPECIAL_NODEID != middle && INVALID_EDGE_WEIGHT != distance),
|
||||
BOOST_ASSERT_MSG((SPECIAL_NODEID != middle && INVALID_EDGE_WEIGHT != weight),
|
||||
"no path found");
|
||||
|
||||
// make sure to correctly unpack loops
|
||||
if (distance != forward_heap.GetKey(middle) + reverse_heap.GetKey(middle))
|
||||
if (weight != forward_heap.GetKey(middle) + reverse_heap.GetKey(middle))
|
||||
{
|
||||
// self loop makes up the full path
|
||||
packed_leg.push_back(middle);
|
||||
@ -568,14 +567,14 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
SearchEngineData::QueryHeap &reverse_heap,
|
||||
SearchEngineData::QueryHeap &forward_core_heap,
|
||||
SearchEngineData::QueryHeap &reverse_core_heap,
|
||||
int &distance,
|
||||
int &weight,
|
||||
std::vector<NodeID> &packed_leg,
|
||||
const bool force_loop_forward,
|
||||
const bool force_loop_reverse,
|
||||
int duration_upper_bound = INVALID_EDGE_WEIGHT) const
|
||||
{
|
||||
NodeID middle = SPECIAL_NODEID;
|
||||
distance = duration_upper_bound;
|
||||
weight = duration_upper_bound;
|
||||
|
||||
using CoreEntryPoint = std::tuple<NodeID, EdgeWeight, NodeID>;
|
||||
std::vector<CoreEntryPoint> forward_entry_points;
|
||||
@ -604,7 +603,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
forward_heap,
|
||||
reverse_heap,
|
||||
middle,
|
||||
distance,
|
||||
weight,
|
||||
min_edge_offset,
|
||||
true,
|
||||
STALLING_ENABLED,
|
||||
@ -626,7 +625,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
reverse_heap,
|
||||
forward_heap,
|
||||
middle,
|
||||
distance,
|
||||
weight,
|
||||
min_edge_offset,
|
||||
false,
|
||||
STALLING_ENABLED,
|
||||
@ -673,13 +672,13 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
// run two-target Dijkstra routing step on core with termination criterion
|
||||
const constexpr bool STALLING_DISABLED = false;
|
||||
while (0 < forward_core_heap.Size() && 0 < reverse_core_heap.Size() &&
|
||||
distance > (forward_core_heap.MinKey() + reverse_core_heap.MinKey()))
|
||||
weight > (forward_core_heap.MinKey() + reverse_core_heap.MinKey()))
|
||||
{
|
||||
RoutingStep(facade,
|
||||
forward_core_heap,
|
||||
reverse_core_heap,
|
||||
middle,
|
||||
distance,
|
||||
weight,
|
||||
min_core_edge_offset,
|
||||
true,
|
||||
STALLING_DISABLED,
|
||||
@ -690,7 +689,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
reverse_core_heap,
|
||||
forward_core_heap,
|
||||
middle,
|
||||
distance,
|
||||
weight,
|
||||
min_core_edge_offset,
|
||||
false,
|
||||
STALLING_DISABLED,
|
||||
@ -699,20 +698,20 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
}
|
||||
|
||||
// No path found for both target nodes?
|
||||
if (duration_upper_bound <= distance || SPECIAL_NODEID == middle)
|
||||
if (duration_upper_bound <= weight || SPECIAL_NODEID == middle)
|
||||
{
|
||||
distance = INVALID_EDGE_WEIGHT;
|
||||
weight = INVALID_EDGE_WEIGHT;
|
||||
return;
|
||||
}
|
||||
|
||||
// Was a paths over one of the forward/reverse nodes not found?
|
||||
BOOST_ASSERT_MSG((SPECIAL_NODEID != middle && INVALID_EDGE_WEIGHT != distance),
|
||||
BOOST_ASSERT_MSG((SPECIAL_NODEID != middle && INVALID_EDGE_WEIGHT != weight),
|
||||
"no path found");
|
||||
|
||||
// we need to unpack sub path from core heaps
|
||||
if (facade.IsCoreNode(middle))
|
||||
{
|
||||
if (distance != forward_core_heap.GetKey(middle) + reverse_core_heap.GetKey(middle))
|
||||
if (weight != forward_core_heap.GetKey(middle) + reverse_core_heap.GetKey(middle))
|
||||
{
|
||||
// self loop
|
||||
BOOST_ASSERT(forward_core_heap.GetData(middle).parent == middle &&
|
||||
@ -734,7 +733,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
}
|
||||
else
|
||||
{
|
||||
if (distance != forward_heap.GetKey(middle) + reverse_heap.GetKey(middle))
|
||||
if (weight != forward_heap.GetKey(middle) + reverse_heap.GetKey(middle))
|
||||
{
|
||||
// self loop
|
||||
BOOST_ASSERT(forward_heap.GetData(middle).parent == middle &&
|
||||
|
@ -48,9 +48,9 @@ class ShortestPathRouting final
|
||||
const bool search_to_reverse_node,
|
||||
const PhantomNode &source_phantom,
|
||||
const PhantomNode &target_phantom,
|
||||
const int total_distance_to_forward,
|
||||
const int total_distance_to_reverse,
|
||||
int &new_total_distance,
|
||||
const int total_weight_to_forward,
|
||||
const int total_weight_to_reverse,
|
||||
int &new_total_weight,
|
||||
std::vector<NodeID> &leg_packed_path) const
|
||||
{
|
||||
forward_heap.Clear();
|
||||
@ -102,7 +102,7 @@ class ShortestPathRouting final
|
||||
reverse_heap,
|
||||
forward_core_heap,
|
||||
reverse_core_heap,
|
||||
new_total_distance,
|
||||
new_total_weight,
|
||||
leg_packed_path,
|
||||
needs_loop_forwad,
|
||||
needs_loop_backwards);
|
||||
@ -112,7 +112,7 @@ class ShortestPathRouting final
|
||||
super::Search(facade,
|
||||
forward_heap,
|
||||
reverse_heap,
|
||||
new_total_distance,
|
||||
new_total_weight,
|
||||
leg_packed_path,
|
||||
needs_loop_forwad,
|
||||
needs_loop_backwards);
|
||||
@ -120,8 +120,8 @@ class ShortestPathRouting final
|
||||
// if no route is found between two parts of the via-route, the entire route becomes
|
||||
// invalid. Adding to invalid edge weight sadly doesn't return an invalid edge weight. Here
|
||||
// we prevent the possible overflow, faking the addition of infinity + x == infinity
|
||||
if (new_total_distance != INVALID_EDGE_WEIGHT)
|
||||
new_total_distance += std::min(total_distance_to_forward, total_distance_to_reverse);
|
||||
if (new_total_weight != INVALID_EDGE_WEIGHT)
|
||||
new_total_weight += std::min(total_weight_to_forward, total_weight_to_reverse);
|
||||
}
|
||||
|
||||
// searches shortest path between:
|
||||
@ -138,10 +138,10 @@ class ShortestPathRouting final
|
||||
const bool search_to_reverse_node,
|
||||
const PhantomNode &source_phantom,
|
||||
const PhantomNode &target_phantom,
|
||||
const int total_distance_to_forward,
|
||||
const int total_distance_to_reverse,
|
||||
int &new_total_distance_to_forward,
|
||||
int &new_total_distance_to_reverse,
|
||||
const int total_weight_to_forward,
|
||||
const int total_weight_to_reverse,
|
||||
int &new_total_weight_to_forward,
|
||||
int &new_total_weight_to_reverse,
|
||||
std::vector<NodeID> &leg_packed_path_forward,
|
||||
std::vector<NodeID> &leg_packed_path_reverse) const
|
||||
{
|
||||
@ -156,14 +156,14 @@ class ShortestPathRouting final
|
||||
if (search_from_forward_node)
|
||||
{
|
||||
forward_heap.Insert(source_phantom.forward_segment_id.id,
|
||||
total_distance_to_forward -
|
||||
total_weight_to_forward -
|
||||
source_phantom.GetForwardWeightPlusOffset(),
|
||||
source_phantom.forward_segment_id.id);
|
||||
}
|
||||
if (search_from_reverse_node)
|
||||
{
|
||||
forward_heap.Insert(source_phantom.reverse_segment_id.id,
|
||||
total_distance_to_reverse -
|
||||
total_weight_to_reverse -
|
||||
source_phantom.GetReverseWeightPlusOffset(),
|
||||
source_phantom.reverse_segment_id.id);
|
||||
}
|
||||
@ -181,7 +181,7 @@ class ShortestPathRouting final
|
||||
reverse_heap,
|
||||
forward_core_heap,
|
||||
reverse_core_heap,
|
||||
new_total_distance_to_forward,
|
||||
new_total_weight_to_forward,
|
||||
leg_packed_path_forward,
|
||||
super::NeedsLoopForward(source_phantom, target_phantom),
|
||||
DO_NOT_FORCE_LOOP);
|
||||
@ -191,7 +191,7 @@ class ShortestPathRouting final
|
||||
super::Search(facade,
|
||||
forward_heap,
|
||||
reverse_heap,
|
||||
new_total_distance_to_forward,
|
||||
new_total_weight_to_forward,
|
||||
leg_packed_path_forward,
|
||||
super::NeedsLoopForward(source_phantom, target_phantom),
|
||||
DO_NOT_FORCE_LOOP);
|
||||
@ -208,14 +208,14 @@ class ShortestPathRouting final
|
||||
if (search_from_forward_node)
|
||||
{
|
||||
forward_heap.Insert(source_phantom.forward_segment_id.id,
|
||||
total_distance_to_forward -
|
||||
total_weight_to_forward -
|
||||
source_phantom.GetForwardWeightPlusOffset(),
|
||||
source_phantom.forward_segment_id.id);
|
||||
}
|
||||
if (search_from_reverse_node)
|
||||
{
|
||||
forward_heap.Insert(source_phantom.reverse_segment_id.id,
|
||||
total_distance_to_reverse -
|
||||
total_weight_to_reverse -
|
||||
source_phantom.GetReverseWeightPlusOffset(),
|
||||
source_phantom.reverse_segment_id.id);
|
||||
}
|
||||
@ -232,7 +232,7 @@ class ShortestPathRouting final
|
||||
reverse_heap,
|
||||
forward_core_heap,
|
||||
reverse_core_heap,
|
||||
new_total_distance_to_reverse,
|
||||
new_total_weight_to_reverse,
|
||||
leg_packed_path_reverse,
|
||||
DO_NOT_FORCE_LOOP,
|
||||
super::NeedsLoopBackwards(source_phantom, target_phantom));
|
||||
@ -242,7 +242,7 @@ class ShortestPathRouting final
|
||||
super::Search(facade,
|
||||
forward_heap,
|
||||
reverse_heap,
|
||||
new_total_distance_to_reverse,
|
||||
new_total_weight_to_reverse,
|
||||
leg_packed_path_reverse,
|
||||
DO_NOT_FORCE_LOOP,
|
||||
super::NeedsLoopBackwards(source_phantom, target_phantom));
|
||||
@ -298,8 +298,8 @@ class ShortestPathRouting final
|
||||
QueryHeap &forward_core_heap = *(engine_working_data.forward_heap_2);
|
||||
QueryHeap &reverse_core_heap = *(engine_working_data.reverse_heap_2);
|
||||
|
||||
int total_distance_to_forward = 0;
|
||||
int total_distance_to_reverse = 0;
|
||||
int total_weight_to_forward = 0;
|
||||
int total_weight_to_reverse = 0;
|
||||
bool search_from_forward_node =
|
||||
phantom_nodes_vector.front().source_phantom.forward_segment_id.enabled;
|
||||
bool search_from_reverse_node =
|
||||
@ -318,8 +318,8 @@ class ShortestPathRouting final
|
||||
// a list of vias
|
||||
for (const auto &phantom_node_pair : phantom_nodes_vector)
|
||||
{
|
||||
int new_total_distance_to_forward = INVALID_EDGE_WEIGHT;
|
||||
int new_total_distance_to_reverse = INVALID_EDGE_WEIGHT;
|
||||
int new_total_weight_to_forward = INVALID_EDGE_WEIGHT;
|
||||
int new_total_weight_to_reverse = INVALID_EDGE_WEIGHT;
|
||||
|
||||
std::vector<NodeID> packed_leg_to_forward;
|
||||
std::vector<NodeID> packed_leg_to_reverse;
|
||||
@ -350,22 +350,22 @@ class ShortestPathRouting final
|
||||
search_to_reverse_node,
|
||||
source_phantom,
|
||||
target_phantom,
|
||||
total_distance_to_forward,
|
||||
total_distance_to_reverse,
|
||||
new_total_distance_to_forward,
|
||||
total_weight_to_forward,
|
||||
total_weight_to_reverse,
|
||||
new_total_weight_to_forward,
|
||||
packed_leg_to_forward);
|
||||
// if only the reverse node is valid (e.g. when using the match plugin) we
|
||||
// actually need to move
|
||||
if (!target_phantom.forward_segment_id.enabled)
|
||||
{
|
||||
BOOST_ASSERT(target_phantom.reverse_segment_id.enabled);
|
||||
new_total_distance_to_reverse = new_total_distance_to_forward;
|
||||
new_total_weight_to_reverse = new_total_weight_to_forward;
|
||||
packed_leg_to_reverse = std::move(packed_leg_to_forward);
|
||||
new_total_distance_to_forward = INVALID_EDGE_WEIGHT;
|
||||
new_total_weight_to_forward = INVALID_EDGE_WEIGHT;
|
||||
}
|
||||
else if (target_phantom.reverse_segment_id.enabled)
|
||||
{
|
||||
new_total_distance_to_reverse = new_total_distance_to_forward;
|
||||
new_total_weight_to_reverse = new_total_weight_to_forward;
|
||||
packed_leg_to_reverse = packed_leg_to_forward;
|
||||
}
|
||||
}
|
||||
@ -382,18 +382,18 @@ class ShortestPathRouting final
|
||||
search_to_reverse_node,
|
||||
source_phantom,
|
||||
target_phantom,
|
||||
total_distance_to_forward,
|
||||
total_distance_to_reverse,
|
||||
new_total_distance_to_forward,
|
||||
new_total_distance_to_reverse,
|
||||
total_weight_to_forward,
|
||||
total_weight_to_reverse,
|
||||
new_total_weight_to_forward,
|
||||
new_total_weight_to_reverse,
|
||||
packed_leg_to_forward,
|
||||
packed_leg_to_reverse);
|
||||
}
|
||||
}
|
||||
|
||||
// No path found for both target nodes?
|
||||
if ((INVALID_EDGE_WEIGHT == new_total_distance_to_forward) &&
|
||||
(INVALID_EDGE_WEIGHT == new_total_distance_to_reverse))
|
||||
if ((INVALID_EDGE_WEIGHT == new_total_weight_to_forward) &&
|
||||
(INVALID_EDGE_WEIGHT == new_total_weight_to_reverse))
|
||||
{
|
||||
raw_route_data.shortest_path_length = INVALID_EDGE_WEIGHT;
|
||||
raw_route_data.alternative_path_length = INVALID_EDGE_WEIGHT;
|
||||
@ -404,16 +404,16 @@ class ShortestPathRouting final
|
||||
if (current_leg > 0)
|
||||
{
|
||||
bool forward_to_forward =
|
||||
(new_total_distance_to_forward != INVALID_EDGE_WEIGHT) &&
|
||||
(new_total_weight_to_forward != INVALID_EDGE_WEIGHT) &&
|
||||
packed_leg_to_forward.front() == source_phantom.forward_segment_id.id;
|
||||
bool reverse_to_forward =
|
||||
(new_total_distance_to_forward != INVALID_EDGE_WEIGHT) &&
|
||||
(new_total_weight_to_forward != INVALID_EDGE_WEIGHT) &&
|
||||
packed_leg_to_forward.front() == source_phantom.reverse_segment_id.id;
|
||||
bool forward_to_reverse =
|
||||
(new_total_distance_to_reverse != INVALID_EDGE_WEIGHT) &&
|
||||
(new_total_weight_to_reverse != INVALID_EDGE_WEIGHT) &&
|
||||
packed_leg_to_reverse.front() == source_phantom.forward_segment_id.id;
|
||||
bool reverse_to_reverse =
|
||||
(new_total_distance_to_reverse != INVALID_EDGE_WEIGHT) &&
|
||||
(new_total_weight_to_reverse != INVALID_EDGE_WEIGHT) &&
|
||||
packed_leg_to_reverse.front() == source_phantom.reverse_segment_id.id;
|
||||
|
||||
BOOST_ASSERT(!forward_to_forward || !reverse_to_forward);
|
||||
@ -447,7 +447,7 @@ class ShortestPathRouting final
|
||||
}
|
||||
}
|
||||
|
||||
if (new_total_distance_to_forward != INVALID_EDGE_WEIGHT)
|
||||
if (new_total_weight_to_forward != INVALID_EDGE_WEIGHT)
|
||||
{
|
||||
BOOST_ASSERT(target_phantom.forward_segment_id.enabled);
|
||||
|
||||
@ -464,7 +464,7 @@ class ShortestPathRouting final
|
||||
search_from_forward_node = false;
|
||||
}
|
||||
|
||||
if (new_total_distance_to_reverse != INVALID_EDGE_WEIGHT)
|
||||
if (new_total_weight_to_reverse != INVALID_EDGE_WEIGHT)
|
||||
{
|
||||
BOOST_ASSERT(target_phantom.reverse_segment_id.enabled);
|
||||
|
||||
@ -484,17 +484,17 @@ class ShortestPathRouting final
|
||||
prev_packed_leg_to_forward = std::move(packed_leg_to_forward);
|
||||
prev_packed_leg_to_reverse = std::move(packed_leg_to_reverse);
|
||||
|
||||
total_distance_to_forward = new_total_distance_to_forward;
|
||||
total_distance_to_reverse = new_total_distance_to_reverse;
|
||||
total_weight_to_forward = new_total_weight_to_forward;
|
||||
total_weight_to_reverse = new_total_weight_to_reverse;
|
||||
|
||||
++current_leg;
|
||||
}
|
||||
|
||||
BOOST_ASSERT(total_distance_to_forward != INVALID_EDGE_WEIGHT ||
|
||||
total_distance_to_reverse != INVALID_EDGE_WEIGHT);
|
||||
BOOST_ASSERT(total_weight_to_forward != INVALID_EDGE_WEIGHT ||
|
||||
total_weight_to_reverse != INVALID_EDGE_WEIGHT);
|
||||
|
||||
// We make sure the fastest route is always in packed_legs_to_forward
|
||||
if (total_distance_to_forward > total_distance_to_reverse)
|
||||
if (total_weight_to_forward > total_weight_to_reverse)
|
||||
{
|
||||
// insert sentinel
|
||||
packed_leg_to_reverse_begin.push_back(total_packed_path_to_reverse.size());
|
||||
@ -504,7 +504,7 @@ class ShortestPathRouting final
|
||||
phantom_nodes_vector,
|
||||
total_packed_path_to_reverse,
|
||||
packed_leg_to_reverse_begin,
|
||||
total_distance_to_reverse,
|
||||
total_weight_to_reverse,
|
||||
raw_route_data);
|
||||
}
|
||||
else
|
||||
@ -517,7 +517,7 @@ class ShortestPathRouting final
|
||||
phantom_nodes_vector,
|
||||
total_packed_path_to_forward,
|
||||
packed_leg_to_forward_begin,
|
||||
total_distance_to_forward,
|
||||
total_weight_to_forward,
|
||||
raw_route_data);
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ struct SegmentBlock
|
||||
{
|
||||
OSMNodeID this_osm_node_id;
|
||||
double segment_length;
|
||||
std::int32_t segment_weight;
|
||||
EdgeWeight segment_weight;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
static_assert(sizeof(SegmentBlock) == 20, "SegmentBlock is not packed correctly");
|
||||
|
@ -149,7 +149,7 @@ template <typename EdgeDataT, bool UseSharedMemory = false> class StaticGraph
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the edge with the smallest `.distance` going from `from` to `to`
|
||||
* Finds the edge with the smallest `.weight` going from `from` to `to`
|
||||
* @param from the source node ID
|
||||
* @param to the target node ID
|
||||
* @param filter a functor that returns a `bool` that determines whether an edge should be
|
||||
@ -169,11 +169,11 @@ template <typename EdgeDataT, bool UseSharedMemory = false> class StaticGraph
|
||||
{
|
||||
const NodeID target = GetTarget(edge);
|
||||
const auto &data = GetEdgeData(edge);
|
||||
if (target == to && data.distance < smallest_weight &&
|
||||
if (target == to && data.weight < smallest_weight &&
|
||||
std::forward<FilterFunction>(filter)(data))
|
||||
{
|
||||
smallest_edge = edge;
|
||||
smallest_weight = data.distance;
|
||||
smallest_weight = data.weight;
|
||||
}
|
||||
}
|
||||
return smallest_edge;
|
||||
|
@ -780,7 +780,7 @@ EdgeID Contractor::LoadEdgeExpandedGraph(
|
||||
edge_segment_byte_ptr += sizeof(extractor::lookup::SegmentHeaderBlock);
|
||||
|
||||
auto previous_osm_node_id = header->previous_osm_node_id;
|
||||
int new_weight = 0;
|
||||
EdgeWeight new_weight = 0;
|
||||
int compressed_edge_nodes = static_cast<int>(header->num_osm_nodes);
|
||||
|
||||
auto segmentblocks =
|
||||
@ -996,12 +996,12 @@ Contractor::WriteContractedGraph(unsigned max_node_id,
|
||||
// every target needs to be valid
|
||||
BOOST_ASSERT(current_edge.target <= max_used_node_id);
|
||||
#ifndef NDEBUG
|
||||
if (current_edge.data.distance <= 0)
|
||||
if (current_edge.data.weight <= 0)
|
||||
{
|
||||
util::SimpleLogger().Write(logWARNING)
|
||||
<< "Edge: " << edge << ",source: " << contracted_edge_list[edge].source
|
||||
<< ", target: " << contracted_edge_list[edge].target
|
||||
<< ", dist: " << current_edge.data.distance;
|
||||
<< ", weight: " << current_edge.data.weight;
|
||||
|
||||
util::SimpleLogger().Write(logWARNING) << "Failed at adjacency list of node "
|
||||
<< contracted_edge_list[edge].source << "/"
|
||||
|
@ -540,13 +540,13 @@ Status TilePlugin::HandleRequest(const std::shared_ptr<datafacade::BaseDataFacad
|
||||
const auto sum_node_weight = std::accumulate(
|
||||
forward_weight_vector.begin(), forward_weight_vector.end(), EdgeWeight{0});
|
||||
|
||||
// The edge.distance is the whole edge weight, which includes the turn cost.
|
||||
// The turn cost is the edge.distance minus the sum of the individual road
|
||||
// The edge.weight is the whole edge weight, which includes the turn cost.
|
||||
// The turn cost is the edge.weight minus the sum of the individual road
|
||||
// segment weights. This might not be 100% accurate, because some
|
||||
// intersections include stop signs, traffic signals and other penalties,
|
||||
// but at this stage, we can't divide those out, so we just treat the whole
|
||||
// lot as the "turn cost" that we'll stick on the map.
|
||||
const auto turn_cost = data.distance - sum_node_weight;
|
||||
const auto turn_cost = data.weight - sum_node_weight;
|
||||
|
||||
// Find the three nodes that make up the turn movement)
|
||||
const auto node_from = first_geometry.size() > 1
|
||||
|
Loading…
Reference in New Issue
Block a user