From 98846847014dfcfcca4f1a54300258184d345d7f Mon Sep 17 00:00:00 2001 From: Michael Bell Date: Sat, 17 Jul 2021 20:12:42 +0100 Subject: [PATCH] Fix generation of inefficient MLD partitions Duplicate restriction nodes in the edge-based-graph are currently not in included in a mapping (.osrm.cnbg_to_ebg) from node-based-graph edges to edge-based-graph nodes. This mapping is used by the MLD partitioner to assign EBG nodes to partitions. The omission from the mapping means all restriction nodes are included in a special 'invalid' partition. This special partition will break the geolocation properties of the multi-level hierarchy. The partition and its super levels will have a large number of border nodes and very few internal paths between them. Given the partitioner is the only consumer of the mapping, we fix the issue by including the duplicate restriction nodes in the mapping, so that they are correctly assigned to a partition. This has measurable improvement on MLD routing. For a country-sized routing network, the fix reduces routing and table request computation time by ~2% and ~6% respectively. --- CHANGELOG.md | 2 ++ src/extractor/edge_based_graph_factory.cpp | 7 +++++++ src/partitioner/partitioner.cpp | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 65ebe5b80..3ebf4c56f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ - FIXED: Allow for special characters in the profile/method as part of the HTTP URL. [#6090](https://github.com/Project-OSRM/osrm-backend/pull/6090) - Build: - CHANGED: Replace Travis with Github Actions for CI builds [#6071](https://github.com/Project-OSRM/osrm-backend/pull/6071) + - Routing: + - FIXED: Fix generation of inefficient MLD partitions [#6084](https://github.com/Project-OSRM/osrm-backend/pull/6084) # 5.25.0 - Changes from 5.24.0 diff --git a/src/extractor/edge_based_graph_factory.cpp b/src/extractor/edge_based_graph_factory.cpp index 7bd359de1..edef3d589 100644 --- a/src/extractor/edge_based_graph_factory.cpp +++ b/src/extractor/edge_based_graph_factory.cpp @@ -412,6 +412,13 @@ EdgeBasedGraphFactory::GenerateEdgeExpandedNodes(const WayRestrictionMap &way_re m_edge_based_node_distances.push_back( m_edge_based_node_distances[nbe_to_ebn_mapping[eid]]); + // Include duplicate nodes in cnbg to ebg mapping. This means a + // compressed node pair (u,v) can appear multiple times in this list. + // This is needed by the MLD partition step to ensure duplicate nodes + // are also assigned to partitions (the MLD partitioner is currently + // the only consumer of this mapping). + mapping.push_back(NBGToEBG{node_u, node_v, edge_based_node_id, SPECIAL_NODEID}); + edge_based_node_id++; progress.PrintStatus(progress_counter++); } diff --git a/src/partitioner/partitioner.cpp b/src/partitioner/partitioner.cpp index 29f6395a3..f01ea966c 100644 --- a/src/partitioner/partitioner.cpp +++ b/src/partitioner/partitioner.cpp @@ -118,6 +118,10 @@ int Partitioner::Run(const PartitionerConfig &config) edge_based_partition_ids[backward_node] = node_based_partition_ids[v]; } + BOOST_ASSERT(std::none_of(edge_based_partition_ids.begin(), + edge_based_partition_ids.end(), + [](auto x) { return x == SPECIAL_NODEID; })); + std::vector partitions; std::vector level_to_num_cells; std::tie(partitions, level_to_num_cells) =