Article
Optimization · Autonomous Systems · ⏱ ~10 min read · Last updated: 9 July 2026

Optimal Drone Routing — The Travelling Salesman Problem Takes Flight

A delivery drone visiting 20 rooftops, an agricultural drone scanning 50 field waypoints, or an inspection drone checking 100 pylons all face the same abstract question: in what order should the stops be visited to minimise total flight distance (and therefore battery use)? This is the travelling salesman problem (TSP) — one of the most studied problems in combinatorial optimization — adapted to three dimensions, wind, and a finite battery budget.

TL;DR: Drone routing is the travelling salesman problem in 3D: finding the flight order that minimises distance and battery use across dozens to hundreds of waypoints. Since exact solutions are computationally infeasible past roughly 20-25 stops, delivery and inspection fleets rely on heuristics like nearest-neighbour and 2-opt, adapted for wind, altitude and battery limits, plus genetic algorithms for multi-drone routing.

1. Formalizing the Problem

Given n waypoints and a distance (or energy-cost) function between each pair, TSP asks for the shortest closed tour visiting every waypoint exactly once and returning to the start:

Minimise: Σ d(p_i, p_{i+1}) for i = 1..n, with p_{n+1} = p_1 Subject to: each waypoint visited exactly once (permutation) Distance metric for drones (3D + energy): d(p_i, p_j) = w1·|Δxyz| + w2·climb_energy(Δz) + w3·wind_penalty Number of distinct tours: (n-1)!/2 — grows explosively: n=10 → 181,440 tours n=20 → 6×10^16 tours

2. Why It's Hard: Complexity

TSP is NP-hard: no known algorithm solves every instance in time polynomial in n, and most researchers believe none exists (P ≠ NP conjecture). Exact methods exist but scale poorly:

3. Construction Heuristics

Fast heuristics build a reasonable starting tour, typically within 10-25% of optimal:

Nearest Neighbour: from current point, always fly to the closest unvisited waypoint. O(n²), simple, but can leave one very long "return" leg at the end. Greedy Edge: sort all edges by length, add shortest edges that don't create a sub-cycle or degree-3 vertex, until a single tour forms. O(n² log n), typically better than nearest neighbour. Christofides Algorithm: minimum spanning tree + minimum- weight perfect matching on odd-degree vertices + Eulerian shortcut. Guaranteed ≤ 1.5× optimal for metric TSP (holds for symmetric Euclidean drone distances without wind).

5. Drone-Specific Constraints

Battery Budget

Total tour energy must not exceed capacity minus reserve — this can force multi-trip routing or a return-to-charge waypoint mid-tour (open TSP with recharging depots).

Wind Asymmetry

Ground speed (and hence energy cost) differs flying with vs. against wind — the distance matrix becomes asymmetric (ATSP), requiring different solvers than symmetric TSP.

Altitude Changes

Climbing costs disproportionately more energy than descending or level flight — the cost function must weight Δz asymmetrically, not just Euclidean 3D distance.

No-Fly Zones

Airspace restrictions turn direct point-to-point legs into shortest-path-around-obstacle problems, usually solved with visibility graphs or A* before TSP ordering is applied.

6. Genetic Algorithms for Fleet Routing

For multi-drone fleets splitting waypoints among vehicles (the vehicle routing problem, VRP — a generalisation of TSP), genetic algorithms and swarm methods scale better than exact solvers:

Chromosome: permutation of waypoints + drone-assignment split points Fitness: 1 / (total fleet energy + max(single-drone time) penalty for load imbalance) Crossover: Order Crossover (OX) — preserves relative order of waypoints from both parents without duplicating stops Mutation: swap two waypoints, or reverse a sub-segment (2-opt-style mutation) Typical settings: population 100-300, 200-500 generations, elitism keeping top 5-10%

7. JavaScript 2-opt Route Optimizer

// 2-opt local search for drone waypoint tour (Euclidean 3D distance)
function dist(a, b) {
  return Math.hypot(a.x-b.x, a.y-b.y, (a.z-b.z)*1.6); // climb weighted higher
}

function tourLength(tour, pts) {
  let total = 0;
  for (let i = 0; i < tour.length; i++) {
    total += dist(pts[tour[i]], pts[tour[(i+1) % tour.length]]);
  }
  return total;
}

function twoOpt(pts) {
  let tour = pts.map((_, i) => i); // start: nearest-neighbour tour would go here
  let improved = true;
  while (improved) {
    improved = false;
    for (let i = 0; i < tour.length - 1; i++) {
      for (let j = i + 2; j < tour.length; j++) {
        const a = pts[tour[i]], b = pts[tour[i+1]];
        const c = pts[tour[j]], d = pts[tour[(j+1) % tour.length]];
        const before = dist(a,b) + dist(c,d);
        const after  = dist(a,c) + dist(b,d);
        if (after < before - 1e-9) {
          const seg = tour.slice(i+1, j+1).reverse();
          tour = [...tour.slice(0, i+1), ...seg, ...tour.slice(j+1)];
          improved = true;
        }
      }
    }
  }
  return { tour, length: tourLength(tour, pts) };
}

// 12 delivery rooftops (x, y in metres, z = altitude band)
const waypoints = [
  {x:0,y:0,z:30}, {x:120,y:40,z:35}, {x:80,y:150,z:28} /* ...more... */
];
const best = twoOpt(waypoints);
console.log(`Optimized route length: ${best.length.toFixed(0)} m`);

8. Real-World Applications

Last-Mile Delivery

Zipline and Wing plan daily delivery batches as TSP/VRP instances, re-solved as new orders arrive, with battery swap/recharge depots as mandatory tour stops.

Precision Agriculture

Crop-scanning drones visit a grid of sample points; routing minimises flight time to maximise battery-limited field coverage per sortie.

Infrastructure Inspection

Power-line and pipeline inspection drones solve a TSP over pylons or valve stations, often combined with obstacle-aware pathfinding between stops.