algorithm - Strategy to find your best route via Public Transportation only? -


Finding a route to the car is very easy: You collect loaded graphs on all the roads and you can use [1]. The bus route is less clear. With the bus you have to represent things like "Waiting for 10 minutes for the next bus" or "Run a block at another bus stop" and feed them in your pathping algorithm.

It is not always easy for cars too. In some cities, the only way of some roads is in the city in the morning, and in the evening there is only one way from the city on one side. Some advanced GPS know how to avoid busy routes during busy hours.

How would you represent such a time-dependent graph efficiently and find the way? There is no need for a proven optimal solution; If the traveler wanted to be on time, they would buy a car. ; -)

[1] An amazing algorithm to mention in an example because everyone has heard about it, though A * is an option for this app.

post-text "itemprop =" text ">

I am involved in the development of a public planner system for Stockholm Public Transport in Sweden. It was based on Djikstra's algorithm, but with the expiration before visiting each node in the system. Today, when reliable coordinates are available for each stop, I think that the A * algorithm will be the choice.

Data about upcoming traffic was routinely removed from many databases and our search was compiled in a large table filled with memory server cluster.

Based on a key journey for the algorithm successfully, one path was using cost function and was waiting to be multiplied by different weight. From time to time known as "krsu" in Swedish, these weighted time shows the fact that, for example, waiting time for one minute is usually equal to the time of two-minute travel in "inconvenience" .

KRESU Weight Table
  • Walking between X-2 - Stop
  • X2 - Waiting at a stop during the trip Used to be.
  • The waiting time on the first stop is weak and it can be between 0.5 and 3.
  • Data structure

    area is a designated area where you can start or end the journey. The bus stop can be an area with two stops. Many platforms can be an area with one stop for a platform. Data: Name, Stop in the area

    Stop An array with all bus stops, trains and underground stations. Note that you usually need two stops, one for each direction because it takes some time to cross the road or runs up to the other platform. Data: Name, Link, Nodes

    Links You can access a list with other stops while you are running with this stop. Data: Other stop, run on other stop

    Lines / Tour You have a number on bus and destination just starting at one stop and many on the way to the destination The stop passes. Data: number, name, destination

    nodes Normally you have a timetable with a minimum of time, when it should be at first and last stop in a tour . Every time a bus / train passes a stop, you add a new node to the array. This table can have millions of cost per day. Data: How to store array nodes array with line / travel, stop, arrival time, departure time, error margin, tour in the next node

    search Used to go there and the cost of the path data: Back-link with the previous node (if node is not envisaged), path cost (unknown for unknown)


    Comments