Skip to content

Stop count limit for access/egress routing and new accessEgress configuration object - #5214

Merged
vesameskanen merged 21 commits into
opentripplanner:dev-2.xfrom
HSLdevcom:max-nearby-stops
Aug 23, 2023
Merged

Stop count limit for access/egress routing and new accessEgress configuration object#5214
vesameskanen merged 21 commits into
opentripplanner:dev-2.xfrom
HSLdevcom:max-nearby-stops

Conversation

@vesameskanen

@vesameskanen vesameskanen commented Jun 29, 2023

Copy link
Copy Markdown
Contributor

Summary

Limiting the number of stops collected in access/egress routing seems to be a very fundamental need. There are already some heuristics implementations in the sandbox. They apply some non-trivial (and somewhat time consuming) logic to analyze and collect 'good stops'. Surprisingly, such logic seems to cause unexpected errors and arise a need to understand how the transit data is modeled by various data producers, thus making configuring the heuristics difficult. For example: what is a typical bike-compatible trip count of a train stop? it can be anything between 100 and 10000.

in this PR, a very simple and fast option to limit the stop count is implemented. One single configuration value applies to all street modes. As the suitable limit value is typically quite high, e.g. 300-500, the skipEdgeStrategy does not have to be very precise, and therefore fast counting of visited transit stops works fine.

The new strategy does not qualify stops against search parameters, but that seems to have only a little effect. For example, if 300 nearest stops provide no bike-compatible trips, then bike + transit itineraries are likely to be poor.

This PR also collect access/egress routing parameters to a new JSON object called accessEgress.

Documentation

Updated

@vesameskanen
vesameskanen requested a review from a team as a code owner June 29, 2023 09:01
@vesameskanen vesameskanen added !Improvement A functional improvement or micro feature !Optimization The feature is to improve performance. labels Jun 29, 2023
@leonardehrenfried

Copy link
Copy Markdown
Member

This looks like a solid effort and I believe with Thomas' recent PR (accessEgressPenalty) we can remove the VehicleToStopHeuristics (subject to a bit of experimentation).

Since we now have a handful of properties to configure for access/egress, I think we should have a new JSON object in the config:

{
  "accessEgress": {
    "maximumDuration": "2h",
    "maximumDurationPerMode" : {}
    "maximumStops": 1000
    "penalty": ...
  }
}

What do you think about that?

@leonardehrenfried
leonardehrenfried self-requested a review June 29, 2023 13:15
@vesameskanen

Copy link
Copy Markdown
Contributor Author

I agree.

I noticed that flex routing uses separate values for access/egress walking. Would it also benefit from the new options and more control?

@leonardehrenfried

Copy link
Copy Markdown
Member

I'm not sure really. I need to investigate some more.

@leonardehrenfried

Copy link
Copy Markdown
Member

Is this ready for review or do you want to experiment with it some more?

@vesameskanen

Copy link
Copy Markdown
Contributor Author

I am still experimenting with it. There is something unexpected going on: commit f600e26 changed itinerary search time from 2.7s to 8.9s in one of our services using complex GTFS data and long access/egress routing time (8h).

I am currently searching which configuration setting is related to the slowdown.

@codecov

codecov Bot commented Jul 3, 2023

Copy link
Copy Markdown

Codecov Report

Patch coverage: 94.87% and project coverage change: +0.03% 🎉

Comparison is base (1baa283) 66.08% compared to head (46fd26b) 66.11%.
Report is 1 commits behind head on dev-2.x.

Additional details and impacted files
@@              Coverage Diff              @@
##             dev-2.x    #5214      +/-   ##
=============================================
+ Coverage      66.08%   66.11%   +0.03%     
- Complexity     14942    14966      +24     
=============================================
  Files           1780     1782       +2     
  Lines          68969    69039      +70     
  Branches        7287     7292       +5     
