Sensitivity and Scenario Analysis
Sensitivity analysis asks how the model solution changes when an input changes. Scenario analysis compares deliberately specified input sets. Neither automatically describes uncertainty probabilities.
Prerequisites
Complete duality and shadow prices.
Learning goals
- Perturb a right-hand side and re-solve the complete model.
- Derive the range over which the current binding structure remains valid.
- Separate local marginal predictions from finite scenario results.
- Report scenario provenance and avoid probabilistic overclaiming.
Local range for staff capacity
Keep room capacity at 50 and suppose both resource constraints bind. Solving
gives and . Both are nonnegative for . Strictly inside that interval the same two-row basis remains nondegenerate and the objective is
so the local slope is benefit points per staff-hour. At an endpoint the basis changes or becomes degenerate; outside it, extrapolating the old shadow price is wrong.
Changing benefit coefficients, capacities, or requirements creates a different scenario. Record why each value is plausible. A scenario is not a probability distribution, confidence interval, or robustness guarantee.
Worked example
import numpy as np
from scipy.optimize import linprog
benefit = np.array([8.0, 6.0])
A = np.array([[2.0, 1.0], [1.0, 2.0]])
for staff_hours in (38.0, 40.0, 42.0):
result = linprog(-benefit, A_ub=A, b_ub=[staff_hours, 50.0],
bounds=[(0.0, None)] * 2, method="highs")
if result.status != 0:
raise RuntimeError(result.message)
print(f"staff_hours={staff_hours:.0f} workshop={result.x[0]:.3f} clinic={result.x[1]:.3f} points={-result.fun:.3f}")
print("local_staff_shadow=3.333333 valid_while_basis_unchanged=(25,100)")
Expected output:
staff_hours=38 workshop=8.667 clinic=20.667 points=193.333
staff_hours=40 workshop=10.000 clinic=20.000 points=200.000
staff_hours=42 workshop=11.333 clinic=19.333 points=206.667
local_staff_shadow=3.333333 valid_while_basis_unchanged=(25,100)
The finite differences match the local shadow price because these scenarios stay within the same active region. The allocation itself shifts toward workshops as staff becomes less scarce relative to room time.
Limitations and common mistakes
- One-at-a-time sensitivity can miss interactions among coefficients and right-hand sides.
- An allowable range is conditional on all other modeled quantities remaining fixed.
- Solver tolerances can blur exact breakpoint classification; inspect residuals near boundaries.
- Hand-picked optimistic and pessimistic scenarios do not have known coverage probabilities.
- Re-solving uncertain inputs is not the same as stochastic or robust optimization, which ticket 60 introduces.
Practice
Derive the analogous room-capacity range with staff fixed at 40, then verify scenarios at 48, 50, and 52 room-hours. State where the room shadow price ceases to extrapolate.
Next steps
Move from one chosen objective to explicit stakeholder tradeoffs in multi-objective optimization and Pareto frontiers.
Primary sources
Checked 2026-10-18: Boyd and Vandenberghe, Convex Optimization, perturbation and sensitivity and updated slides; SciPy 1.18.1, linprog(method="highs") marginals and residuals; HiGHS, official documentation.