Add second criteria to the Raptor heuristics #7165
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a bug in Raptor's destination pruning heuristics where the secondary cost criterion (c2) was not being considered when evaluating whether paths can be pruned. When using multi-criteria search with transit priority groups, this could cause paths to be incorrectly pruned based on incomplete cost information (only c1, ignoring c2). Note! There
are usually a lot of slack in the heuristics due to the estimation of c1, so this bug only apply when the slack is less than the c1 relaxation.
Issue
Closes #7112
Raptor Transit Routing
The HeuristicsProvider creates optimistic best-case estimates for paths to determine if continuing a search branch is worthwhile. It does this by combining actual arrival state with pre-calculated heuristics to estimate the best possible final destination arrival. These estimates are then checked against the current best known paths using
DestinationArrivalPaths.qualify().Before this fix:
HeuristicsProvider.qualify()was only passing c1 (primary cost) toDestinationArrivalPaths.qualify()NOT_SETin dummy pathsAfter this fix:
HeuristicsProvider.qualify()→DestinationArrivalPaths.qualify()→Path.dummyPath()all pass c2Testing
PathTestto include c2 values in test cases, verifying path comparison respects c2 orderingI02_C2DestinationPruningTestthat specifically tests destination pruning with transit priority groupsPerformance Impact
This change modifies Raptor's heuristics evaluation, but only adds parameter passing - no additional computation. The qualify() method was already being called; it now has access to complete cost information. This does however increase the number of paths evaluated, so a smal increase in the search time is expected - now including possible optimal paths, witch was dropped earlier.
Performance verification
I have not seen any significant changes in the SpeedTest run on the Norway data set:
Before
After fix
Documentation
✅ Java Documentation updated - the modified methods maintain clear javadoc
Changelog
✅ Should be included in changelog
Bumping the serialization version id
🟥 No serialization changes
This PR modifies Raptor's internal routing logic but doesn't change any serialized graph data structures or edge properties. No serialization version bump needed.