On-Demand Transit (GTFS-Flex)
1. Overview
Many transit agencies operate demand-responsive or microtransit services—such as dial-a-ride, curb-to-curb shuttles, or deviated fixed routes—modeled using the GTFS-Flex specification. Instead of fixed stop-to-stop timetables, GTFS-Flex defines polygonal service zones (locations.geojson), booking rules, operating time windows (start_pickup_drop_off_window / end_pickup_drop_off_window), and zone-to-zone travel rules (stop_times.txt).
In BAMBAM, a GTFS-Flex trip allows a traveler to walk to a pickup location within an active flex zone, board an on-demand vehicle that routes over the drivable road network within permitted pickup/drop-off zone pairs, and alight to walk to their final destination.
2. Setup
1. Import GTFS-Flex Feeds (bambam-gtfs-flex)
After building your road network (e.g., denver_buf/), run bambam-gtfs-flex import on a directory containing GTFS-Flex .zip archives for a specific service date (YYYYMMDD):
./rust/target/release/bambam-gtfs-flex import \
denver_buf/gtfs \
denver_buf/flex \
20250901
This extracts all GTFS-Flex zones, operating windows, and zone-pair relations active on 20250901 and writes them to denver_buf/flex/:
gtfs-flex-zones.csv.gzgtfs-flex-geometries.txt.gzgtfs-flex-relations.csv.gzgtfs-flex-metadata.json
2. Inject GTFS-Flex into bambam.toml (bambam_util gtfs-flex-config-app)
Use bambam_util gtfs-flex-config-app to automatically augment denver_buf/bambam.toml with the gtfs-flex mode and write denver_buf/bambam-gtfs-flex.toml:
./rust/target/release/bambam_util gtfs-flex-config-app \
--base-file denver_buf/bambam.toml \
--out-file denver_buf/bambam-gtfs-flex.toml \
--flex-directory denver_buf/flex \
--start-time "2025-09-01T08:00:00" \
--graph-edge-list 2 \
--map-edge-list 2 \
--gtfs-flex-edge-list 2 \
--overwrite
Here, --graph-edge-list 2, --map-edge-list 2, and --gtfs-flex-edge-list 2 instruct BAMBAM to attach the gtfs-flex service to edge list index 2 (the drive road network, since on-demand microtransit vehicles travel on drivable streets).
3. Run BAMBAM
cd denver_buf
../rust/target/release/bambam \
--config-file bambam-gtfs-flex.toml \
--query-file ../query/denver_extent.json
(See script/bambam_gtfs_flex_test.sh for a complete self-contained example script.)
3. What Happens
- Automated Configuration Injection (
gtfs-flex-config-app):- Appends a fourth edge list (
gtfs-flex) to[graph]and[mapping]backed by thedrivenetwork topology and geometries. - Adds
"gtfs-flex"to the[label]modes and updates allmultimodaltraversal and constraint models. - Adds a
[[search]]block forgtfs-flexcombining thedrivespeed/time traversal models with thegtfs-flexzone traversal and departure-frontier constraint models. - Injects the trip
start_time(2025-09-01T08:00:00) and adds thegtfs-flexmode constraints (allowingwalk+gtfs-flexwith a 0.5-mile walk limit on first/last legs and a 40-minute total time budget).
- Appends a fourth edge list (
- Zone-Constrained On-Demand Routing:
- During the search, a traveler can transition onto the
gtfs-flexedge list at vertices inside a flex zone whose pickup window is active atstart_time. - Once boarded in a pickup zone, the
gtfs-flextraversal and constraint models track the active zone pair (gtfs-flex-relations.csv.gz), applying any boarding wait times (prior_notice_duration_min/ zone delays) and restricting vehicle movement and alighting to valid drop-off zones within the service’s operating rules.
- During the search, a traveler can transition onto the
- Output Aggregation:
- Destinations reachable within 10, 20, 30, and 40 minutes via
gtfs-flexare written alongsidewalk,bike, anddriveinresult.csvandresult.json.
- Destinations reachable within 10, 20, 30, and 40 minutes via