name: route-optimization
description: Builds and validates a multi-stop route plan from a list of locations, time windows, vehicle capacity, and driver constraints, then explains why the solver's answer is or is not trustworthy. Use when planning deliveries, service visits, or field work, or when a route plan looks wrong.
license: MIT
metadata:
author: community-list
version: "1.0.0"
created: "2026-11-22"
Route Optimization
Optimisation without validation produces confident nonsense. This skill defines the problem,
solves it, then checks the answer against reality.
When to use
- Planning daily deliveries or service visits with more than ~8 stops.
- Comparing a proposed plan against the current manual route.
- Diagnosing a plan that assigns an impossible sequence.
- Adding time windows or capacity to an existing plan.
Workflow
1. Define the problem completely
A route problem is under-specified until all of these are answered:
| Element |
Question |
| Depot |
Where does each route start and end? |
| Stops |
Coordinates, service duration, demand |
| Vehicles |
How many, capacity per dimension, fixed and per-km cost |
| Time windows |
Per stop; hard or soft? |
| Drivers |
Shift start/end, mandatory breaks, max driving hours |
| Travel model |
Straight-line, road network, or a traffic-aware matrix |
| Objective |
Minimise distance, time, cost, or lateness? In what priority? |
| Constraints |
One-way streets, access restrictions, vehicle height/weight, customer preferences |
If any of these is missing, state the assumption explicitly and mark the plan provisional.
2. Get a travel-time matrix, not distances
Use a routing provider's matrix for the actual road network. Straight-line distance
underestimates travel by 30–60% in cities and produces plans that are impossible to drive.
Cache the matrix. A 200-stop problem is 40,000 pairs; recomputing per solver iteration is slow
and expensive.
3. Choose the solver by size
| Stops |
Approach |
| ≤ 10 |
Exact (brute force or dynamic programming) |
| 11–50 |
Heuristic: nearest neighbour + 2-opt, or OR-Tools with a time limit |
| 51–500 |
OR-Tools with guided local search, time-limited |
| > 500 |
Cluster first (geographic sectors), then solve per cluster |
Always report the solver's gap or whether it hit the time limit. "Optimal" is a claim that
requires proof.
4. Model the constraints that actually bind
- Time windows: hard windows produce infeasible problems quickly. Report infeasibility and
the minimum relaxation needed (which window, by how many minutes) rather than silently
dropping stops.
- Capacity: track every dimension (weight, volume, count), not just one.
- Driving hours: insert breaks and enforce daily limits.
- Service time: include it; a 15-minute stop × 40 stops is 10 hours.
5. Validate the output against the physical world
Before presenting a plan:
- Every stop appears exactly once.
- Sequence respects every time window and break.
- Capacity is not exceeded on any leg.
- Total driving time is within legal limits.
- No leg is implausibly fast (implies a bad matrix entry).
- Compare against the naive baseline: current manual route, or nearest-neighbour. Report the
improvement as a percentage, not an absolute claim.
6. Present with the assumptions
A route plan is only as good as its inputs. State: matrix source and timestamp, traffic model,
assumed service times, and which constraints were relaxed.
Rules
- Never present a plan as "optimal" without a proven optimality gap of zero.
- Never drop a stop to make the problem feasible; report infeasibility.
- Never use straight-line distance for a plan that will actually be driven, unless the user
explicitly accepts the approximation.
- Never average coordinates for a multi-stop location; use a real access point.
- Respect provider terms for matrix and geocoding usage.
Output format
# Route plan: <date> – <fleet>
## Assumptions
depot, matrix source and time, traffic model, service times, objective and priority
## Result
| Route | Vehicle | Stops | Distance | Driving | Service | Window violations |
|-------|---------|-------|----------|---------|---------|-------------------|
## Sequence
Route 1: depot → stop 14 (08:05–08:20) → stop 3 (08:41–08:56) → ... → depot (17:10)
## Validation
- all stops assigned: yes
- capacity respected: yes
- windows respected: yes, 0 violations
- driving hours within limit: yes
- improvement vs baseline: −18% distance, −11% time
## Not satisfied / relaxed
- <constraint> — reason and impact
Error handling
| Condition |
Action |
| Problem is infeasible |
Report which constraint set conflicts, and the smallest relaxation that makes it feasible |
| Matrix provider rate-limited |
Use cached entries; report coverage; do not substitute straight-line silently |
| Solver hits its time limit |
Report the gap and the best solution found; label it "not proven optimal" |
| Stop coordinates are low precision |
Flag them; a city-centroid stop invalidates the leg times |
Example
Input: 62 deliveries, 4 vans, 08:00–17:00 windows, 20-minute service, London.
Output: a 4-route plan, 0 window violations, −18% distance versus the manual route, a note
that two stops are only city-precision and may add 10 minutes each, and the exact matrix
timestamp used.
1---2name: route-optimization3description: Builds and validates a multi-stop route plan from a list of locations, time windows, vehicle capacity, and driver constraints, then explains why the solver's an4---5---6name: route-optimization7description: Builds and validates a multi-stop route plan from a list of locations, time windows, vehicle capacity, and driver constraints, then explains why the solver's answer is or is not trustworthy. Use when planning deliveries, service visits, or field work, or when a route plan looks wrong.8license: MIT9metadata:10 author: community-list11 version: "1.0.0"12 created: "2026-11-22"13---1415# Route Optimization1617Optimisation without validation produces confident nonsense. This skill defines the problem,18solves it, then checks the answer against reality.1920## When to use2122- Planning daily deliveries or service visits with more than ~8 stops.23- Comparing a proposed plan against the current manual route.24- Diagnosing a plan that assigns an impossible sequence.25- Adding time windows or capacity to an existing plan.2627## Workflow2829### 1. Define the problem completely3031A route problem is under-specified until all of these are answered:3233| Element | Question |34|---------|----------|35| Depot | Where does each route start and end? |36| Stops | Coordinates, service duration, demand |37| Vehicles | How many, capacity per dimension, fixed and per-km cost |38| Time windows | Per stop; hard or soft? |39| Drivers | Shift start/end, mandatory breaks, max driving hours |40| Travel model | Straight-line, road network, or a traffic-aware matrix |41| Objective | Minimise distance, time, cost, or lateness? In what priority? |42| Constraints | One-way streets, access restrictions, vehicle height/weight, customer preferences |4344If any of these is missing, state the assumption explicitly and mark the plan provisional.4546### 2. Get a travel-time matrix, not distances4748Use a routing provider's matrix for the actual road network. Straight-line distance49underestimates travel by 30–60% in cities and produces plans that are impossible to drive.5051Cache the matrix. A 200-stop problem is 40,000 pairs; recomputing per solver iteration is slow52and expensive.5354### 3. Choose the solver by size5556| Stops | Approach |57|-------|----------|58| ≤ 10 | Exact (brute force or dynamic programming) |59| 11–50 | Heuristic: nearest neighbour + 2-opt, or OR-Tools with a time limit |60| 51–500 | OR-Tools with guided local search, time-limited |61| > 500 | Cluster first (geographic sectors), then solve per cluster |6263Always report the solver's gap or whether it hit the time limit. "Optimal" is a claim that64requires proof.6566### 4. Model the constraints that actually bind6768- **Time windows:** hard windows produce infeasible problems quickly. Report infeasibility and69 the minimum relaxation needed (which window, by how many minutes) rather than silently70 dropping stops.71- **Capacity:** track every dimension (weight, volume, count), not just one.72- **Driving hours:** insert breaks and enforce daily limits.73- **Service time:** include it; a 15-minute stop × 40 stops is 10 hours.7475### 5. Validate the output against the physical world7677Before presenting a plan:7879- Every stop appears exactly once.80- Sequence respects every time window and break.81- Capacity is not exceeded on any leg.82- Total driving time is within legal limits.83- No leg is implausibly fast (implies a bad matrix entry).84- Compare against the naive baseline: current manual route, or nearest-neighbour. Report the85 improvement as a percentage, not an absolute claim.8687### 6. Present with the assumptions8889A route plan is only as good as its inputs. State: matrix source and timestamp, traffic model,90assumed service times, and which constraints were relaxed.9192## Rules9394- Never present a plan as "optimal" without a proven optimality gap of zero.95- Never drop a stop to make the problem feasible; report infeasibility.96- Never use straight-line distance for a plan that will actually be driven, unless the user97 explicitly accepts the approximation.98- Never average coordinates for a multi-stop location; use a real access point.99- Respect provider terms for matrix and geocoding usage.100101## Output format102103```markdown104# Route plan: <date> – <fleet>105106## Assumptions107depot, matrix source and time, traffic model, service times, objective and priority108109## Result110| Route | Vehicle | Stops | Distance | Driving | Service | Window violations |111|-------|---------|-------|----------|---------|---------|-------------------|112113## Sequence114Route 1: depot → stop 14 (08:05–08:20) → stop 3 (08:41–08:56) → ... → depot (17:10)115116## Validation117- all stops assigned: yes118- capacity respected: yes119- windows respected: yes, 0 violations120- driving hours within limit: yes121- improvement vs baseline: −18% distance, −11% time122123## Not satisfied / relaxed124- <constraint> — reason and impact125```126127## Error handling128129| Condition | Action |130|-----------|--------|131| Problem is infeasible | Report which constraint set conflicts, and the smallest relaxation that makes it feasible |132| Matrix provider rate-limited | Use cached entries; report coverage; do not substitute straight-line silently |133| Solver hits its time limit | Report the gap and the best solution found; label it "not proven optimal" |134| Stop coordinates are low precision | Flag them; a city-centroid stop invalidates the leg times |135136## Example137138**Input:** 62 deliveries, 4 vans, 08:00–17:00 windows, 20-minute service, London.139**Output:** a 4-route plan, 0 window violations, −18% distance versus the manual route, a note140that two stops are only city-precision and may add 10 minutes each, and the exact matrix141timestamp used.