From chaotic backtracking to clean neighborhood sweeps
A vehicle-routing optimizer for multi-day delivery across Montreal, built on Google OR-Tools, with constraints that encode how good drivers actually work.
The problem
Naive shortest-path routing produces plans that look optimal on paper and feel insane behind the wheel: the route zig-zags between distant neighborhoods, doubles back late in the day, and lets the "return home" leg drag afternoon stops in random directions. Drivers ignore plans like that — which means the plan is worthless.
The constraint
The optimizer had to respect three things standard VRP formulations don't give you for free:
- Finish a neighborhood before leaving it. Once a driver enters a district, all stops there get done. No coming back tomorrow for one missed address.
- The commute home doesn't count. The drive back to the depot shouldn't distort where the last deliveries of the day go.
- Days connect. Whatever is left over from Day 1 must anchor the start of Day 2, so the driver resumes where they stopped rather than from a fresh shuffle.
The solution
- Open VRP modelling. The return-to-depot arc is weighted to zero, mathematically removing the "pull" that home exerts on late-day stops.
- District contiguity. Constraint-programming indicator variables mean that entering a district commits the solver to completing it.
- Cross-day carryover. Leftover stops persist, so Day 2 inherits yesterday's active district before opening new zones.
- Graceful degradation. Where hyper-dense areas make a hard constraint infeasible, the solver relaxes it into a soft penalty rather than failing.
- An interactive Leaflet map — toggleable route layers with direction-marking animations, so the client could see the difference instead of reading distance tables.
Proof: see it, don't take my word for it
Delivered as a runnable repository: solver, mock-data generator, baseline-vs-optimized comparison script, interactive GIS map, and a print-ready PDF report. Anyone can reproduce every figure with two commands. You don't have to take my word for the maps above either: the interactive version is live — pan it, zoom it, follow a single vehicle's route. Open the live map → · Code →
Where else this applies
Field-service scheduling, last-mile delivery, sales-territory planning, technician dispatch. Any operation where "the math says drive across town twice" costs you real fuel and real morale.
If a machine you build needs an interface, a device connection, or data that has to land somewhere else, tell me what it's costing you now. You'll get an honest read on whether it's solvable, and usually something running to look at. Start here →