Skip to content

Commit db18e86

Browse files
oxidasePatrick Niklaus
authored andcommitted
Always read .osrm.enw file in updater
1 parent 9b4a4fd commit db18e86

File tree

14 files changed

+71
-37
lines changed

14 files changed

+71
-37
lines changed

include/customizer/customizer_config.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ struct CustomizationConfig final : storage::IOConfig
2121
".osrm.partition",
2222
".osrm.cells",
2323
".osrm.ebg_nodes",
24-
".osrm.properties"},
24+
".osrm.properties",
25+
".osrm.enw"},
2526
{},
2627
{".osrm.cell_metrics", ".osrm.mldgr"}),
2728
requested_num_threads(0)

include/customizer/edge_based_graph.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ class MultiLevelGraph : public partitioner::MultiLevelGraph<EdgeDataT, Ownership
7474
// TODO: add EdgeArrayEntry shaving
7575
}
7676

77+
EdgeWeight GetNodeWeight(NodeID node) const { return node_weights[node]; }
78+
7779
friend void
7880
serialization::read<EdgeDataT, Ownership>(storage::tar::FileReader &reader,
7981
const std::string &name,

include/engine/datafacade/algorithm_datafacade.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,16 @@ template <> class AlgorithmDataFacade<MLD>
7171

7272
virtual unsigned GetOutDegree(const NodeID n) const = 0;
7373

74+
virtual EdgeRange GetAdjacentEdgeRange(const NodeID node) const = 0;
75+
76+
virtual EdgeWeight GetNodeWeight(const NodeID node) const = 0;
77+
78+
virtual EdgeWeight GetNodeDuration(const NodeID node) const = 0; // TODO: to be removed
79+
7480
virtual NodeID GetTarget(const EdgeID e) const = 0;
7581

7682
virtual const EdgeData &GetEdgeData(const EdgeID e) const = 0;
7783

78-
virtual EdgeRange GetAdjacentEdgeRange(const NodeID node) const = 0;
79-
8084
virtual const partitioner::MultiLevelPartitionView &GetMultiLevelPartition() const = 0;
8185

8286
virtual const partitioner::CellStorageView &GetCellStorage() const = 0;

include/engine/datafacade/contiguous_internalmem_datafacade.hpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -282,13 +282,13 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
282282
return segment_data.GetReverseDatasources(id);
283283
}
284284

285-
TurnPenalty GetWeightPenaltyForEdgeID(const unsigned id) const override final
285+
TurnPenalty GetWeightPenaltyForEdgeID(const EdgeID id) const override final
286286
{
287287
BOOST_ASSERT(m_turn_weight_penalties.size() > id);
288288
return m_turn_weight_penalties[id];
289289
}
290290

291-
TurnPenalty GetDurationPenaltyForEdgeID(const unsigned id) const override final
291+
TurnPenalty GetDurationPenaltyForEdgeID(const EdgeID id) const override final
292292
{
293293
BOOST_ASSERT(m_turn_duration_penalties.size() > id);
294294
return m_turn_duration_penalties[id];
@@ -682,16 +682,26 @@ template <> class ContiguousInternalMemoryAlgorithmDataFacade<MLD> : public Algo
682682
return query_graph.GetOutDegree(n);
683683
}
684684

685-
NodeID GetTarget(const EdgeID e) const override final { return query_graph.GetTarget(e); }
685+
EdgeRange GetAdjacentEdgeRange(const NodeID node) const override final
686+
{
687+
return query_graph.GetAdjacentEdgeRange(node);
688+
}
686689

687-
const EdgeData &GetEdgeData(const EdgeID e) const override final
690+
EdgeWeight GetNodeWeight(const NodeID node) const override final
688691
{
689-
return query_graph.GetEdgeData(e);
692+
return query_graph.GetNodeWeight(node);
690693
}
691694

