Skip to content

Fix rare 'waypoints are not included in points' error occurring for edge-based CH alternatives#3139

Merged
michaz merged 4 commits intomasterfrom
alt_ch_edge_fix
Mar 11, 2025
Merged

Fix rare 'waypoints are not included in points' error occurring for edge-based CH alternatives#3139
michaz merged 4 commits intomasterfrom
alt_ch_edge_fix

Conversation

@easbar
Copy link
Copy Markdown
Member

@easbar easbar commented Mar 9, 2025

This bug in AlternativeRouteEdgeCH was introduced in #2101: If there is a turn restriction at the node where we 'glue together' the s->v and v->t paths the uvt-path might be empty/not found. This can cause alternative routes that end at node v and thus do not even reach the target node t. Sometimes they also have a lower weight than the best path. Paths that do not end at the target node cause an error in PathMerger reading:

java.lang.IllegalStateException: waypoints are not included in points, or waypoint indices are wrong

Whether the error occurs or not strongly depends on the set of nodes where the forward/backward SPTs overlap which in turn strongly depends on the exact structure of the CH. Therefore the error often cannot be reproduced on a smaller map extract.

The fix is quite simple: We just need to filter out these alternative path candidates.

Related: #2850

@easbar easbar added the bug label Mar 9, 2025
@easbar easbar added this to the 11.0 milestone Mar 9, 2025
Comment on lines -152 to -167
@RepeatedTest(value = 1000)
void testForErrors() {
// error analysis:
// * suvPath is found, but uvtPath isn't!
// * suvPath is some kind of loop leading back close to the start (but not the virtual start node)
// * the resulting alternative has lower weight than the best path!
// * the resulting alternative does not even connect the start and target nodes
long seed = System.nanoTime();
System.out.println(seed);
Random rnd = new Random(seed);
final BaseGraph graph = new BaseGraph.Builder(em).withTurnCosts(true).create();
GHUtility.buildRandomGraph(graph, rnd, 10, 2.0, false, speedEnc, 60.0, 0.5, 0);
GHUtility.addRandomTurnCosts(graph, seed, null, turnCostEnc, 1, graph.getTurnCostStorage());
// GHUtility.printGraphForUnitTest(graph, speedEnc);
graph.freeze();
RoutingCHGraph routingCHGraph = prepareCH(graph);
Copy link
Copy Markdown
Member Author

@easbar easbar Mar 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used this code to produce a simple situation where the error occurs. Just in case we run into a similar problem again.

Copy link
Copy Markdown
Member

@michaz michaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super, danke!

Ich glaube, ich vergesse immer, dass es "nicht gefundene Pfade" gibt, die man dann aber trotzdem wie Pfade verwenden kann.

@michaz michaz merged commit 34749f8 into master Mar 11, 2025
3 of 4 checks passed
@michaz michaz deleted the alt_ch_edge_fix branch March 11, 2025 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants