Skip to main content

Project: Plan a Constrained Delivery Operation

This capstone plans one synthetic day of two-zone deliveries. It joins the area's complete workflow: formulation, integer decisions, uncertainty, solver evidence, independent validation, stress testing, and an operational fallback.

Prerequisites​

Complete combining predictive models with optimization and the preceding Optimization & Decision Science path.

Learning goals​

  • Run a local constrained-delivery command without downloads or credentials.
  • Audit assumptions, units, status, gap, plan, binding and violated constraints.
  • Compare planning scenarios, a robust stress set, paired simulation, and out-of-sample cases.
  • Preserve a byte-stable evidence artifact and state known model limitations.

Local project contract​

The repository-owned fixture declares route capacities and costs, 14 driver-hours, three depot slots, three scenarios with probabilities, a componentwise uncertainty set, six prediction-error pairs, two held-out cases, and a courier fallback limited to three packages.

Run:

npm run project:constrained-delivery

or write the same canonical JSON bytes to a file:

npm run project:constrained-delivery -- --output /tmp/constrained-delivery-evidence.json

The command uses SciPy milp/HiGHS for the sample-average model. It separately recomputes resource use, scenario objective components, box stress, Monte Carlo comparisons, and held-out performance. Fixed seed 60 and common scenarios make policy comparisons reproducible. The embedded SHA-256 covers the canonical payload before the hash field is appended.

Worked example​

import json
import subprocess
import sys

command = [sys.executable, "scripts/run-constrained-delivery-project.py"]
first = subprocess.run(command, check=True, capture_output=True, text=True).stdout
second = subprocess.run(command, check=True, capture_output=True, text=True).stdout
evidence = json.loads(first)
solver = evidence["solver_evidence"]
plan = evidence["plan"]
validation = evidence["validation"]
peak = next(row for row in evidence["scenario_performance"] if row["scenario"] == "peak")
spike = next(row for row in evidence["out_of_sample_performance"] if row["case"] == "holdout_joint_spike")
print(f"status={solver['status']} gap={solver['mip_gap']} objective_eur={solver['objective_eur']}")
print(f"plan=({plan['route_a_runs']},{plan['route_b_runs']}) capacity_packages=(east={plan['east_capacity_packages']},west={plan['west_capacity_packages']})")
print(f"violated={validation['violated_constraints']} binding={validation['binding_constraints']}")
print(f"peak_outsourced={peak['outsourced_packages']} spike_residual_unserved={spike['residual_unserved_packages']} byte_stable={first == second}")

Expected output:

status=optimal gap=0.0 objective_eur=260.0
plan=(2,1) capacity_packages=(east=9,west=6)
violated=[] binding=['depot_slots', 'driver_hours']
peak_outsourced=2 spike_residual_unserved=2 byte_stable=True

The solver certifies EUR 260 for the declared sample-average model. Both resource constraints bind. Peak planning demand fits after two outsourced packages, while the joint held-out spike exceeds the fallback and leaves two packages unserved. That failure remains visible rather than being averaged away.

Evidence review checklist​

  • Assumptions and units: one day; packages, driver-hours, route runs, and EUR are explicit.
  • Status and gap: optimal with reported zero MIP gap, scoped only to the encoded model.
  • Constraint satisfaction: integrality and resources are checked independently; violated and binding lists are separate.
  • Uncertainty: probabilities, box stress, sampling error, model uncertainty, prediction error, and solver gap are not conflated.
  • Fallback: courier name, three-package limit, lead time, trigger, and residual-unserved rule are reported.
  • Reproducibility: local fixture, pinned dependencies, fixed seed, common draws, canonical ordering, and byte-stable output.

Limitations and common mistakes​

  • The instance is synthetic and has no external validity for a real delivery operation.
  • Travel times, route sequences, traffic, vehicle failures, worker breaks, emissions, and fairness impacts are omitted.
  • Scenario probabilities and uncertainty bounds are judgmental; no statistical coverage is claimed.
  • The objective prices every shortage at EUR 50 even beyond the fallback limit, so operational residuals must be inspected separately.
  • Byte-stable evidence proves replayability of this environment, not truth, causality, or future performance.

Practice​

Copy the fixture, add a third zone and a route type, and define the new fallback invariant before editing the solver. Add one held-out case that exhausts the fallback, then require the evidence to expose the residual rather than silently clipping it.

Next steps​

You have completed all 24 Optimization & Decision Science lessons. Revisit from prediction to decision and audit how the final project keeps predictions, choices, mathematical certificates, and real-world validity distinct.

Primary sources​

Checked 2026-10-19: SciPy 1.18.1, milp; HiGHS, MIP terminology and options; NumPy 2.5, Generator; Kleywegt, Shapiro, and Homem-de-Mello, sample-average approximation.