692-
EdgeRange GetAdjacentEdgeRange(const NodeID node) const override final
695+
EdgeDuration GetNodeDuration(const NodeID) const override final
693696
{
694-
return query_graph.GetAdjacentEdgeRange(node);
697+
return 0; // TODO: query_graph.GetNodeduration(node);
698+
}
699+
700+
NodeID GetTarget(const EdgeID e) const override final { return query_graph.GetTarget(e); }
701+
702+
const EdgeData &GetEdgeData(const EdgeID e) const override final
703+
{
704+
return query_graph.GetEdgeData(e);
695705
}
696706

697707
EdgeRange GetBorderEdgeRange(const LevelID level, const NodeID node) const override final

include/engine/datafacade/datafacade_base.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ class BaseDataFacade
8686
virtual NodeForwardRange GetUncompressedForwardGeometry(const EdgeID id) const = 0;
8787
virtual NodeReverseRange GetUncompressedReverseGeometry(const EdgeID id) const = 0;
8888

89-
virtual TurnPenalty GetWeightPenaltyForEdgeID(const unsigned id) const = 0;
89+
virtual TurnPenalty GetWeightPenaltyForEdgeID(const EdgeID id) const = 0;
9090

91-
virtual TurnPenalty GetDurationPenaltyForEdgeID(const unsigned id) const = 0;
91+
virtual TurnPenalty GetDurationPenaltyForEdgeID(const EdgeID id) const = 0;
9292

9393
// Gets the weight values for each segment in an uncompressed geometry.
9494
// Should always be 1 shorter than GetUncompressedGeometry

