Skip to content

Conversation

@habrahamsson-skanetrafiken
Copy link
Contributor

@habrahamsson-skanetrafiken habrahamsson-skanetrafiken commented Dec 18, 2025

Summary

This PR adds support for a complimentary search that is run in addition to the regular raptor search. This new search extends the search result with "direct" transit paths, that is paths with a single transit leg. In contrast to raptor it returns paths even if they are not optimal according to any criteria. It can be configured to run with access/egress or only for stop to stop searches.

The main use case for this additional search is to show slower journeys such as regional trains, slower buses etc that are not included in the main raptor search. See the highlighted journey in the example below, using an ordinary raptor search it will never show up in a search results because the previous journey is better in all criteria.

direct-transit1

Issue

Closes #6977. See issue for detailed use cases.

Implementation

The search is implemented in the raptor module and runs on the raptor transit data in order to take advantage of the cost calculation and the itinerary mapping.

Configuration

This feature is currently not exposed through any api and is configurable through router-config.json. It takes three configuration parameters:

costRelaxFunction
In order to exclude really bad paths there is a cost function that is used to reject paths that are much more expensive than the cheapest path.

extraAccessEgressCostFactor
When using this search in an area with lots of transit options such as a city center it can produce too many results where one walks for a while, takes a short transit and then walks to the destination. Having too many of these alternatives will not be useful to travelers. They can be limited using an extra cost on accesses and egresses that is specific for this search.

maxAccessEgressDuration
The maximum length of access/egress, can also be configured to not use access/egress at all. In that case it will only be used when searching to and from a stop or station.

Bumping the serialization version id

Yes, updating the route request.

@habrahamsson-skanetrafiken habrahamsson-skanetrafiken requested a review from a team as a code owner December 18, 2025 08:41
@habrahamsson-skanetrafiken habrahamsson-skanetrafiken added !New Feature A functional feature targeting the end user. +Bump Serialization Id Add this label if you want the serialization id automatically bumped after merging the PR labels Dec 18, 2025
@codecov
Copy link

codecov bot commented Dec 18, 2025

Codecov Report

❌ Patch coverage is 31.68605% with 235 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.97%. Comparing base (b0a7a05) to head (64cf3b4).
⚠️ Report is 71 commits behind head on dev-2.x.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...ner/raptor/direct/service/DirectTransitSearch.java 1.12% 88 Missing ⚠️
.../raptor/direct/api/RaptorDirectTransitRequest.java 0.00% 49 Missing ⚠️
...er/transit/mappers/DirectTransitRequestMapper.java 5.12% 36 Missing and 1 partial ⚠️
.../direct/api/RaptorDirectTransitRequestBuilder.java 0.00% 26 Missing ⚠️
...anner/routing/framework/DebugTimingAggregator.java 30.76% 7 Missing and 2 partials ⚠️
.../algorithm/raptoradapter/router/TransitRouter.java 50.00% 6 Missing and 1 partial ⚠️
...r/direct/configure/DirectTransitSearchFactory.java 0.00% 7 Missing ⚠️
...ptoradapter/transit/AccessEgressWithExtraCost.java 0.00% 4 Missing ⚠️
...i/request/preference/DirectTransitPreferences.java 94.23% 1 Missing and 2 partials ⚠️
...ing/api/request/preference/TransitPreferences.java 76.92% 1 Missing and 2 partials ⚠️
... and 2 more
Additional details and impacted files
@@              Coverage Diff              @@
##             dev-2.x    #7145      +/-   ##
=============================================
- Coverage      72.14%   71.97%   -0.17%     
- Complexity     21045    21112      +67     
=============================================
  Files           2292     2305      +13     
  Lines          85036    85569     +533     
  Branches        8473     8526      +53     
=============================================
+ Hits           61349    61592     +243     
- Misses         20713    20993     +280     
- Partials        2974     2984      +10     

☔ 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.

@t2gran t2gran force-pushed the relaxed-limited-transfer-search branch from 81feadd to 6081246 Compare January 12, 2026 11:43
@habrahamsson-skanetrafiken habrahamsson-skanetrafiken changed the title Relaxed limited transfer search Direct transit search Jan 12, 2026
* <p>
* The direct transit search should include trips within the cost limit
*/
public class M04_RelaxedCostLimit implements RaptorTestConstants {
Copy link
Member

Choose a reason for hiding this comment

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

The test description is incorrect. This test is testing departure time and arrival time for optimality.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it?

Copy link
Member

@t2gran t2gran Jan 23, 2026

Choose a reason for hiding this comment

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

Not sure I understand the comments on each of the test methods - they seem to focus on arrive/departure times, while the class objective talk about cost. Are arrival & departure times considered?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I understand what you mean and I tried to clarify the comments. The search will include results if they are optimal on arrival or departure or if they are within the "cost limit". These tests are set up in such a way that arrival and departure times should not influence whether the trip under test gets included or not.

Maye I should just remove the reference to arrival and departure times in the comments.

@leonardehrenfried
Copy link
Member

You need to resolve the conflicts.

@t2gran t2gran added this to the 2.9 (next release) milestone Jan 23, 2026
…m/raptoradapter/transit/mappers/DirectTransitRequestMapper.java

Co-authored-by: Thomas Gran <[email protected]>
t2gran
t2gran previously approved these changes Jan 29, 2026
t2gran
t2gran previously approved these changes Jan 29, 2026
@Override
public String toString() {
return ToStringBuilder.of(DirectTransitPreferences.class)
.addBool("enabled", enabled)
Copy link
Member

Choose a reason for hiding this comment

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

Should we only log this when it doesn't match the default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it would be helpful to log it even when it is default (false) since this will cause the direct transit search to be disabled.

)
.withCostRelaxFunction(
c
.of("costRelaxFunction")
Copy link
Member

Choose a reason for hiding this comment

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

What did we decide with this naming? I can't remember anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We decided to leave it like this to keep it consistent with the transit group priority. If we decide to change this to "costLimitFunction" we will do that together with the transit group priority feature.

@optionsome
Copy link
Member

Formatting is broken.

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

Labels

+Bump Serialization Id Add this label if you want the serialization id automatically bumped after merging the PR !New Feature A functional feature targeting the end user.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Include non-optimal direct transit trips in search result

5 participants