Skip to main content

Dispatch evaluation: independent truth model and parameter sweep

scripts/eval_dispatch.py evaluates the live dispatch engine (backend/app/dispatch/risk.py) on the Chennai world (OSM hospitals and localities, MEXCLP fleet plan). The harness is in backend/app/eval/dispatch_sim.py and the outcome model in backend/app/eval/truth.py.

Why it changed (research §1.6, §4.5)​

The earlier ablation (dispatch_ablation*.md, RESULTS.md) scored "realised harm" with the same λ and θ that the engine optimises. It also ignored first responders, hospital choice and transport. A policy that agreed with the objective could not lose, so the evaluation was partly circular. Those files are kept for the record. Their numbers are not comparable with the ones below.

Truth model (backend/app/eval/truth.py)​

Each simulated call has a true condition group, drawn from a case mix built on TN 108 figures (trauma 31 %, pregnancy 27 %, cardiac 5 % split into ACS 4 % and arrest 1.5 %, poisoning 4 % [R39]; stroke, respiratory, burns and the undifferentiated remainder are our assumption). It also has a true severity given the group. The realised outcome is the probability of an adverse outcome. It comes from published curves, implemented separately from the engine:

groupoutcome modelsource
cardiac arrestsurvival = 67 % − 2.3 %/min to CPR − 1.1 %/min to defibrillation − 2.1 %/min to ACLS, floored at 0, timed from collapse. CPR / AED start when the first unit able to give them arrives (108 crews and fire: CPR + AED; police: CPR only). ACLS starts when an ALS ambulance arrives (or at hospital).Larsen 1993 [R1]
STEMI1-year mortality × 1.075 per 30 min of ischaemic time. A cath-lab hospital gives primary PCI. A non-PCI hospital transfers for PCI if the 120-min diagnosis-to-wire window can be met; otherwise it gives fibrinolysis (RR 1.3 vs PCI).De Luca 2004 [R9], ESC [R10], Keeley 2003
stroke (eligible)alteplase odds ratio falls with onset-to-needle time (1.75 → 1.26 → 1.15, none after 4.5 h). Large-vessel occlusions reaching a thrombectomy centre: −5.2 % functional independence per hour, no benefit after 7.3 h.Emberson 2014 [R12], HERMES [R13]
major traumaresponse minutes have no effect. A trauma centre gives RR 0.80. A transfer to one adds odds ×1.085 per 30 min beyond 90 min.Newgard 2010 [R14], MacKenzie 2006, [R77]
respiratory (critical)mortality 14.3 % without ALS on scene, 12.4 % with itOPALS [R23]
othersbase risk + small slope per minute to definitive care (+0.10 pp per 5 min for urgent calls)Asheim 2025 [R19]

Hospital and transport legs. The patient reaches the hospital chosen by the policy at transport-unit arrival

  • scene time + drive time. Whether that hospital really has the definitive service is set by the simulated world. A profile's claim is right with probability 0.8. An unclaimed service exists with probability 0.02. These draws do not use the confidence value the engine reads. If the hospital lacks the service, a door-in-door-out delay is drawn around the literature medians (STEMI 82 min [R79], stroke 147 min [R78], trauma 112 min [R77]) and the drive to the nearest hospital that really has it is added. Unit busy time includes the drive to the chosen hospital and back, so hospital choice also affects coverage.

