Always read .osrm.enw file in updater
This commit is contained in:
parent
9b4a4fdd82
commit
db18e8669f
@ -21,7 +21,8 @@ struct CustomizationConfig final : storage::IOConfig
|
||||
".osrm.partition",
|
||||
".osrm.cells",
|
||||
".osrm.ebg_nodes",
|
||||
".osrm.properties"},
|
||||
".osrm.properties",
|
||||
".osrm.enw"},
|
||||
{},
|
||||
{".osrm.cell_metrics", ".osrm.mldgr"}),
|
||||
requested_num_threads(0)
|
||||
|
@ -74,6 +74,8 @@ class MultiLevelGraph : public partitioner::MultiLevelGraph<EdgeDataT, Ownership
|
||||
// TODO: add EdgeArrayEntry shaving
|
||||
}
|
||||
|
||||
EdgeWeight GetNodeWeight(NodeID node) const { return node_weights[node]; }
|
||||
|
||||
friend void
|
||||
serialization::read<EdgeDataT, Ownership>(storage::tar::FileReader &reader,
|
||||
const std::string &name,
|
||||
|
@ -71,12 +71,16 @@ template <> class AlgorithmDataFacade<MLD>
|
||||
|
||||
virtual unsigned GetOutDegree(const NodeID n) const = 0;
|
||||
|
||||
virtual EdgeRange GetAdjacentEdgeRange(const NodeID node) const = 0;
|
||||
|
||||
virtual EdgeWeight GetNodeWeight(const NodeID node) const = 0;
|
||||
|
||||
virtual EdgeWeight GetNodeDuration(const NodeID node) const = 0; // TODO: to be removed
|
||||
|
||||
virtual NodeID GetTarget(const EdgeID e) const = 0;
|
||||
|
||||
virtual const EdgeData &GetEdgeData(const EdgeID e) const = 0;
|
||||
|
||||
virtual EdgeRange GetAdjacentEdgeRange(const NodeID node) const = 0;
|
||||
|
||||
virtual const partitioner::MultiLevelPartitionView &GetMultiLevelPartition() const = 0;
|
||||
|
||||
virtual const partitioner::CellStorageView &GetCellStorage() const = 0;
|
||||
|
@ -282,13 +282,13 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
return segment_data.GetReverseDatasources(id);
|
||||
}
|
||||
|
||||
TurnPenalty GetWeightPenaltyForEdgeID(const unsigned id) const override final
|
||||
TurnPenalty GetWeightPenaltyForEdgeID(const EdgeID id) const override final
|
||||
{
|
||||
BOOST_ASSERT(m_turn_weight_penalties.size() > id);
|
||||
return m_turn_weight_penalties[id];
|
||||
}
|
||||
|
||||
TurnPenalty GetDurationPenaltyForEdgeID(const unsigned id) const override final
|
||||
TurnPenalty GetDurationPenaltyForEdgeID(const EdgeID id) const override final
|
||||
{
|
||||
BOOST_ASSERT(m_turn_duration_penalties.size() > id);
|
||||
return m_turn_duration_penalties[id];
|
||||
@ -682,6 +682,21 @@ template <> class ContiguousInternalMemoryAlgorithmDataFacade<MLD> : public Algo
|
||||
return query_graph.GetOutDegree(n);
|
||||
}
|
||||
|
||||
EdgeRange GetAdjacentEdgeRange(const NodeID node) const override final
|
||||
{
|
||||
return query_graph.GetAdjacentEdgeRange(node);
|
||||
}
|
||||
|
||||
EdgeWeight GetNodeWeight(const NodeID node) const override final
|
||||
{
|
||||
return query_graph.GetNodeWeight(node);
|
||||
}
|
||||
|
||||
EdgeDuration GetNodeDuration(const NodeID) const override final
|
||||
{
|
||||
return 0; // TODO: query_graph.GetNodeduration(node);
|
||||
}
|
||||
|
||||
NodeID GetTarget(const EdgeID e) const override final { return query_graph.GetTarget(e); }
|
||||
|
||||
const EdgeData &GetEdgeData(const EdgeID e) const override final
|
||||
@ -689,11 +704,6 @@ template <> class ContiguousInternalMemoryAlgorithmDataFacade<MLD> : public Algo
|
||||
return query_graph.GetEdgeData(e);
|
||||
}
|
||||
|
||||
EdgeRange GetAdjacentEdgeRange(const NodeID node) const override final
|
||||
{
|
||||
return query_graph.GetAdjacentEdgeRange(node);
|
||||
}
|
||||
|
||||
EdgeRange GetBorderEdgeRange(const LevelID level, const NodeID node) const override final
|
||||
{
|
||||
return query_graph.GetBorderEdgeRange(level, node);
|
||||
|
@ -86,9 +86,9 @@ class BaseDataFacade
|
||||
virtual NodeForwardRange GetUncompressedForwardGeometry(const EdgeID id) const = 0;
|
||||
virtual NodeReverseRange GetUncompressedReverseGeometry(const EdgeID id) const = 0;
|
||||
|
||||
virtual TurnPenalty GetWeightPenaltyForEdgeID(const unsigned id) const = 0;
|
||||
virtual TurnPenalty GetWeightPenaltyForEdgeID(const EdgeID id) const = 0;
|
||||
|
||||
virtual TurnPenalty GetDurationPenaltyForEdgeID(const unsigned id) const = 0;
|
||||
virtual TurnPenalty GetDurationPenaltyForEdgeID(const EdgeID id) const = 0;
|
||||
|
||||
// Gets the weight values for each segment in an uncompressed geometry.
|
||||
// Should always be 1 shorter than GetUncompressedGeometry
|
||||
|
@ -206,6 +206,7 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
|
||||
for (const auto edge : facade.GetBorderEdgeRange(level, node))
|
||||
{
|
||||
const auto &edge_data = facade.GetEdgeData(edge);
|
||||
|
||||
if (DIRECTION == FORWARD_DIRECTION ? edge_data.forward : edge_data.backward)
|
||||
{
|
||||
const NodeID to = facade.GetTarget(edge);
|
||||
@ -213,8 +214,13 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
|
||||
if (!facade.ExcludeNode(to) &&
|
||||
checkParentCellRestriction(partition.GetCell(level + 1, to), args...))
|
||||
{
|
||||
BOOST_ASSERT_MSG(edge_data.weight > 0, "edge_weight invalid");
|
||||
const EdgeWeight to_weight = weight + edge_data.weight;
|
||||
const auto node_weight =
|
||||
facade.GetNodeWeight(DIRECTION == FORWARD_DIRECTION ? node : to);
|
||||
const auto turn_penalty = facade.GetWeightPenaltyForEdgeID(edge_data.turn_id);
|
||||
|
||||
BOOST_ASSERT(edge_data.weight == node_weight + turn_penalty);
|
||||
|
||||
const EdgeWeight to_weight = weight + node_weight + turn_penalty;
|
||||
|
||||
if (!forward_heap.WasInserted(to))
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ namespace partitioner
|
||||
struct PartitionerConfig final : storage::IOConfig
|
||||
{
|
||||
PartitionerConfig()
|
||||
: IOConfig({".osrm", ".osrm.fileIndex", ".osrm.ebg_nodes"},
|
||||
: IOConfig({".osrm", ".osrm.fileIndex", ".osrm.ebg_nodes", ".osrm.enw"},
|
||||
{".osrm.hsgr", ".osrm.cnbg"},
|
||||
{".osrm.ebg",
|
||||
".osrm.cnbg",
|
||||
|
@ -53,7 +53,8 @@ struct UpdaterConfig final : storage::IOConfig
|
||||
".osrm.geometry",
|
||||
".osrm.fileIndex",
|
||||
".osrm.properties",
|
||||
".osrm.restrictions"},
|
||||
".osrm.restrictions",
|
||||
".osrm.enw"},
|
||||
{},
|
||||
{".osrm.datasource_names"}),
|
||||
valid_now(0)
|
||||
|
@ -9,6 +9,8 @@ lonlat = lambda x: (coord2float(x['lon']['__value']), coord2float(x['lat']['__va
|
||||
|
||||
def call(this, method, *args):
|
||||
"""Call this.method(args)"""
|
||||
if (str(this) == '<optimized out>'):
|
||||
raise BaseException('"this" is optimized out')
|
||||
command = '(*({})({})).{}({})'.format(this.type.target().pointer(), this.address, method, ','.join((str(x) for x in args)))
|
||||
return gdb.parse_and_eval(command)
|
||||
|
||||
@ -234,7 +236,6 @@ class SVGPrinter (gdb.Command):
|
||||
mld_facade = facade.cast(gdb.lookup_type('osrm::engine::datafacade::ContiguousInternalMemoryAlgorithmDataFacade<osrm::engine::routing_algorithms::mld::Algorithm>'))
|
||||
mld_partition = mld_facade['mld_partition']
|
||||
mld_levels = call(mld_partition, 'GetNumberOfLevels')
|
||||
print (mld_level, mld_levels)
|
||||
if mld_level < mld_levels:
|
||||
sentinel_node = call(mld_partition['partition'], 'size') - 1 # GetSentinelNode
|
||||
number_of_cells = call(mld_partition, 'GetCell', mld_level, sentinel_node) # GetNumberOfCells
|
||||
@ -272,6 +273,7 @@ class SVGPrinter (gdb.Command):
|
||||
for node in nodes:
|
||||
geometry_id = call(facade, 'GetGeometryIndex', node)
|
||||
direction = 'forward' if geometry_id['forward'] else 'reverse'
|
||||
print (geometry_id, direction)
|
||||
geometry = SVGPrinter.getByGeometryId(facade, geometry_id, 'Geometry')
|
||||
weights = SVGPrinter.getByGeometryId(facade, geometry_id, 'Weights')
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -325,6 +325,11 @@ class ContiguousInternalMemoryDataFacade<routing_algorithms::offline::Algorithm>
|
||||
return {};
|
||||
}
|
||||
|
||||
EdgeWeight GetNodeWeight(const NodeID /*node*/) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool HasLaneData(const EdgeID /*id*/) const override { return false; }
|
||||
NameID GetNameIndex(const NodeID /*nodeID*/) const override { return EMPTY_NAMEID; }
|
||||
StringView GetNameForID(const NameID /*id*/) const override { return StringView{}; }
|
||||
|
Loading…
Reference in New Issue
Block a user