Skip to content

Conversation

@t2gran
Copy link
Member

@t2gran t2gran commented Jan 2, 2026

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) to DestinationArrivalPaths.qualify()
  • The c2 value (secondary cost, used for transit priority) was hardcoded to NOT_SET in dummy paths
  • This meant pareto comparison during pruning didn't account for transit priority penalties

After this fix:

  • c2 is now threaded through the entire qualify chain
  • HeuristicsProvider.qualify()DestinationArrivalPaths.qualify()Path.dummyPath() all pass c2
  • Destination pruning now correctly considers both cost criteria

Testing

  • Updated PathTest to include c2 values in test cases, verifying path comparison respects c2 ordering
  • Added a module test I02_C2DestinationPruningTest that specifically tests destination pruning with transit priority groups
  • Test verifies that paths are correctly qualified/disqualified based on c2 values when using multi-criteria search

Performance 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

 ==> multi_criteria_destination : [  294,  280,  277,  279,  280 ] Avg: 282,0  (σ=6,1)
 ==> multi_criteria_destination : [  420,  389,  386,  390,  390 ] Avg: 395,0  (σ=12,6)

After fix

 ==> multi_criteria_destination : [  296,  282,  291,  281,  282 ] Avg: 286,4  (σ=6,0)
 ==> multi_criteria_destination : [  426,  393,  403,  392,  391 ] Avg: 401,0  (σ=13,2)

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.

@t2gran t2gran added this to the 2.9 (next release) milestone Jan 2, 2026
@t2gran t2gran requested a review from a team as a code owner January 2, 2026 16:56
@t2gran t2gran added !Bug Apply to issues describing a bug and PRs witch fixes it. Entur Test This is currently being tested at Entur labels Jan 2, 2026
@t2gran t2gran force-pushed the c2-destination-pruning branch from e884965 to c6aa533 Compare January 5, 2026 09:55
@t2gran t2gran changed the title feature: Add c2 to the Raptor heuristics. Add second criteria to the Raptor heuristics Jan 5, 2026
@leonardehrenfried
Copy link
Member

You have a conflict.

@codecov
Copy link

codecov bot commented Jan 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.17%. Comparing base (2540a97) to head (f70f649).
⚠️ Report is 3 commits behind head on dev-2.x.

Additional details and impacted files
@@            Coverage Diff             @@
##             dev-2.x    #7165   +/-   ##
==========================================
  Coverage      72.17%   72.17%           
- Complexity     20877    20878    +1     
==========================================
  Files           2273     2273           
  Lines          84437    84438    +1     
  Branches        8424     8424           
==========================================
+ Hits           60942    60945    +3     
+ Misses         20520    20518    -2     
  Partials        2975     2975           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

!Bug Apply to issues describing a bug and PRs witch fixes it. Entur Test This is currently being tested at Entur

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The Raptor heuristic qualify check drop optimal travel paths with transit group priority

2 participants