Independence. All truth constants are in one dict, TRUTH, at the top of truth.py, with citations. The module imports nothing from app.dispatch and reads no config/*.yaml. tests/test_eval_truth.py checks this: a doctored dispatch.yaml (hazards × 7) leaves truth outcomes unchanged. Every random draw (scene time, DIDO, onset-to-call, LVO) is fixed per call, so all policies are scored on the same patients (common random numbers), and Δ columns are paired over the same calls.

What is still assumed. The case mix beyond the four TN shares, severity given group, onset-to-call times, baseline mortalities, the claim-accuracy of hospital profiles, the stroke-capable proxy (a real cath lab or trauma centre), and how the simulated triage reads a call (80 % of true concepts found, 8 % confused, TRIAGE in dispatch_sim.py). These numbers compare policies inside a simulation. They are not field results.

Ablation​

uv run python scripts/eval_dispatch.py --calls 60 --seeds 7,11,23 # quick, Haversine
uv run python scripts/eval_dispatch.py --calls 150 --seeds 1,2,3,4,5,6,7,8,9,10 --write [--miscalibrated]
VAAZHVU_OSRM_URL=http://127.0.0.1:5001 VAAZHVU_VROOM_URL=http://127.0.0.1:3000 uv run python scripts/eval_dispatch.py ...

Policies: B0 nearest ambulance + nearest hospital. B1 nearest ambulance with ALS when the policy requires it + nearest hospital that claims the needed services. B2 VROOM (only when VAAZHVU_VROOM_URL is set). R1–R4 are the engine ablation ladder (point estimate → distribution → future-demand term → bundles). Reported per policy:

  • mean adverse-outcome probability ± 95 % CI, overall and by condition group;
  • paired Δ vs B1 and vs B0;
  • arrest survival;
  • STEMI and stroke call-to-treatment time and primary-PCI share;
  • share of specialty patients whose first hospital really had the service;
  • the earlier response-time metrics.

Results, 2026-10-04 (Haversine routing, 10 seeds × 150 calls): dispatch_outcomes_2026-10-04.md and dispatch_outcomes_miscalibrated_2026-10-04.md.

  • R4 (the live engine) is not better than nearest-capable. Calibrated: +0.6 ± 0.7 adverse outcomes per 1000 calls vs B1. Miscalibrated: −0.2 ± 0.5. Both are within noise.
  • Both beat plain nearest (B0) by about 2–3 per 1000. The gap comes mostly from obstetric patients (+10 per 1000 for B0 vs B1), then trauma and ACS, going to a hospital that has the service (B0 reaches one for 15 % of specialty patients, B1 64 %, R1–R4 62 %).
  • R2 (distribution without a future-demand term) is the worst engine variant again: +2.3 ± 1.1 per 1000. It spends ALS and lengthens critical ALS times.
  • The engine sends slightly fewer specialty patients to a capable hospital than B1 (62 % vs 64 %), and stroke patients go to the nearest ED. The live model asks only for an ED for stroke; the condition model is in shadow mode.

Sensitivity sweep (--sweep, research §7.2 item 7)​

uv run python scripts/eval_dispatch.py --calls 40 --sweep # ~10 s, Haversine, no docker
uv run python scripts/eval_dispatch.py --calls 150 --sweep --write # -> sensitivity.md / .json

The sweep takes a frozen snapshot of N calls, each decided against the starting fleet with every unit idle at base. About 8 % of specialty hospitals get synthetic ER-board reports, so the live-readiness parameters have something to act on. Each parameter is set to the low and the high end of its range, one at a time:

  • parameters in config/dispatch.yaml parameter_sources;
  • parameters in destination.yaml: arrest κ, absent_prior, unknown_prior, half_life_sec. Their ranges are in DESTINATION_SWEEP.

decide() is re-run for each setting. A decision flips when its units or hospital differ from the decision at the priors. The table is sorted by flip rate: that is the calibration priority list. It also gives the truth model's Δ in adverse outcomes, which shows whether a flip matters, and the true groups of the flipped calls.

Top of Sensitivity sweep (150 calls, Haversine):

  • coverage.city_calls_per_hour (47 %);
  • risk_aversion (27 %);
  • handover_time_sec (21 %);
  • coverage.severity_mix.critical (21 %);
  • treated_hazard_factor (17 %, all hospital flips; θ = 0 costs +0.7 adverse outcomes per 1000 calls).

Arrest κ, absent_prior, unknown_prior and specialty_en_route_effect flip nothing, or almost nothing, in this snapshot.