-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Observed behavior
For large deployments of OTP the travel search can be slow. For deployments of the size of Germany or the combined Nordic countries(Finland, Sweden, Denmark and Norway) it takes up to 7-10 seconds in some cases on a high compute server.
One of the reasons is that OTP will search local transit networks even fare from the origin and destination, even if we with high probability could exclude the local stops or local routes in these areas from the search. For example, if we search from Oslo to Stockholm, there should be no reason to explore local transit in other cities like Malmo or Trondheim.
Solution outline
We can divide the routes into to bags:
- local routes - Used to get from the origin to all places nearby where you can board all relevant long distance route. And like wise get from a long-distance-route to the destination.
- long distance routes - All routes used to travel fare, plus local traffic routes regularly used to connect between long distance routes.
To find the local routes we use a bounding box around the origin and destination. Then we use the bounding box for each route to find all routes overlapping with either the origin or destination. This can be optimized to be very fast.
Now we can merge the set of local routes and long distance routes and do the search with these routes as input.
Variations
Finding a good set of "long-distance-routes" by letting the algorithm learn
If we run a normal search with all routes in parallel in the background we can update the set of long-distance-routes if we find paths containing routes not in the set of routes used by the optimized search. The set of long-distance-routes should be shared between OTP instances (distributed cache or db).
A disruption in the traffic forces the traveler to use local transit network .
For example when a long distance transit hub is closed temporarily it might become important to use local transit to travel around the hub. By letting the algorithm learn (se above) it quickly will learn witch routes to use.
Tuning the search and serve all optimal paths
If we can switch to an asynchronous routing call, then we can restrict the routes in the fast search to target a few results, then when the "full" search return we can send all additional paths to the client.
Using stops as well
This can be implemented using stops instead of routes, but it is not likely to perform as good. One benefit however, is that by including not only the long distance stops, but the stops you can transfer too as well, is that we automatically would include all transfers with local traffic between to long-distance-routes.
We can also strip away all stops from a long-distance-route witch do not have a connection to another long-distance-route.
We can filter on only routes or stops or both.
Version of OTP used (exact commit hash or JAR name)
OTP2.1