Docs / Scheduling & dispatch / Route optimization

Route optimization

How the nearest-neighbor + 2-opt optimizer works, when to use it, and what it does not do yet.

The route optimizer reorders a tech's assigned visits to minimize total drive distance. It is not a routing engine with time windows or vehicle constraints (those are coming Q4 with VROOM integration). It is a fast, pragmatic "run this tech's day in a better order" button.

How to use it

  1. On the dispatcher, find the tech whose day you want to optimize.
  2. Click "Optimize" next to their name (only shows when they have 2+ visits).
  3. A toast appears: "Optimized. Saved 3.4 km." The chip order on the screen re-sequences.
  4. If the result is not better than what you had, the toast will say "No improvement — keeping current order."

What the algorithm does

  1. Loads all assigned visits for that tech on that day.
  2. Computes Haversine (great-circle) distance between every pair of properties.
  3. Starts from the current first visit, picks the nearest unvisited next, repeats (nearest-neighbor).
  4. Applies 2-opt: iterates through every pair (i,j) and reverses the segment if it shrinks total distance. Repeats until stable or 100 iterations.
  5. Writes the new order to visits.sequence_in_route on each visit.
Haversine distance is the straight-line distance between two points on the globe. It is usually 10-20% shorter than actual driving distance, but the relative ranking is usually correct. For higher accuracy, the Q4 VROOM integration will use OSRM (actual driving distance) as the matrix.

When to use it vs not

💡
Run the optimizer every morning before your techs hit the road. It takes 50ms. Worst case it changes nothing; best case you shave 15% off your drive time for the day.
The optimizer does NOT know about time windows. If a client said "please come after 2pm," the optimizer may put them first. For now, set their visit time manually and let the optimizer re-sequence only the visits with no hard time constraints. Time-window aware optimization ships with Q4's VROOM integration.
Properties without lat/lng (imported clients with partial address data, or addresses that failed geocoding) are treated as 0 distance, which can mangle the order. The optimizer will flag affected visits. Fix the addresses on those clients.

Limits you should know

  • No multi-day optimization — the optimizer considers one tech's one day at a time.
  • No cross-tech reassignment — it does not move a visit from Tech A to Tech B if that would be faster.
  • No skill matching — it assumes any tech can do any visit.

Was this article helpful?

Contact support