Skip to content

Re-optimization (live ops)

~5 min · Recipe

Plans change mid-day: a vehicle is running late, a job is cancelled, a new order arrives, a truck breaks down. Re-optimization re-plans the remaining work while respecting what's already happened. It's the same POST — with current state added.

What you add

  • On each vehicle: lastKnownLocation — where it is right now.
  • On each task: a statuspending, in_progress, or performed — plus its current vehicleId and eta where known.
  • In configuration: optionally freezeWindowLength (minutes) to lock the immediate next stops so the driver isn't re-routed out from under their current move.
{
  "problem": {
    "fleet": [{
      "id": 1,
      "capacities": [{ "name": "parcels", "units": 40 }],
      "lastKnownLocation": [49.27500, -123.12000],
      "shifts": [{ "start": { "time": "2026-07-31T11:30:00-07:00", "location": [49.27500, -123.12000] },
                    "end":   { "time": "2026-07-31T17:00:00-07:00", "location": [49.28270, -123.11540] } }]
    }],
    "jobs": [
      { "id": 101, "deliveries": [{ "id": 1001, "location": [49.26340, -123.13830], "duration": 300, "demand": [2],
        "status": "performed", "vehicleId": 1 }] },
      { "id": 105, "deliveries": [{ "id": 1005, "location": [49.25100, -123.10100], "duration": 300, "demand": [1],
        "status": "pending" }] }
    ]
  },
  "objective": 1,
  "configuration": { "units": "metric", "freezeWindowLength": 15, "statistics": true }
}

The three common scenarios

Scenario How you express it
New job arrives Add the new job with status: pending; keep completed tasks as performed.
Job cancelled Drop it from the payload (or mark upstream); re-submit the rest.
Vehicle breakdown Remove that vehicle (or end its shift now) and re-submit — its pending tasks get reassigned.
  • Tasks marked performed are treated as done — the engine won't re-plan them.
  • in_progress tasks stay with their vehicle.
  • Set the shift start.time/location to now and the vehicle's current spot so ETAs are realistic.

Freeze what's in motion

Use freezeWindowLength so a driver mid-move isn't yanked to a new stop. It keeps the head of the schedule stable while re-optimizing the tail.

Related: How optimization works · Pickups and deliveries · Enums, limits and rules