opentripplanner / OpenTripPlanner

An open source multi-modal trip planner
http://www.opentripplanner.org
Other
2.21k stars 1.03k forks source link

Transfer cost #3145

Closed t2gran closed 2 years ago

t2gran commented 4 years ago

Problem

In OTP2 transfers is a criteria in the McRaptor search, so adding a cost for transfers have no effect. But, after the raptor search is done some of the filters group itineraries together, with different number of transfers, and then keep the best itineraries based on cost. Hence, for the filter to account for the extra felt penalty of a transfer, the generalized-cost should incorporate a penalty for transfers.

Solution

In OTP1 the transfer cost was added during the AStar search, but it is not necessary to do so with McRaptor. Instead it is better to add the cost to the itineraries returned from the Raptor search before filtering them. This eliminate the extra work during the search (probably almost nothing, but it complicates the code) and allow for a much more sophisticated penalty function. This should be implemented using the strategy pattern - enabling swapping in different strategies. Note! The transfer cost strategy should be the same for all returned itineraries, but can be assigned based on input parameters and derived info like: minimum number of transfers, min travel distance, min travel time and all other request parameters.

It could also be tempting to add transfer cost when transferring between operators or modes, but this is not algorithmically correct and need to be added during the Raptor search.

Simple first implementation

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 30 days