Technical Lab · Synthetic demonstration

Single-vehicle routing with time windows

One depot, one vehicle and eight synthetic customers. The objective is travel time. A window or the capacity limit can reject the trip that looks shortest on the map.

All technical examples

Synthetic demonstration · Independent educational implementation. Not the doctoral routing study.

Visit every customer from a depot and return, without missing a delivery window or exceeding the vehicle capacity.

A shorter route that arrives after the window, or that overfills the vehicle, is not a usable plan. The constraint changes the decision, not only the picture.

See which constraint binds

Point at or tap a customer for its demand, window and arrival.

  • Route, arrows give direction
  • Delivery window
  • Service starts
Travel time is the objective. Windows and capacity decide which tours are allowed. Depot in the centre, customers A–H, and the minimum-travel route that respects the selected windows and capacity. The square is the depot. Letters are customers; small numbers give the visit order. An open dot and a dotted line mean the vehicle arrived early and waited.

Standard windows, capacity 32. The exact search visits C–B–A–H–G–F–E–D and returns to the depot. Travel time is 204 minutes and the route waits 12 minutes for windows to open. Load is 31 of 32. The objective is travel time; service time does not change the ranking of complete routes.

Solver: exact enumeration for this small teaching instance

Schedule

Times are minutes from departure. A wait means the vehicle arrived before the window opened.

Customer windows and planned arrivals
Stop Window Demand Arrival Wait
Customer A 0–150 4 98 0
Customer B 20–180 3 68 0
Customer C 40–220 5 28 12
Customer D 60–260 4 245 0
Customer E 80–300 3 217 0
Customer F 90–330 4 187 0
Customer G 70–300 5 157 0
Customer H 15–190 3 126 0

Implementation

Objective Minimise travel time back to the depot. Constraints Visit each customer once. Arrive no later than the window end. Load never exceeds capacity.

src/lib/lab/routing.ts View source on GitHub: src/lib/lab/routing.ts

A visit is rejected before it is added to the route.src/lib/lab/routing.ts
function canVisit(problem: RoutingProblem, stop: RouteStop, time: number, load: number, x: number, y: number): { start: number; travel: number } | null {
  if (load + stop.demand > problem.capacity) return null;
  const travel = travelMinutes({ x, y }, stop, problem.speed);
  const arrival = time + travel;
  if (arrival > stop.due) return null;
  return { start: Math.max(arrival, stop.ready), travel };
}

The doctoral case study is a separate, published simulation. This map does not reproduce it.