for every formula, worked out with the numbers from the run in progress, and the code behind it.
The cities
Two conceptual street networks, loosely modeled on real places; locations are approximate. Blocks are finest in the center and coarser outward, with arterials every mile. Water can only be crossed on bridges and tunnels, and freeways are the fastest roads overnight but slow the most at the peaks.
Portland, OR (20 × 15 miles): the Willamette splits east from west and the Columbia forms the north edge; sparse, slow West Hills streets; I-5, I-84, I-205, US-26, OR-217 and I-405; three garages.
New York City (15 × 30 miles): the five boroughs, with Manhattan's streets the slowest and expressways peaking hardest; the Hudson, Harlem and East rivers, the bays and the Narrows crossed only at the East River and Harlem River bridges, RFK, Whitestone, Throgs Neck, Verrazzano, the Queens-Midtown and Battery tunnels; FDR, Henry Hudson, Deegan, I-95, Bruckner, BQE, LIE, Grand Central, Van Wyck, Belt and West Shore; four borough garages. New Jersey is outside the service area.
Demand
Riders make round trips for dialysis, day programs, medical visits, work, school and shopping, timed by purpose. Destinations are the named hospitals, employers, colleges, high schools and malls, or anywhere in proportion to activity, and nearer ones are likelier.
What every decision minimizes
One cost, in minutes of vehicle driving: driving time, plus weighted displacement (promised time minus requested time), extra ride time beyond the direct trip, and violation minutes (past a pickup window, over a max ride, past a shift end). Denied trips add a fixed amount when denials are allowed. The weights come from Scheduling priorities.
Insertion, the basic move
To place a trip, the scheduler tries its pickup and drop-off in every possible position on every vehicle's remaining itinerary, checks seats, windows and ride limits, and picks the spot that adds the least cost. Both optimizers below are built from this move.
Same day: rolling horizon
- Every scheduling cycle (2 minutes by default), new requests are inserted where they add the least cost, sometimes by diverting a moving vehicle at its next intersection. The rider is promised a pickup time at once.
- The scheduler then re-solves everything not yet picked up. In a short burst of the adaptive search described below (8 rounds), it pulls groups of trips out of the plan and puts them back wherever the total cost is now lowest. A change is kept only if it lowers total cost.
- Promised windows are hard limits during this reshuffling, so a rider's pickup can move between vehicles but never outside the time they were promised.
- The plan only ever covers what is known. As the clock moves and requests arrive, the horizon rolls forward and the plan is re-solved again. Adding or removing a vehicle triggers a longer burst.
- In the 1- and 2-hour regimes, new bookings are held briefly and placed together at each batch boundary using regret insertion (below), so the hardest-to-fit trips claim their slots first.
Overnight: regret insertion + adaptive search
- Four starting schedules. One inserts trips in order of requested time. Three use regret insertion within 30-, 45- and 60-minute batches. A trip's regret is how much worse its second- and third-best placements are than its best. High-regret trips have few good options, so they are placed first, before easier trips take their slots. The cheapest of the four becomes the starting point.
- Destroy and repair. Adaptive large neighborhood search (ALNS) then runs hundreds of rounds. Each round pulls 2 to 10 trips out of the schedule and reinserts them. Trips are pulled at random, as a cluster of trips close in time and place, or as the trips costing the most where they sit. They go back in greedily or by regret.
- Adaptive. Each pull-and-reinsert method earns credit when it produces a better schedule, and successful methods are chosen more often as the search goes on.
- Avoiding dead ends. Early on the search sometimes accepts a slightly worse schedule, a technique called simulated annealing, so it can climb out of a plan that no single change improves. That tolerance shrinks to nothing by the end, and the best schedule found is kept.
- Timing and promises. Pickups are held later where that keeps riders from waiting onboard, then every rider is promised the planned pickup time. Effort sets the number of rounds: 250, 800 or 2,000.
Traffic
Both schedulers know the normal pattern: how much slower each road type is at each time of day. Vehicles drive in today's actual traffic instead. It swings above and below normal by road type in 15-minute steps, and good or bad stretches tend to persist. The Traffic today setting makes actual travel slower than normal across the board: Heavy by 15 to 20%, Severe by 35 to 45%, and a Snow day by 60%, with much less predictable traffic and 30% slower boarding. The overnight schedule is always built for normal traffic.
With learning on, the same-day scheduler watches every completed trip leg. Each cycle it fits one factor per road type (central streets, other streets, freeways) so that factor times expected minutes best matches actual minutes over recent legs. Recent legs count most, and the fit is pulled toward normal so a few odd legs can't swing it. Every travel-time estimate it then makes, for insertions, promises and re-optimization, uses those factors.
Running the day
Plans use expected travel times. Vehicles experience seeded random traffic and boarding times, so tight schedules can run late. On-time means arriving within the pickup window around the promised time. Day 2 takes every Day 1 request as a reservation closed at 11:59 pm, builds the full schedule overnight, then plays the day under the same traffic.