Inspiration

Our group has been living in Lisbon for only one month, and all of us have heard that buses aren't as reliable as other forms of transport. When we went through the challenges of this hackathon we came across a term that we didn't know but soon realized we had seen before: bus bunching. When a bus experiences an initial delay due to traffic or passenger boarding, a negative feedback loop begins. As the gap behind the lead bus widens, more passengers accumulate at upcoming stops. The lead bus spends longer boarding passengers, while the trailing bus, facing empty stops, speeds up until both buses run nose-to-tail. We realized we cannot eliminate urban traffic or human error, but we can optimize dispatch timing and mid-route scheduling so schedule instability isn't the reason someone misses a job interview or a morning commute.

What it does and how we built it

We developed RouteMaxxing, an operational decision-support workspace and simulation platform designed for transit operators across the Greater Lisbon Metropolitan Area (CARRIS, Carris Metropolitana, and MobiCascais).
Our stack consists of:

  • Frontend and Spatial Visualization: Built with React, TypeScript, and Leaflet. We implemented Geohash Level-5 and Level-6 geofencing to map vehicle telemetry, visualize live route variants, and render time-space trajectory diagrams.

  • Data Pipeline and PostGIS Storage: Filtered and structured an initial dataset of 35,000,000+ raw GPS pings down to a core set of 22,082,195 pings and 1,358,347 historical headway irregularity events by linking vehicle pings to GTFS schedule packages.

  • Three-Tiered Machine Learning Architecture: - LightGBM Regressor : Predicts continuous upcoming headway gaps (in seconds) with a Mean Absolute Error (MAE) of 191.32a (approx 3.1 min). - Gradient-Boosted Early-Warning Model (v4): Forecasts bunching across a look-ahead horizon of 5 stops for single lines and shared corridors. - Mid-Route Hold Timing Model: Evaluates when and where to insert precise mid-route holding stops (up to 90s) to restore headway symmetry before bunching cascades.

  • Counterfactual Simulator: A trace-based replay engine that evaluates "what-if" scenarios (such as terminal dispatch holding or layover buffer extensions).

The Physics Behind Our Simulator To ensure realistic counterfactual simulations, our simulator models passenger dwell feedback dynamically. The extra boarding dwell time at a stop is modeled as:

Extra Dwell Time = k x (Observed Gap - Baseline Gap)

Where k = 0.005 represents the passenger accumulation factor fitted on weekday baseline data (~0.3 seconds of added boarding time per minute of headway error).To prevent holding interventions from creating new delays, we enforce strict guardrails:

Onset Gate: Predictions trigger only while the headway gap is still > 50\% of plan (ONSET_MIN_RATIO = 0.5).

Safe Gap Constraint: Holds are clipped so a vehicle never falls within 60 seconds of the follower bus behind.

Challenges we ran into

Data access was a big issue, since only one of us had access to the google drive of the challenge and the datasets were big. Processing that data was also hard, considering that we had a bunch of GPS pings, it required efficient spatial indexing and handling missing or unlinked trip_id joins. Even though the dataset was big and had loads of data, we still only had one week of historical data to work with, that made it hard for us to actually have any solid historical data insights. Understanding how we could model the vehicle chains was complex, ensuring that if a bus is delayed on Trip 1, the delay cascades realistically to Trip 2 after accounting for layovers (60 s).

Accomplishments that we're proud of

Massive Data Scale: Successfully ingesting, filtering, and indexing over 35 million raw GPS pings across multiple transit providers (CARRIS, Carris Metropolitana, MobiCascais) into a real-time responsive web interface.
Realistic Simulation: Building a simulator well calibrated, ready to test, with some actual insights on how the logistics can get better.

What we learned

We all have learned the process of a project creation from zero. We were a bit lost in the beginning but were able to structure a cool and functional tool that has impact.

What's next for RouteMaxxing

Hearing the actual users feedback, connecting directly to real-time AVL/GTFS-RT streaming feeds from CARRIS and Carris Metropolitana to enable live dispatcher alerts. Incorporating real-time traffic accident and road hazard, creating a interface for drivers.. The sky is the limit!

Built With

Share this project:

Updates

Submission history