Skip to content

A search algorithm to find optimal routes for trains and scheduled transport

Notifications You must be signed in to change notification settings

aaryak-shah/route-finder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Route Finder

Optimal Train Route Generator Using Modified A* Search

Demo


The Problem

A standard node-to-node travel problem can easily be solved by means of a simple seacrh algorithm, like BFS, A* or Branch & Bound. Such a solution assumes that the agent can freely depart from any node at any time.

However for a system like a train network, departures occur on a scheduled basis. The agent may only leave a node at given times described by the schedule table. This means that the cumulative cost at each node is not just the sum of path costs, but also needs to consider the time an agent spends waiting at each node.

The Solution

We can slightly modify the evaluation function f(n) = h(n) + g(n) in A* to include a third term w(n) which denotes the total waiting duration of the agent till that node. Practically this is implemented by adding only the previous wait time to the g(n) term at each step.

Project Structure

Read docs for additional information. Refer to data file to understand dummy data

This project was built and tested using python 3.7.3 without any additional requirements

project
├── main.py (driver code / entry point)
├── data.py (demo data file)
├── models.py (Node class definition)
├── ai.py (AI algorithm)
└── util.py (utility functions)

Try It Out

Clone this repository and navigate to the project directory

Windows> cd path\to\project

linux$ cd /path/to/project/

Ensure python is installed on your system. Then run

Windows> python main.py

linux$ python3 main.py

About

A search algorithm to find optimal routes for trains and scheduled transport

Topics

Resources

Stars

Watchers

Forks

Languages