Quinn Webster, Joe Bresee, Scott Garneau
This project explores how to place bus stops for a transit route in a way that improves rider access without making the stop spacing unrealistic. The goal is to find a stop layout that balances coverage, walking distance, transfer opportunities, and proximity to useful destinations.
The implementation uses a genetic algorithm. It starts from candidate stop locations along a route, evaluates each candidate layout with a weighted fitness function, and then iteratively evolves better stop sets over multiple generations.
For a chosen transit route, the script aims to place stops that:
- improve access for nearby residents and equity-weighted populations
- keep stops reasonably spaced along the route
- support transfers to other routes
- stay close to important destinations such as schools, clinics, supermarkets, and community facilities
The result is a set of stop locations that can be viewed as an interactive map.
- Load route and transit data from the project’s GTFS-style text files.
- Generate initial candidate stop layouts along the route.
- Score each layout using a custom fitness function based on several weighted criteria.
- Apply genetic algorithm steps:
- select strong parent layouts
- combine them through crossover
- mutate some children to explore new stop positions
- Keep the best-performing layout and save it as an HTML map.
code/ga.py— main genetic algorithm workflowcode/weight_function.py— fitness scoring and spatial evaluation logiccode/config.py— GA parameters and route settingscode/busRoutes.py— route and stop generation helperscode/evenlySpacedBusStops.py— candidate stop generation logiccode/plot_actual_stops.pyandcode/best_bus_stops.html— map-related output examples
From the project root, install the required Python packages:
pip install -r requirements.txtIf you run into missing geospatial packages, install them as well:
pip install geopandas osmnx shapelyThe script expects to be run from the code directory because it reads data files relative to that location:
cd code
python ga.pyThis will print generation-by-generation progress and save the best result to:
code/best_bus_stops.html- The current configuration targets route 95 by default. You can change this in
code/config.py. - The fitness function is intentionally weighted and can be adjusted depending on what matters most for the route being studied.