Improve performance of Park+Ride, Bike+Ride and Bike+Transit - #3906
Conversation
miles-grant-ibigroup
left a comment
There was a problem hiding this comment.
Have played with this and it works really well! Thank you very much
b31f2af to
75ed569
Compare
|
@hannesj has asked why I don't use the So basically a |
optionsome
left a comment
There was a problem hiding this comment.
This seems to be an improvement at least from our point of view in a sense that it leads to less driving and more transit. However, I find there are also some downsides to this pr. If I look for an itinerary to a destination which is next to a car park, before it just suggested driving to the park and walking from there to the destination. Now it just suggests to park next to the destination, take a bus that takes you away from the destination by one stop and then walking from there to the destination. I don't remember anymore if there was some configuration option somewhere to get rid of these types of suggestions.
I think these car park + walk "direct" suggestions are not supported at all anymore with this implementation. It's not something we necessarily need in our project but I think it is still something we should support.
| public final static Set<StreetMode> vehicleToStopModes = | ||
| Set.of( | ||
| StreetMode.BIKE, | ||
| StreetMode.BIKE_TO_PARK, | ||
| StreetMode.BIKE_RENTAL, | ||
| StreetMode.CAR_TO_PARK, | ||
| StreetMode.CAR_PICKUP | ||
| ); |
There was a problem hiding this comment.
Shouldn't this include SCOOTER_RENTAL?
There was a problem hiding this comment.
Yes it should. And CAR_RENTAL!
| transferMode = StreetMode.WALK; | ||
| egressMode = StreetMode.WALK; | ||
| directMode = StreetMode.CAR_TO_PARK; | ||
| directMode = null; |
There was a problem hiding this comment.
This makes it so that it's not possible to ever look for car park itineraries with no transit?
There was a problem hiding this comment.
This disables it if you use the Legacy GraphQL and REST APIs and set a mode of CAR_PARK. You can use the Transmodel API to set any direct_mode you want.
There was a problem hiding this comment.
I don't at least mind that it would no longer by possible with the legacy GraphQL API. Not sure if that should still remain a possibility for the REST API. Could we make it so that if no transit modes are specified in the query, it would enable the directMode search?
There was a problem hiding this comment.
I would prefer the existing functionality being preserved, with the directMode being set. Currently mode=BICYCLE_RENTAL returns a bicycle rental only trip. I would expect mode=CAR_PARK to behave similarly.
There was a problem hiding this comment.
I get where you're coming from but in my tests computing the direct mode CAR_PARK was often the slowest part of the entire query. It appears to try to leave the car on all stations along the way and then calculate a walking leg from there.
There was a problem hiding this comment.
I would prefer always keeping the direct mode -- regardless of transit modes being set. For now it preserves the existing functionality, is in line with how the other modes work in the rest api, and is easier to understand/document.
This currently only affects the rest api along with the legacy graphql api: an alternative option would be to instead extend either of these apis with an option to included/exclude the direct mode when planning a trip? That would both be backward-compatible, easy to explain/document and can be set as-needed.
Presumably in the new API this wouldn't be needed anymore, since the values would be explicitly set instead of using heuristics.
There was a problem hiding this comment.
Even if it's terrible for performance? In some of my tests it takes 3 times as long.
There was a problem hiding this comment.
Seemingly it also affects vehicle rental but doesn't affect the search when arriveBy=true?
There was a problem hiding this comment.
It also improves the rental performance but the arriveBy is correct, because when searching in reverse you actually want to go to the closest rental bike from the destination not the start. Am I describing this correctly, @hannesj ?
| case RAIL: | ||
| case FERRY: | ||
| case SUBWAY: | ||
| return 20; | ||
| case BUS: | ||
| return 1; | ||
| default: | ||
| return 2; |
There was a problem hiding this comment.
This scoring system is probably slightly opinionated although it does seem reasonable. Not sure if this should be made somehow configurable or not.
There was a problem hiding this comment.
What has stopped me so far from making it configurable is trying to explain it in documentation and giving it a name. If you have a suggestion, I'm very happy to hear it.
There was a problem hiding this comment.
Yeah I'm not sure. If we make it configurable, should the configuration only affect this or could/should it also be used for preference in some other context? My intuition is that the configuration should probably be limited to only affect this scope.
direct mode = null means gives you walking so you should get a walk route. You can then use the itinerary filtering to remove the ridiculous P+R route. If you tell me where you see the route I can give the a config snippet. But you're right, if you want routes that drive to the destination and park the car, this is not possible in the current Digitransit UI. You'd need to use an API where you can set the direct mode. |
I think these ridiculous itineraries happen everytime I search for a destination that is next to a car park that is relatively close to the origin. I think because we no longer do the direct search, these itineraries don't get filtered out because they are not being compared against direct result. Without the direct search, in some cases we would not get any itineraries if these ridiculous itineraries are filtered out but I think that is probably a good thing. If you have some configuration snippet for filtering these itineraries out, please let know. |
|
We do the a direct search but it's a walking one. I tried playing around in Helsinki for a bit but it wasn't easy to get one of these ridiculous routes. In fact I could not find one. Starting close to a parking lotShort trip starting close to a parking lotHere bad results are filtered out because walking is faster. |
|
And what would you want to see in such a case? |
I discussed this topic internally at out our project and I think we are not at least completely opposed to including itineraries that include just car park + walk because some people only search for a part of their journey. However, it's not really necessary that it's possible with legacy GraphQL API as soon we will move to use the new API once it's done anyway before we fully start using OTP2 in production. |
|
I forgot to mention in the last post that we will also like to use a high car reluctance value so transit is preferred over car travel. |
6e353a2 to
24b36b5
Compare
|
@optionsome I did some improvements today with @hannesj and I think we came to a good compromise solution: we calculate CAR as the direct mode (fast) and increase the car reluctance which means that you still get results even though driving all the way is almost always the fastest. Here is your example in Järvenperä: And from Järvenperä to central Helsinki you still get useful results. |
Co-authored-by: Hannes Junnila <hannes.junnila@gmail.com>
135ed2c to
c589473
Compare
optionsome
left a comment
There was a problem hiding this comment.
While testing this, I spotted #3958 but it doesn't originate from this pr so I think it can be fixed in a separate pr.






Summary
This improves the performance of P+R, B+R and B+T trip searches.
The main reason why these searches are slow is that a large number of accesses are computed and then passed to raptor. Both the access as well as the transit searches are slow as the default duration of 45 minutes leads to many stops. For example, if you do a P+R search in a city, you will most likely find all stops in the entire city. However, limiting the access search time will lead to bad results in rural regions.
There is some prior art that limits the nearby stops to the closest 5 stations: #3556
This suffers from the problem that in GTFS stations are not mandatory. It also doesn't terminate the access search which is bad for performance.
That's why I'm proposing the following.
Heuristic
We want to scale the search radius with the density of "important" stops. So in a city the access search should should be aborted relatively early as you will most likely have a dense network of useful stops.
In a rural region you want to search a bit longer.
So to compute the density of stops I'm using the the number of routes at a stop as a termination criteria. If we have found many routes of type RAIL, SUBWAY or FERRY we terminate the access search and pass the stops to raptor. If we are in a rural region where we only have bus stops, we continue searching.
Results
Using this approach leads to faster search times as well as results with less driving/cycling, which are both desirable outcomes.
Before
After
Issue
Closes #3555
Unit tests
I would love to have some advice on how to write one.
Code style
Yes.
Documentation
Javadoc added.