Add EBG node durations
This commit is contained in:
committed by
Patrick Niklaus
parent
db18e8669f
commit
fd9bebbfa7
@@ -75,13 +75,14 @@ void printUnreachableStatistics(const Partition &partition,
|
||||
auto LoadAndUpdateEdgeExpandedGraph(const CustomizationConfig &config,
|
||||
const partitioner::MultiLevelPartition &mlp,
|
||||
std::vector<EdgeWeight> &node_weights,
|
||||
std::vector<EdgeDuration> &node_durations,
|
||||
std::uint32_t &connectivity_checksum)
|
||||
{
|
||||
updater::Updater updater(config.updater_config);
|
||||
|
||||
std::vector<extractor::EdgeBasedEdge> edge_based_edge_list;
|
||||
EdgeID num_nodes = updater.LoadAndUpdateEdgeExpandedGraph(
|
||||
edge_based_edge_list, node_weights, connectivity_checksum);
|
||||
edge_based_edge_list, node_weights, node_durations, connectivity_checksum);
|
||||
|
||||
auto directed = partitioner::splitBidirectionalEdges(edge_based_edge_list);
|
||||
|
||||
@@ -123,8 +124,10 @@ int Customizer::Run(const CustomizationConfig &config)
|
||||
partitioner::files::readPartition(config.GetPath(".osrm.partition"), mlp);
|
||||
|
||||
std::vector<EdgeWeight> node_weights;
|
||||
std::vector<EdgeDuration> node_durations; // TODO: to be removed later
|
||||
std::uint32_t connectivity_checksum = 0;
|
||||
auto graph = LoadAndUpdateEdgeExpandedGraph(config, mlp, node_weights, connectivity_checksum);
|
||||
auto graph = LoadAndUpdateEdgeExpandedGraph(
|
||||
config, mlp, node_weights, node_durations, connectivity_checksum);
|
||||
BOOST_ASSERT(graph.GetNumberOfNodes() == node_weights.size());
|
||||
std::for_each(node_weights.begin(), node_weights.end(), [](auto &w) { w &= 0x7fffffff; });
|
||||
util::Log() << "Loaded edge based graph: " << graph.GetNumberOfEdges() << " edges, "
|
||||
@@ -163,7 +166,6 @@ int Customizer::Run(const CustomizationConfig &config)
|
||||
util::Log() << "MLD customization writing took " << TIMER_SEC(writing_mld_data) << " seconds";
|
||||
|
||||
TIMER_START(writing_graph);
|
||||
std::vector<EdgeDuration> node_durations; // TODO: save an empty vector, to be removed later
|
||||
MultiLevelEdgeBasedGraph shaved_graph{
|
||||
std::move(graph), std::move(node_weights), std::move(node_durations)};
|
||||
customizer::files::writeGraph(
|
||||
|
||||
@@ -169,8 +169,6 @@ void relaxOutgoingEdges(const DataFacade<mld::Algorithm> &facade,
|
||||
}
|
||||
}
|
||||
|
||||
const auto node_weight = facade.GetNodeWeight(node);
|
||||
const auto node_duration = facade.GetNodeDuration(node); // TODO: remove later
|
||||
for (const auto edge : facade.GetBorderEdgeRange(level, node))
|
||||
{
|
||||
const auto &data = facade.GetEdgeData(edge);
|
||||
@@ -183,6 +181,10 @@ 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);
|
||||
|
||||
@@ -299,7 +301,6 @@ oneToManySearch(SearchEngineData<Algorithm> &engine_working_data,
|
||||
}
|
||||
};
|
||||
|
||||
// Check a single path result and insert adjacent nodes into heap
|
||||
auto insert_node = [&](NodeID node, EdgeWeight initial_weight, EdgeDuration initial_duration) {
|
||||
|
||||
// Update single node paths
|
||||
@@ -311,9 +312,19 @@ oneToManySearch(SearchEngineData<Algorithm> &engine_working_data,
|
||||
const auto &data = facade.GetEdgeData(edge);
|
||||
if (DIRECTION == FORWARD_DIRECTION ? data.forward : data.backward)
|
||||
{
|
||||
query_heap.Insert(facade.GetTarget(edge),
|
||||
data.weight + initial_weight,
|
||||
{node, data.duration + initial_duration});
|
||||
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)) +
|
||||
facade.GetDurationPenaltyForEdgeID(turn_id);
|
||||
|
||||
query_heap.Insert(facade.GetTarget(edge), edge_weight, {node, edge_duration});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -107,6 +107,13 @@ void EdgeBasedGraphFactory::GetEdgeBasedNodeWeights(std::vector<EdgeWeight> &out
|
||||
swap(m_edge_based_node_weights, output_node_weights);
|
||||
}
|
||||
|
||||
void EdgeBasedGraphFactory::GetEdgeBasedNodeDurations(
|
||||
std::vector<EdgeWeight> &output_node_durations)
|
||||
{
|
||||
using std::swap; // Koenig swap
|
||||
swap(m_edge_based_node_durations, output_node_durations);
|
||||
}
|
||||
|
||||
std::uint32_t EdgeBasedGraphFactory::GetConnectivityChecksum() const
|
||||
{
|
||||
return m_connectivity_checksum;
|
||||
@@ -281,6 +288,7 @@ unsigned EdgeBasedGraphFactory::LabelEdgeBasedNodes()
|
||||
// heuristic: node-based graph node is a simple intersection with four edges
|
||||
// (edge-based nodes)
|
||||
m_edge_based_node_weights.reserve(4 * m_node_based_graph.GetNumberOfNodes());
|
||||
m_edge_based_node_durations.reserve(4 * m_node_based_graph.GetNumberOfNodes());
|
||||
nbe_to_ebn_mapping.resize(m_node_based_graph.GetEdgeCapacity(), SPECIAL_NODEID);
|
||||
|
||||
// renumber edge based node of outgoing edges
|
||||
@@ -297,6 +305,7 @@ unsigned EdgeBasedGraphFactory::LabelEdgeBasedNodes()
|
||||
}
|
||||
|
||||
m_edge_based_node_weights.push_back(edge_data.weight);
|
||||
m_edge_based_node_durations.push_back(edge_data.duration);
|
||||
|
||||
BOOST_ASSERT(numbered_edges_count < m_node_based_graph.GetNumberOfEdges());
|
||||
nbe_to_ebn_mapping[current_edge] = numbered_edges_count;
|
||||
@@ -392,6 +401,8 @@ EdgeBasedGraphFactory::GenerateEdgeExpandedNodes(const WayRestrictionMap &way_re
|
||||
const auto ebn_weight = m_edge_based_node_weights[nbe_to_ebn_mapping[eid]];
|
||||
BOOST_ASSERT(ebn_weight == INVALID_EDGE_WEIGHT || ebn_weight == edge_data.weight);
|
||||
m_edge_based_node_weights.push_back(ebn_weight);
|
||||
m_edge_based_node_durations.push_back(
|
||||
m_edge_based_node_durations[nbe_to_ebn_mapping[eid]]);
|
||||
|
||||
edge_based_node_id++;
|
||||
progress.PrintStatus(progress_counter++);
|
||||
@@ -400,6 +411,7 @@ EdgeBasedGraphFactory::GenerateEdgeExpandedNodes(const WayRestrictionMap &way_re
|
||||
|
||||
BOOST_ASSERT(m_edge_based_node_segments.size() == m_edge_based_node_is_startpoint.size());
|
||||
BOOST_ASSERT(m_number_of_edge_based_nodes == m_edge_based_node_weights.size());
|
||||
BOOST_ASSERT(m_number_of_edge_based_nodes == m_edge_based_node_durations.size());
|
||||
|
||||
util::Log() << "Generated " << m_number_of_edge_based_nodes << " nodes ("
|
||||
<< way_restriction_map.NumberOfDuplicatedNodes()
|
||||
|
||||
@@ -241,6 +241,7 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
|
||||
util::DeallocatingVector<EdgeBasedEdge> edge_based_edge_list;
|
||||
std::vector<bool> node_is_startpoint;
|
||||
std::vector<EdgeWeight> edge_based_node_weights;
|
||||
std::vector<EdgeDuration> edge_based_node_durations;
|
||||
std::uint32_t ebg_connectivity_checksum = 0;
|
||||
|
||||
// Create a node-based graph from the OSRM file
|
||||
@@ -320,6 +321,7 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
|
||||
edge_based_node_segments,
|
||||
node_is_startpoint,
|
||||
edge_based_node_weights,
|
||||
edge_based_node_durations,
|
||||
edge_based_edge_list,
|
||||
ebg_connectivity_checksum);
|
||||
|
||||
@@ -343,8 +345,8 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
|
||||
|
||||
util::Log() << "Saving edge-based node weights to file.";
|
||||
TIMER_START(timer_write_node_weights);
|
||||
extractor::files::writeEdgeBasedNodeWeights(config.GetPath(".osrm.enw"),
|
||||
edge_based_node_weights);
|
||||
extractor::files::writeEdgeBasedNodeWeightsDurations(
|
||||
config.GetPath(".osrm.enw"), edge_based_node_weights, edge_based_node_durations);
|
||||
TIMER_STOP(timer_write_node_weights);
|
||||
util::Log() << "Done writing. (" << TIMER_SEC(timer_write_node_weights) << ")";
|
||||
|
||||
@@ -733,6 +735,7 @@ EdgeID Extractor::BuildEdgeExpandedGraph(
|
||||
std::vector<EdgeBasedNodeSegment> &edge_based_node_segments,
|
||||
std::vector<bool> &node_is_startpoint,
|
||||
std::vector<EdgeWeight> &edge_based_node_weights,
|
||||
std::vector<EdgeDuration> &edge_based_node_durations,
|
||||
util::DeallocatingVector<EdgeBasedEdge> &edge_based_edge_list,
|
||||
std::uint32_t &connectivity_checksum)
|
||||
{
|
||||
@@ -782,6 +785,7 @@ EdgeID Extractor::BuildEdgeExpandedGraph(
|
||||
edge_based_graph_factory.GetEdgeBasedNodeSegments(edge_based_node_segments);
|
||||
edge_based_graph_factory.GetStartPointMarkers(node_is_startpoint);
|
||||
edge_based_graph_factory.GetEdgeBasedNodeWeights(edge_based_node_weights);
|
||||
edge_based_graph_factory.GetEdgeBasedNodeDurations(edge_based_node_durations);
|
||||
connectivity_checksum = edge_based_graph_factory.GetConnectivityChecksum();
|
||||
|
||||
return number_of_edge_based_nodes;
|
||||
|
||||
@@ -146,9 +146,13 @@ int Partitioner::Run(const PartitionerConfig &config)
|
||||
}
|
||||
{
|
||||
std::vector<EdgeWeight> node_weights;
|
||||
extractor::files::readEdgeBasedNodeWeights(config.GetPath(".osrm.enw"), node_weights);
|
||||
std::vector<EdgeDuration> node_durations;
|
||||
extractor::files::readEdgeBasedNodeWeightsDurations(
|
||||
config.GetPath(".osrm.enw"), node_weights, node_durations);
|
||||
util::inplacePermutation(node_weights.begin(), node_weights.end(), permutation);
|
||||
extractor::files::writeEdgeBasedNodeWeights(config.GetPath(".osrm.enw"), node_weights);
|
||||
util::inplacePermutation(node_durations.begin(), node_durations.end(), permutation);
|
||||
extractor::files::writeEdgeBasedNodeWeightsDurations(
|
||||
config.GetPath(".osrm.enw"), node_weights, node_durations);
|
||||
}
|
||||
{
|
||||
const auto &filename = config.GetPath(".osrm.maneuver_overrides");
|
||||
|
||||
+14
-1
@@ -529,6 +529,17 @@ EdgeID
|
||||
Updater::LoadAndUpdateEdgeExpandedGraph(std::vector<extractor::EdgeBasedEdge> &edge_based_edge_list,
|
||||
std::vector<EdgeWeight> &node_weights,
|
||||
std::uint32_t &connectivity_checksum) const
|
||||
{
|
||||
std::vector<EdgeDuration> node_durations(node_weights.size());
|
||||
return LoadAndUpdateEdgeExpandedGraph(
|
||||
edge_based_edge_list, node_weights, node_durations, connectivity_checksum);
|
||||
}
|
||||
|
||||
EdgeID
|
||||
Updater::LoadAndUpdateEdgeExpandedGraph(std::vector<extractor::EdgeBasedEdge> &edge_based_edge_list,
|
||||
std::vector<EdgeWeight> &node_weights,
|
||||
std::vector<EdgeDuration> &node_durations,
|
||||
std::uint32_t &connectivity_checksum) const
|
||||
{
|
||||
TIMER_START(load_edges);
|
||||
|
||||
@@ -536,7 +547,8 @@ Updater::LoadAndUpdateEdgeExpandedGraph(std::vector<extractor::EdgeBasedEdge> &e
|
||||
std::vector<util::Coordinate> coordinates;
|
||||
extractor::PackedOSMIDs osm_node_ids;
|
||||
|
||||
extractor::files::readEdgeBasedNodeWeights(config.GetPath(".osrm.enw"), node_weights);
|
||||
extractor::files::readEdgeBasedNodeWeightsDurations(
|
||||
config.GetPath(".osrm.enw"), node_weights, node_durations);
|
||||
|
||||
extractor::files::readEdgeBasedGraph(config.GetPath(".osrm.ebg"),
|
||||
number_of_edge_based_nodes,
|
||||
@@ -738,6 +750,7 @@ Updater::LoadAndUpdateEdgeExpandedGraph(std::vector<extractor::EdgeBasedEdge> &e
|
||||
BOOST_ASSERT(edge.source < node_weights.size());
|
||||
node_weights[edge.source] =
|
||||
node_weights[edge.source] & 0x80000000 ? new_weight | 0x80000000 : new_weight;
|
||||
node_durations[edge.source] = new_duration;
|
||||
|
||||
// We found a zero-speed edge, so we'll skip this whole edge-based-edge
|
||||
// which
|
||||
|
||||
Reference in New Issue
Block a user