=============================================
+ Hits           45576    45644      +68     
- Misses         20905    20910       +5     
+ Partials        2488     2485       -3     
Files Changed Coverage Δ
...tripplanner/ext/traveltime/TravelTimeResource.java 0.00% <0.00%> (ø)
.../graph_builder/module/DirectTransferGenerator.java 91.17% <ø> (ø)
...aptoradapter/router/street/AccessEgressRouter.java 100.00% <ø> (ø)
...radapter/router/street/FlexAccessEgressRouter.java 70.58% <50.00%> (ø)
...pi/request/preference/AccessEgressPreferences.java 91.83% <91.83%> (ø)
...i/mapping/preferences/StreetPreferencesMapper.java 88.88% <100.00%> (+1.38%) ⬆️
...lanner/ext/transmodelapi/model/plan/TripQuery.java 99.63% <100.00%> (ø)
...anner/astar/strategy/MaxCountSkipEdgeStrategy.java 100.00% <100.00%> (ø)
...planner/graph_builder/module/NearbyStopFinder.java 86.44% <100.00%> (+0.59%) ⬆️
.../algorithm/raptoradapter/router/TransitRouter.java 76.11% <100.00%> (+0.36%) ⬆️
... and 3 more

... and 4 files with indirect coverage changes

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

@vesameskanen vesameskanen changed the title WIP: safety limit for access/egress routing Safety limit for access/egress routing Jul 5, 2023
@vesameskanen vesameskanen changed the title Safety limit for access/egress routing Stop count limit for access/egress routing and new accessEgress configuration object Jul 5, 2023
Comment thread src/main/java/org/opentripplanner/graph_builder/module/NearbyStopFinder.java Outdated
@leonardehrenfried

Copy link
Copy Markdown
Member

I've taken the liberty to improve the generics and add a test here: leonardehrenfried@04f9616

If you are happy with this code, can you pull it into this branch.

@leonardehrenfried
leonardehrenfried requested review from t2gran and vpaturet and removed request for vpaturet July 11, 2023 08:29
@t2gran t2gran added this to the 2.4 (next release) milestone Jul 18, 2023
@t2gran

t2gran commented Jul 18, 2023

Copy link
Copy Markdown
Member

The new strategy does not qualify stops against search parameters, but that seems to have only a little effect. For example, if 300 nearest stops provide no bike-compatible trips, then bike + transit itineraries are likely to be poor.

I think this is a good thing - it make the system more deterministic and more easy to reason about. If changing a parameter yields an unexpected different result (because of access/egress pruning) understanding the system will be difficult. It is important to remember this is a performance tuning optimisation and should be kept "as simple as possible".

Comment thread docs/OTP2-MigrationGuide.md Outdated
@leonardehrenfried leonardehrenfried added the +Config Change This PR might require the configuration to be updated. label Jul 20, 2023
@leonardehrenfried

Copy link
Copy Markdown
Member

You still have merge conflicts and have to merge the very latest version of dev-2.x.

@vesameskanen

vesameskanen commented Aug 22, 2023

Copy link
Copy Markdown
Contributor Author

One can see stop count conveniently by creating a logback-include-extensions.xml file in otp root:

<included> <logger name="org.opentripplanner.routing.algorithm.raptoradapter.router.street.AccessEgressRouter" level="debug" /> </included>

@t2gran

t2gran commented Aug 22, 2023

Copy link
Copy Markdown
Member

One can see stop count conveniently by creating a logback-include-extensions.xml file in otp root:

<included> <logger name="org.opentripplanner.routing.algorithm.raptoradapter.router.street.AccessEgressRouter" level="debug" /> </included>

You may also check this box when starting OTP with the interactive lancher:
Skjermbilde 2023-08-22 kl  20 22 13

@vesameskanen
vesameskanen merged commit a24a6af into opentripplanner:dev-2.x Aug 23, 2023
@vesameskanen
vesameskanen deleted the max-nearby-stops branch August 23, 2023 04:49
t2gran pushed a commit that referenced this pull request Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

+Config Change This PR might require the configuration to be updated. !Improvement A functional improvement or micro feature !Optimization The feature is to improve performance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants