Review and rebase updates
This commit is contained in:
parent
105709cb43
commit
cacb162520
@ -46,6 +46,10 @@ class MultiLevelGraph : public partitioner::MultiLevelGraph<EdgeDataT, Ownership
|
|||||||
template <typename T> using Vector = util::ViewOrVector<T, Ownership>;
|
template <typename T> using Vector = util::ViewOrVector<T, Ownership>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
using NodeArrayEntry = typename SuperT::NodeArrayEntry;
|
||||||
|
using EdgeArrayEntry = typename SuperT::EdgeArrayEntry;
|
||||||
|
using EdgeOffset = typename SuperT::EdgeOffset;
|
||||||
|
|
||||||
MultiLevelGraph() = default;
|
MultiLevelGraph() = default;
|
||||||
MultiLevelGraph(MultiLevelGraph &&) = default;
|
MultiLevelGraph(MultiLevelGraph &&) = default;
|
||||||
MultiLevelGraph(const MultiLevelGraph &) = default;
|
MultiLevelGraph(const MultiLevelGraph &) = default;
|
||||||
@ -74,9 +78,9 @@ class MultiLevelGraph : public partitioner::MultiLevelGraph<EdgeDataT, Ownership
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiLevelGraph(Vector<typename SuperT::NodeArrayEntry> node_array_,
|
MultiLevelGraph(Vector<NodeArrayEntry> node_array_,
|
||||||
Vector<typename SuperT::EdgeArrayEntry> edge_array_,
|
Vector<EdgeArrayEntry> edge_array_,
|
||||||
Vector<typename SuperT::EdgeOffset> node_to_edge_offset_,
|
Vector<EdgeOffset> node_to_edge_offset_,
|
||||||
Vector<EdgeWeight> node_weights_,
|
Vector<EdgeWeight> node_weights_,
|
||||||
Vector<EdgeDuration> node_durations_,
|
Vector<EdgeDuration> node_durations_,
|
||||||
Vector<bool> is_forward_edge_,
|
Vector<bool> is_forward_edge_,
|
||||||
|
@ -149,7 +149,7 @@ class MultiLevelGraph : public util::StaticGraph<EdgeDataT, Ownership>
|
|||||||
return max_border_node_id;
|
return max_border_node_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto data() &&
|
auto data() && // rvalue ref-qualifier is a safety-belt
|
||||||
{
|
{
|
||||||
return std::make_tuple(std::move(SuperT::node_array),
|
return std::make_tuple(std::move(SuperT::node_array),
|
||||||
std::move(SuperT::edge_array),
|
std::move(SuperT::edge_array),
|
||||||
|
@ -470,10 +470,10 @@ RandIt filterUnpackedPathsBySharing(RandIt first,
|
|||||||
if (shortest_path.edges.empty())
|
if (shortest_path.edges.empty())
|
||||||
return last;
|
return last;
|
||||||
|
|
||||||
std::unordered_set<EdgeID> edges;
|
std::unordered_set<NodeID> nodes;
|
||||||
edges.reserve(size * shortest_path.edges.size() * (1.25));
|
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) {
|
const auto over_sharing_limit = [&](auto &unpacked) {
|
||||||
if (unpacked.edges.empty())
|
if (unpacked.edges.empty())
|
||||||
@ -482,20 +482,20 @@ RandIt filterUnpackedPathsBySharing(RandIt first,
|
|||||||
}
|
}
|
||||||
|
|
||||||
EdgeWeight total_duration = 0;
|
EdgeWeight total_duration = 0;
|
||||||
const auto add_if_seen = [&](const EdgeWeight duration, const EdgeID edge) {
|
const auto add_if_seen = [&](const EdgeWeight duration, const NodeID node) {
|
||||||
auto edge_duration = facade.GetEdgeData(edge).duration;
|
auto node_duration = facade.GetNodeDuration(node);
|
||||||
total_duration += edge_duration;
|
total_duration += node_duration;
|
||||||
if (edges.count(edge) > 0)
|
if (nodes.count(node) > 0)
|
||||||
{
|
{
|
||||||
return duration + edge_duration;
|
return duration + node_duration;
|
||||||
}
|
}
|
||||||
return duration;
|
return duration;
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto shared_weight =
|
const auto shared_duration = std::accumulate(
|
||||||
std::accumulate(begin(unpacked.edges), end(unpacked.edges), EdgeWeight{0}, add_if_seen);
|
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 >= 0.);
|
||||||
BOOST_ASSERT(unpacked.sharing <= 1.);
|
BOOST_ASSERT(unpacked.sharing <= 1.);
|
||||||
|
|
||||||
@ -505,7 +505,7 @@ RandIt filterUnpackedPathsBySharing(RandIt first,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
edges.insert(begin(unpacked.edges), end(unpacked.edges));
|
nodes.insert(begin(unpacked.nodes), end(unpacked.nodes));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -182,16 +182,15 @@ void relaxOutgoingEdges(const DataFacade<mld::Algorithm> &facade,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const auto turn_id = data.turn_id;
|
const auto turn_id = data.turn_id;
|
||||||
const auto node_weight =
|
const auto node_id = DIRECTION == FORWARD_DIRECTION ? node : facade.GetTarget(edge);
|
||||||
facade.GetNodeWeight(DIRECTION == FORWARD_DIRECTION ? node : to);
|
const auto node_weight = facade.GetNodeWeight(node_id);
|
||||||
const auto node_duration = facade.GetNodeDuration(
|
const auto node_duration = facade.GetNodeDuration(node_id);
|
||||||
DIRECTION == FORWARD_DIRECTION ? node : to); // TODO: remove later
|
const auto turn_weight = node_weight + facade.GetWeightPenaltyForEdgeID(turn_id);
|
||||||
const auto edge_weight = node_weight + facade.GetWeightPenaltyForEdgeID(turn_id);
|
const auto turn_duration = node_duration + facade.GetDurationPenaltyForEdgeID(turn_id);
|
||||||
const auto edge_duration = node_duration + facade.GetDurationPenaltyForEdgeID(turn_id);
|
|
||||||
|
|
||||||
BOOST_ASSERT_MSG(edge_weight > 0, "edge_weight invalid");
|
BOOST_ASSERT_MSG(node_weight + turn_weight > 0, "edge weight is invalid");
|
||||||
const auto to_weight = weight + edge_weight;
|
const auto to_weight = weight + turn_weight;
|
||||||
const auto to_duration = duration + edge_duration;
|
const auto to_duration = duration + turn_duration;
|
||||||
|
|
||||||
// New Node discovered -> Add to Heap + Node Info Storage
|
// New Node discovered -> Add to Heap + Node Info Storage
|
||||||
if (!query_heap.WasInserted(to))
|
if (!query_heap.WasInserted(to))
|
||||||
@ -315,15 +314,10 @@ oneToManySearch(SearchEngineData<Algorithm> &engine_working_data,
|
|||||||
: facade.IsBackwardEdge(edge))
|
: facade.IsBackwardEdge(edge))
|
||||||
{
|
{
|
||||||
const auto turn_id = data.turn_id;
|
const auto turn_id = data.turn_id;
|
||||||
const auto edge_weight =
|
const auto node_id = DIRECTION == FORWARD_DIRECTION ? node : facade.GetTarget(edge);
|
||||||
initial_weight +
|
const auto edge_weight = initial_weight + facade.GetNodeWeight(node_id) +
|
||||||
facade.GetNodeWeight(DIRECTION == FORWARD_DIRECTION ? node
|
facade.GetWeightPenaltyForEdgeID(turn_id);
|
||||||
: facade.GetTarget(edge)) +
|
const auto edge_duration = initial_duration + facade.GetNodeDuration(node_id) +
|
||||||
facade.GetWeightPenaltyForEdgeID(turn_id);
|
|
||||||
const auto edge_duration = initial_duration +
|
|
||||||
+facade.GetNodeDuration(DIRECTION == FORWARD_DIRECTION
|
|
||||||
? node
|
|
||||||
: facade.GetTarget(edge)) +
|
|
||||||
facade.GetDurationPenaltyForEdgeID(turn_id);
|
facade.GetDurationPenaltyForEdgeID(turn_id);
|
||||||
|
|
||||||
query_heap.Insert(facade.GetTarget(edge), edge_weight, {node, edge_duration});
|
query_heap.Insert(facade.GetTarget(edge), edge_weight, {node, edge_duration});
|
||||||
|
@ -145,9 +145,13 @@ NBGToEBG EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const N
|
|||||||
BOOST_ASSERT(nbe_to_ebn_mapping[edge_id_1] != SPECIAL_NODEID ||
|
BOOST_ASSERT(nbe_to_ebn_mapping[edge_id_1] != SPECIAL_NODEID ||
|
||||||
nbe_to_ebn_mapping[edge_id_2] != SPECIAL_NODEID);
|
nbe_to_ebn_mapping[edge_id_2] != SPECIAL_NODEID);
|
||||||
|
|
||||||
// TODO: use the sign bit to distinguish oneway streets that must
|
// ⚠ Use the sign bit of node weights to distinguish oneway streets:
|
||||||
// have INVALID_EDGE_WEIGHT node weight values to enforce loop edges
|
// * MSB is set - a node corresponds to a one-way street
|
||||||
// in contraction
|
// * MSB is clear - a node corresponds to a bidirectional street
|
||||||
|
// Before using node weights data values must be adjusted:
|
||||||
|
// * in contraction if MSB is set the node weight is INVALID_EDGE_WEIGHT.
|
||||||
|
// This adjustment is needed to enforce loop creation for oneways.
|
||||||
|
// * in other cases node weights must be masked with 0x7fffffff to clear MSB
|
||||||
if (nbe_to_ebn_mapping[edge_id_1] != SPECIAL_NODEID &&
|
if (nbe_to_ebn_mapping[edge_id_1] != SPECIAL_NODEID &&
|
||||||
nbe_to_ebn_mapping[edge_id_2] == SPECIAL_NODEID)
|
nbe_to_ebn_mapping[edge_id_2] == SPECIAL_NODEID)
|
||||||
m_edge_based_node_weights[nbe_to_ebn_mapping[edge_id_1]] |= 0x80000000;
|
m_edge_based_node_weights[nbe_to_ebn_mapping[edge_id_1]] |= 0x80000000;
|
||||||
|
Loading…
Reference in New Issue
Block a user