Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Solutions · 17. Project: planning a relief mission after an earthquake

School of Engineering, Nazarbayev University

Worked solutions to the three exercises of Lecture 17. Each solution is computed here and checked with assert statements against an exact identity or an independent calculation. The first code cell sets up the notebook and runs Demonstration 1 of the lecture without showing its output, because some of the solutions use its variables.

Exercise 1

Problem. Implement held_karp_exact_tsp(dist_matrix) in NumPy solving the exact asymmetric/symmetric Travelling Salesperson Problem on N=11N = 11 priority relief sites (11⋅210=11,26411 \cdot 2^{10} = 11{,}264 table entries) with exact backpointer tour reconstruction. Benchmark emergence_verification.simulated_annealing_tsp against held_karp_exact_tsp, proving SA achieves < 0.5% optimality gap while comparing state counts against (N−1)!/2=1,814,400(N-1)!/2 = 1{,}814{,}400 brute-force tours.


Exercise 1: Exact Held-Karp bitmask DP TSP on 11 relief sites against simulated annealing
=========================================================================================
11-Site Exact Held-Karp Optimum = 272.016203 km (reconstructed check = 272.016203 km)
Simulated Annealing Tour Length = 272.016203 km (optimality gap = 0.0000% < 0.5%)
Held-Karp DP table cells = 11,264 (23,040 transitions) vs. Brute-Force (10!/2) = 1,814,400 tours
<Figure size 1254x451 with 2 Axes>

Figure S17.1. Exact tour. (a) The Held–Karp tour through 11 sites (solid) and the annealed tour (dashed), both 272.02 km. (b) States of the Held–Karp table and brute-force tours against the number of sites.

Explanation. Why is Held–Karp so much cheaper than brute force? Regardless of which of the (k−1)!(k-1)! permutations visited subset SS before arriving at endpoint j∈Sj \in S, the future cost to visit V∖SV \setminus S and return to 0 depends only on (S,j)(S, j). Collapsing (k−1)!(k-1)! prefix permutations onto a single bitmask state reduces N=15N = 15 from 4.36×10104.36 \times 10^{10} tours down to 2.46×1052.46 \times 10^5 states. The exact optimum then serves as a reference for heuristics such as simulated annealing, which here finds the optimal 11-site tour, 272.02 km.


Exercise 2

Problem. Perform a Mission-Wide Failure Audit quantifying two dangerous shortcuts: (a) Compare a naive flat-earth straight-line flight path from (10, 10) to (52, 52) on make_topographic_terrain(64, 64, seed=42) (assuming constant base cell cost 1.0, budgeting 1.75×1.75\times the flat cost for battery capacity) against the actual cumulative terrain-climb energy burned flying that straight ridge-crossing line vs. the elevation-aware A* saddle-pass detour. (b) Sweep LoRa communication range rcomm∈[8,34] kmr_{\mathrm{comm}} \in [8, 34]\ \mathrm{km} across the 60-station basin to expose the sharp continuum percolation blackout below the critical range (at rcomm=11 kmr_{\mathrm{comm}} = 11\ \mathrm{km}).


Exercise 2: Straight path across the ridge and relay network below its threshold
================================================================================
[Part A] Flat-earth assumed cost = 59.4 (Battery budget w/ +75% reserve = 103.9)
         True straight-ridge energy = 137.6 -> battery exhausted at step 24/42 mid-ridge
         Elevation-aware A* pass    = 98.5 (arrives safely within 103.9 budget? True)
[Part B] At subcritical r = 11 km: 96.7% of survivor beacons are unreachable (> 40%)
         At supercritical r = 26 km: 100.0% of survivor beacons reach Command Depot
<Figure size 1254x451 with 2 Axes>

Figure S17.2. Two mission failures. (a) Cumulative energy along the straight path and along the A* detour against the battery capacity (dashed). (b) Fraction of stations connected to the depot against the radio range.

Explanation. Both failures come from replacing a nonlinear threshold by an average. (a) The cell cost rises quadratically with elevation, up to 10.5 times the valley cost at the top of the ridge, so the geometrically longer A* detour (98.5) is cheaper than the straight line (137.6), which exhausts the battery after 24 of 42 steps. (b) Reducing the radio range from 26 km to 11 km crosses the percolation threshold of the relay network: 96.7 % of the survivor beacons can no longer reach the depot.


Exercise 3

Problem. Implement plan_battery_constrained_multi_drone_sorties(dist_matrix, depot_idx, max_range_km) in NumPy solving multi-sortie capacitated relief routing across a 16-site network (1 Command Depot + 15 survivor sites, or general NN-node dist_matrix). First order the non-depot sites using a 2-opt Simulated Annealing giant tour, then apply Beasley’s (1983) Shortest-Path DAG Split DP: construct an auxiliary (M+1)(M+1)-node DAG where directed edge (i→j)(i \to j) (0≤i<j≤M0 \le i < j \le M) represents feasible sortie depot -> seq[i] -> ... -> seq[j-1] -> depot iff its total distance ≤max_range_km\le \mathrm{max\_range\_km}, and find the exact minimum-total-distance partition. Verify 100% customer coverage, strict battery feasibility on every sortie, and exact optimality of the DAG Split step against exhaustive 2M−12^{M-1} cut enumeration.


Exercise 3: Implement it yourself — Beasley's DAG split DP for battery-constrained multi-sortie routing
=======================================================================================================
16-Site Multi-Sortie Relief Plan (max battery range = 195 km):
  Number of sorties = 4 | Sortie lengths = [135.4, 135.2, 192.3, 176.5] km
  Beasley DAG Split total = 639.384683 km vs. 2^14 Exhaustive Cut Oracle = 639.384683 km
<Figure size 836x484 with 1 Axes>

Figure S17.3. The four sorties of the split plan from the charging depot (star), each within the range of 195 km.

Summary. Beasley’s split reduces the NP-hard distance-constrained vehicle routing problem to two parts: a simulated annealing search for the order of the sites (Part V) and an exact O(M2)\mathcal{O}(M^2) shortest-path dynamic program on a DAG for the cuts (Parts III and IV). For this order, the split total, 639.38 km in 4 sorties, agrees to 10-12 with exhaustive search over all 214 ways of cutting the tour (Mental Move #24). The optimality holds for the given order only; the order itself comes from a heuristic.