Review and rebase updates
This commit is contained in:
committed by
Patrick Niklaus
parent
105709cb43
commit
cacb162520
@@ -470,10 +470,10 @@ RandIt filterUnpackedPathsBySharing(RandIt first,
|
||||
if (shortest_path.edges.empty())
|
||||
return last;
|
||||
|
||||
std::unordered_set<EdgeID> edges;
|
||||
edges.reserve(size * shortest_path.edges.size() * (1.25));
|
||||
std::unordered_set<NodeID> nodes;
|
||||
nodes.reserve(size * shortest_path.nodes.size() * (1.25));
|
||||
|
||||
edges.insert(begin(shortest_path.edges), end(shortest_path.edges));
|
||||
nodes.insert(begin(shortest_path.nodes), end(shortest_path.nodes));
|
||||
|
||||
const auto over_sharing_limit = [&](auto &unpacked) {
|
||||
if (unpacked.edges.empty())
|
||||
@@ -482,20 +482,20 @@ RandIt filterUnpackedPathsBySharing(RandIt first,
|
||||
}
|
||||
|
||||
EdgeWeight total_duration = 0;
|
||||
const auto add_if_seen = [&](const EdgeWeight duration, const EdgeID edge) {
|
||||
auto edge_duration = facade.GetEdgeData(edge).duration;
|
||||
total_duration += edge_duration;
|
||||
if (edges.count(edge) > 0)
|
||||
const auto add_if_seen = [&](const EdgeWeight duration, const NodeID node) {
|
||||
auto node_duration = facade.GetNodeDuration(node);
|
||||
total_duration += node_duration;
|
||||
if (nodes.count(node) > 0)
|
||||
{
|
||||
return duration + edge_duration;
|
||||
return duration + node_duration;
|
||||
}
|
||||
return duration;
|
||||
};
|
||||
|
||||
const auto shared_weight =
|
||||
std::accumulate(begin(unpacked.edges), end(unpacked.edges), EdgeWeight{0}, add_if_seen);
|
||||
const auto shared_duration = std::accumulate(
|
||||
begin(unpacked.nodes), end(unpacked.nodes), EdgeDuration{0}, add_if_seen);
|
||||
|
||||
unpacked.sharing = shared_weight / static_cast<double>(total_duration);
|
||||
unpacked.sharing = shared_duration / static_cast<double>(total_duration);
|
||||
BOOST_ASSERT(unpacked.sharing >= 0.);
|
||||
BOOST_ASSERT(unpacked.sharing <= 1.);
|
||||
|
||||
@@ -505,7 +505,7 @@ RandIt filterUnpackedPathsBySharing(RandIt first,
|
||||
}
|
||||
else
|
||||
{
|
||||
edges.insert(begin(unpacked.edges), end(unpacked.edges));
|
||||
nodes.insert(begin(unpacked.nodes), end(unpacked.nodes));
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -182,16 +182,15 @@ void relaxOutgoingEdges(const DataFacade<mld::Algorithm> &facade,
|
||||
}
|
||||
|
||||
const auto turn_id = data.turn_id;
|
||||
const auto node_weight =
|
||||
facade.GetNodeWeight(DIRECTION == FORWARD_DIRECTION ? node : to);
|
||||
const auto node_duration = facade.GetNodeDuration(
|
||||
DIRECTION == FORWARD_DIRECTION ? node : to); // TODO: remove later
|
||||
const auto edge_weight = node_weight + facade.GetWeightPenaltyForEdgeID(turn_id);
|
||||
const auto edge_duration = node_duration + facade.GetDurationPenaltyForEdgeID(turn_id);
|
||||
const auto node_id = DIRECTION == FORWARD_DIRECTION ? node : facade.GetTarget(edge);
|
||||
const auto node_weight = facade.GetNodeWeight(node_id);
|
||||
const auto node_duration = facade.GetNodeDuration(node_id);
|
||||
const auto turn_weight = node_weight + facade.GetWeightPenaltyForEdgeID(turn_id);
|
||||
const auto turn_duration = node_duration + facade.GetDurationPenaltyForEdgeID(turn_id);
|
||||
|
||||
BOOST_ASSERT_MSG(edge_weight > 0, "edge_weight invalid");
|
||||
const auto to_weight = weight + edge_weight;
|
||||
const auto to_duration = duration + edge_duration;
|
||||
BOOST_ASSERT_MSG(node_weight + turn_weight > 0, "edge weight is invalid");
|
||||
const auto to_weight = weight + turn_weight;
|
||||
const auto to_duration = duration + turn_duration;
|
||||
|
||||
// New Node discovered -> Add to Heap + Node Info Storage
|
||||
if (!query_heap.WasInserted(to))
|
||||
@@ -315,15 +314,10 @@ oneToManySearch(SearchEngineData<Algorithm> &engine_working_data,
|
||||
: facade.IsBackwardEdge(edge))
|
||||
{
|
||||
const auto turn_id = data.turn_id;
|
||||
const auto edge_weight =
|
||||
initial_weight +
|
||||
facade.GetNodeWeight(DIRECTION == FORWARD_DIRECTION ? node
|
||||
: facade.GetTarget(edge)) +
|
||||
facade.GetWeightPenaltyForEdgeID(turn_id);
|
||||
const auto edge_duration = initial_duration +
|
||||
+facade.GetNodeDuration(DIRECTION == FORWARD_DIRECTION
|
||||
? node
|
||||
: facade.GetTarget(edge)) +
|
||||
const auto node_id = DIRECTION == FORWARD_DIRECTION ? node : facade.GetTarget(edge);
|
||||
const auto edge_weight = initial_weight + facade.GetNodeWeight(node_id) +
|
||||
facade.GetWeightPenaltyForEdgeID(turn_id);
|
||||
const auto edge_duration = initial_duration + facade.GetNodeDuration(node_id) +
|
||||
facade.GetDurationPenaltyForEdgeID(turn_id);
|
||||
|
||||
query_heap.Insert(facade.GetTarget(edge), edge_weight, {node, edge_duration});
|
||||
|
||||
Reference in New Issue
Block a user