include/engine/routing_algorithms/routing_base_mld.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,21 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
206206
for (const auto edge : facade.GetBorderEdgeRange(level, node))
207207
{
208208
const auto &edge_data = facade.GetEdgeData(edge);
209+
209210
if (DIRECTION == FORWARD_DIRECTION ? edge_data.forward : edge_data.backward)
210211
{
211212
const NodeID to = facade.GetTarget(edge);
212213

213214
if (!facade.ExcludeNode(to) &&
214215
checkParentCellRestriction(partition.GetCell(level + 1, to), args...))
215216
{
216-
BOOST_ASSERT_MSG(edge_data.weight > 0, "edge_weight invalid");
217-
const EdgeWeight to_weight = weight + edge_data.weight;
217+
const auto node_weight =
218+
facade.GetNodeWeight(DIRECTION == FORWARD_DIRECTION ? node : to);
219+
const auto turn_penalty = facade.GetWeightPenaltyForEdgeID(edge_data.turn_id);
220+
221+
BOOST_ASSERT(edge_data.weight == node_weight + turn_penalty);
222+
223+
const EdgeWeight to_weight = weight + node_weight + turn_penalty;
218224

219225
if (!forward_heap.WasInserted(to))
220226
{

include/partitioner/partitioner_config.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace partitioner
1616
struct PartitionerConfig final : storage::IOConfig
1717
{
1818
PartitionerConfig()
19-
: IOConfig({".osrm", ".osrm.fileIndex", ".osrm.ebg_nodes"},
19+
: IOConfig({".osrm", ".osrm.fileIndex", ".osrm.ebg_nodes", ".osrm.enw"},
2020
{".osrm.hsgr", ".osrm.cnbg"},
2121
{".osrm.ebg",
2222
".osrm.cnbg",

include/updater/updater_config.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ struct UpdaterConfig final : storage::IOConfig
5353
".osrm.geometry",
5454
".osrm.fileIndex",
5555
".osrm.properties",
56-
".osrm.restrictions"},
56+
".osrm.restrictions",
57+
".osrm.enw"},
5758
{},
5859
{".osrm.datasource_names"}),
5960
valid_now(0)

scripts/gdb_printers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
def call(this, method, *args):
1111
"""Call this.method(args)"""
12+
if (str(this) == '<optimized out>'):
13+
raise BaseException('"this" is optimized out')
1214
command = '(*({})({})).{}({})'.format(this.type.target().pointer(), this.address, method, ','.join((str(x) for x in args)))
1315
return gdb.parse_and_eval(command)
1416

@@ -234,7 +236,6 @@ def Facade(facade, width, height, arg):
234236
mld_facade = facade.cast(gdb.lookup_type('osrm::engine::datafacade::ContiguousInternalMemoryAlgorithmDataFacade<osrm::engine::routing_algorithms::mld::Algorithm>'))
235237
mld_partition = mld_facade['mld_partition']
236238
mld_levels = call(mld_partition, 'GetNumberOfLevels')
237-
print (mld_level, mld_levels)
238239
if mld_level < mld_levels:
239240
sentinel_node = call(mld_partition['partition'], 'size') - 1 # GetSentinelNode
240241
number_of_cells = call(mld_partition, 'GetCell', mld_level, sentinel_node) # GetNumberOfCells
@@ -272,6 +273,7 @@ def Facade(facade, width, height, arg):
272273
for node in nodes:
273274
geometry_id = call(facade, 'GetGeometryIndex', node)
274275
direction = 'forward' if geometry_id['forward'] else 'reverse'
276+
print (geometry_id, direction)
275277
geometry = SVGPrinter.getByGeometryId(facade, geometry_id, 'Geometry')
276278
weights = SVGPrinter.getByGeometryId(facade, geometry_id, 'Weights')
277279

src/customize/customizer.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,20 @@ void printUnreachableStatistics(const Partition &partition,
7474

7575
auto LoadAndUpdateEdgeExpandedGraph(const CustomizationConfig &config,
7676
const partitioner::MultiLevelPartition &mlp,
77+
std::vector<EdgeWeight> &node_weights,
7778
std::uint32_t &connectivity_checksum)
7879
{
7980
updater::Updater updater(config.updater_config);
8081

81-
EdgeID num_nodes;
8282
std::vector<extractor::EdgeBasedEdge> edge_based_edge_list;
83-
std::tie(num_nodes, edge_based_edge_list, connectivity_checksum) =
84-
updater.LoadAndUpdateEdgeExpandedGraph();
83+
EdgeID num_nodes = updater.LoadAndUpdateEdgeExpandedGraph(
84+
edge_based_edge_list, node_weights, connectivity_checksum);
8585

8686
auto directed = partitioner::splitBidirectionalEdges(edge_based_edge_list);
87+
8788
auto tidied = partitioner::prepareEdgesForUsageInGraph<
8889
typename partitioner::MultiLevelEdgeBasedGraph::InputEdge>(std::move(directed));
90+
8991
auto edge_based_graph =
9092
partitioner::MultiLevelEdgeBasedGraph(mlp, num_nodes, std::move(tidied));
9193

@@ -120,8 +122,11 @@ int Customizer::Run(const CustomizationConfig &config)
120122
partitioner::MultiLevelPartition mlp;
121123
partitioner::files::readPartition(config.GetPath(".osrm.partition"), mlp);
122124

125+
std::vector<EdgeWeight> node_weights;
123126
std::uint32_t connectivity_checksum = 0;
124-
auto graph = LoadAndUpdateEdgeExpandedGraph(config, mlp, connectivity_checksum);
127+
auto graph = LoadAndUpdateEdgeExpandedGraph(config, mlp, node_weights, connectivity_checksum);
128+
BOOST_ASSERT(graph.GetNumberOfNodes() == node_weights.size());
129+
std::for_each(node_weights.begin(), node_weights.end(), [](auto &w) { w &= 0x7fffffff; });
125130
util::Log() << "Loaded edge based graph: " << graph.GetNumberOfEdges() << " edges, "
126131
<< graph.GetNumberOfNodes() << " nodes";
127132

@@ -158,8 +163,7 @@ int Customizer::Run(const CustomizationConfig &config)
158163
util::Log() << "MLD customization writing took " << TIMER_SEC(writing_mld_data) << " seconds";
159164

160165
TIMER_START(writing_graph);
161-
std::vector<EdgeWeight> node_weights;
162-
std::vector<EdgeDuration> node_durations;
166+
std::vector<EdgeDuration> node_durations; // TODO: save an empty vector, to be removed later
163167
MultiLevelEdgeBasedGraph shaved_graph{
164168
std::move(graph), std::move(node_weights), std::move(node_durations)};
165169
customizer::files::writeGraph(

0 commit comments

Comments
 (0)