Always read .osrm.enw file in updater

This commit is contained in:
Michael Krasnyk
2018-04-22 09:34:31 +03:00
committed by Patrick Niklaus
parent 9b4a4fdd82
commit db18e8669f
14 changed files with 71 additions and 37 deletions
+10 -6
View File
@@ -74,18 +74,20 @@ void printUnreachableStatistics(const Partition &partition,
auto LoadAndUpdateEdgeExpandedGraph(const CustomizationConfig &config,
const partitioner::MultiLevelPartition &mlp,
std::vector<EdgeWeight> &node_weights,
std::uint32_t &connectivity_checksum)
{
updater::Updater updater(config.updater_config);
EdgeID num_nodes;
std::vector<extractor::EdgeBasedEdge> edge_based_edge_list;
std::tie(num_nodes, edge_based_edge_list, connectivity_checksum) =
updater.LoadAndUpdateEdgeExpandedGraph();
EdgeID num_nodes = updater.LoadAndUpdateEdgeExpandedGraph(
edge_based_edge_list, node_weights, connectivity_checksum);
auto directed = partitioner::splitBidirectionalEdges(edge_based_edge_list);
auto tidied = partitioner::prepareEdgesForUsageInGraph<
typename partitioner::MultiLevelEdgeBasedGraph::InputEdge>(std::move(directed));
auto edge_based_graph =
partitioner::MultiLevelEdgeBasedGraph(mlp, num_nodes, std::move(tidied));
@@ -120,8 +122,11 @@ int Customizer::Run(const CustomizationConfig &config)
partitioner::MultiLevelPartition mlp;
partitioner::files::readPartition(config.GetPath(".osrm.partition"), mlp);
std::vector<EdgeWeight> node_weights;
std::uint32_t connectivity_checksum = 0;
auto graph = LoadAndUpdateEdgeExpandedGraph(config, mlp, connectivity_checksum);
auto graph = LoadAndUpdateEdgeExpandedGraph(config, mlp, node_weights, 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, "
<< graph.GetNumberOfNodes() << " nodes";
@@ -158,8 +163,7 @@ int Customizer::Run(const CustomizationConfig &config)
util::Log() << "MLD customization writing took " << TIMER_SEC(writing_mld_data) << " seconds";
TIMER_START(writing_graph);
std::vector<EdgeWeight> node_weights;
std::vector<EdgeDuration> node_durations;
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,6 +169,8 @@ 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);
@@ -180,8 +182,9 @@ void relaxOutgoingEdges(const DataFacade<mld::Algorithm> &facade,
continue;
}
const auto edge_weight = data.weight;
const auto edge_duration = data.duration;
const auto turn_id = data.turn_id;
const auto edge_weight = node_weight + facade.GetWeightPenaltyForEdgeID(turn_id);
const auto edge_duration = node_duration + facade.GetDurationPenaltyForEdgeID(turn_id);
BOOST_ASSERT_MSG(edge_weight > 0, "edge_weight invalid");
const auto to_weight = weight + edge_weight;
+6
View File
@@ -144,6 +144,12 @@ int Partitioner::Run(const PartitionerConfig &config)
renumber(node_data, permutation);
extractor::files::writeNodeData(config.GetPath(".osrm.ebg_nodes"), node_data);
}
{
std::vector<EdgeWeight> node_weights;
extractor::files::readEdgeBasedNodeWeights(config.GetPath(".osrm.enw"), node_weights);
util::inplacePermutation(node_weights.begin(), node_weights.end(), permutation);
extractor::files::writeEdgeBasedNodeWeights(config.GetPath(".osrm.enw"), node_weights);
}
{
const auto &filename = config.GetPath(".osrm.maneuver_overrides");
std::vector<extractor::StorageManeuverOverride> maneuver_overrides;
+2 -12
View File
@@ -517,7 +517,6 @@ updateConditionalTurns(std::vector<TurnPenalty> &turn_weight_penalties,
{
if (IsRestrictionValid(time_zone_handler, penalty))
{
std::cout << "Disabling: " << penalty.turn_offset << std::endl;
turn_weight_penalties[penalty.turn_offset] = INVALID_TURN_PENALTY;
updated_turns.push_back(penalty.turn_offset);
}
@@ -526,17 +525,6 @@ updateConditionalTurns(std::vector<TurnPenalty> &turn_weight_penalties,
}
}
Updater::NumNodesAndEdges Updater::LoadAndUpdateEdgeExpandedGraph() const
{
std::vector<EdgeWeight> node_weights;
std::vector<extractor::EdgeBasedEdge> edge_based_edge_list;
std::uint32_t connectivity_checksum;
auto number_of_edge_based_nodes = Updater::LoadAndUpdateEdgeExpandedGraph(
edge_based_edge_list, node_weights, connectivity_checksum);
return std::make_tuple(
number_of_edge_based_nodes, std::move(edge_based_edge_list), connectivity_checksum);
}
EdgeID
Updater::LoadAndUpdateEdgeExpandedGraph(std::vector<extractor::EdgeBasedEdge> &edge_based_edge_list,
std::vector<EdgeWeight> &node_weights,
@@ -548,6 +536,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::readEdgeBasedGraph(config.GetPath(".osrm.ebg"),
number_of_edge_based_nodes,
edge_based_edge_list,