Skip to content

πŸš‡ Route planner for all stages of the Singapore MRT/LRT rail network (1987-2040+).

License

Apache-2.0, Unknown licenses found

Licenses found

Apache-2.0
LICENSE
Unknown
LICENSE-DATASET.md
Notifications You must be signed in to change notification settings

elliotwutingfeng/railrailrail

railrailrail

Train

Route planner for all stages of the Singapore MRT/LRT rail network (1987-2040+).

Python

Apache-2.0 license SODL-1.0 License

railrailrail finds fastest routes between any 2 stations on the Singapore MRT/LRT rail network. It supports all known past and future stages of the network (1987-2040+).

Features

  • Preset configurations for all known stages of the MRT/LRT network, in the TOML file format.
  • Customize every station-to-station travel time, interchange transfer time, and station dwell time, by editing the TOML config file directly.
  • Optionally enable walking routes between nearby stations.
  • Find the circuity ratio of a fastest route. The circuity ratio is the total distance travelled divided by the great-circle distance between origin station and destination station. Smaller circuity ratio implies a more direct and efficient route.

Requirements

Works natively on a POSIX/UNIX-like environment like Linux/macOS. Windows users should use the Windows Subsystem for Linux.

Setup

Install dependencies. Then generate a coordinates file (station_coordinates.csv), and network config files for all stages. These files will be saved to the config/ folder.

make install
make generate_config

Basic Usage

Now lets find the fastest route between Pasir Ris and Hougang in 2003.

poetry run python railrailrail/cli.py route --network-file config/network_nel.toml --coordinates-file config/station_coordinates.csv --start EW1 --end NE14

# Start at EW1 Pasir Ris
# Board train towards terminus EW27 Boon Lay
# Alight at EW13 City Hall
# Transfer to NS25 City Hall
# Board train towards terminus NS1 Jurong East
# Alight at NS24 Dhoby Ghaut
# Transfer to NE6 Dhoby Ghaut
# Board train towards terminus NE17 Punggol
# Alight at NE14 Hougang
# Total duration: 61 minutes 28 seconds
# Approximate path distance: 28.1 km, Haversine distance: 6.3 km, Circuity ratio: 4.4

In 2024.

poetry run python railrailrail/cli.py route --network-file config/network_tel_4.toml --coordinates-file config/station_coordinates.csv --start EW1 --end NE14

# Start at EW1 Pasir Ris
# Board train towards terminus EW33 Tuas Link
# Alight at EW8 Paya Lebar
# Transfer to CC9 Paya Lebar
# Board train towards terminus CC29 HarbourFront
# Alight at CC13 Serangoon
# Transfer to NE12 Serangoon
# Board train towards terminus NE17 Punggol
# Alight at NE14 Hougang
# Total duration: 49 minutes 26 seconds
# Approximate path distance: 19.6 km, Haversine distance: 6.3 km, Circuity ratio: 3.1

In 2030.

poetry run python railrailrail/cli.py route --network-file config/network_crl_1.toml --coordinates-file config/station_coordinates.csv --start EW1 --end NE14

# Start at EW1 Pasir Ris
# Transfer to CR5 Pasir Ris
# Board train towards terminus CR13 Bright Hill
# Alight at CR8 Hougang
# Transfer to NE14 Hougang
# Total duration: 13 minutes 41 seconds
# Approximate path distance: 7.3 km, Haversine distance: 6.3 km, Circuity ratio: 1.1

Customization

The generated network config files (ending with .toml) and the station coordinates file (station_coordinates.csv) in the config folder can be customized. See CONFIG.md.

Commands

See COMMANDS.md.

Misc

See MISC.md.

Analysis

A Jupyter notebook for analysing the route planner output is available at analysis.ipynb.

License

Source code is under Apache-2.0. Most of the datasets are under the Singapore Open Data Licence version 1.0.

See LICENSE and LICENSE-DATASET.md.

References