Stochastic Allocation — Staffing
Python · NumPyro, TBATS, PuLP · Data: UnityPoint Health ED arrivals (hourly, Iowa, 2014–2017, via Dryad)
Decide Now, Learn Later
The inventory example showed that acting on a distribution beats acting on a point. This one generalises the claim into its standard form. Staffing an emergency department is the canonical two-stage stochastic program: nurses are rostered before the day's arrivals are known, and once demand lands the only remaining freedom is expensive — overtime, agency cover, patients waiting. The first-stage decision is committed under uncertainty; the second stage cleans up.
The reason a point forecast is the wrong object is asymmetry, not inaccuracy. Suppose the best model says Monday will see 110 patients. Staffing for exactly 110 is optimal only if being one patient short costs the same as being one nurse over, and it never does. The correct object is the distribution of arrivals, and the correct decision minimises expected cost across it:
Here is the roster chosen now, a demand scenario, and the second-stage recourse cost of coping with given . Both stages are linear, so the whole thing is a linear program once the expectation is replaced by an average over scenarios.
The scenarios are not invented from a rule of thumb. They come from the fitted model's own posterior predictive — its simulation of how tomorrow could go, run thousands of times, where each run is a complete plausible day rather than a single number with an error bar bolted on. That matters because the runs carry the model's uncertainty about the seasonal pattern itself, not merely the scatter left over once the pattern is fixed. The data is real hourly emergency-department arrivals, and the forecasting section is a genuine bake-off before the optimizer ever runs — the arrival series carries three seasonal periods at once (daily, weekly, annual), which is what makes it hard.
Two Numbers That Decide Everything
Two quantities decide whether any of this was worth doing, and they are the reason this example exists. The value of the stochastic solution is what modelling uncertainty bought over solving with the expected demand and hoping. The expected value of perfect information is what a flawless forecast would buy over the stochastic solution — the ceiling on all further forecasting effort.
| quantity | definition | value |
|---|---|---|
| EEV | solve with expected demand, then live with it | $46,521 |
| RP | the stochastic program, optimizing over scenarios | $44,515 |
| WS | wait-and-see: a perfect forecast, every week | $44,191 |
| VSS | EEV − RP — value of modelling uncertainty | $2,006 4.3% of EEV |
| EVPI | RP − WS — value of removing it entirely | $324 0.7% |
Over 41 held-out weeks the stochastic plan is at least as cheap as the expected-value plan in 39 of them. VSS is $2,006, or 4.3% of the expected-value cost. EVPI is $324 — 0.7%.
That gap is the finding, and it is worth more than a larger one would be. Modelling the uncertainty is worth six times more than eliminating it. Almost all the available gain is captured by admitting that demand is a distribution and optimizing accordingly; only a small remainder is left for a better forecast to claim. A team pouring effort into forecast accuracy while solving the deterministic problem has the priority backwards — and the ordering that the three costs satisfy is not luck but a theorem, which makes it a check on the implementation as well as a result.
The notebook then asks whether the scenario source matters, comparing posterior-predictive scenarios against a bootstrap. It is the right question to ask of any stochastic program: the optimizer is only ever as good as the distribution handed to it, and a bootstrap that shuffles past errors one hour at a time produces a jagged picture of a world where things actually move together — busy hours cluster into busy days, and shuffling breaks exactly the pattern that matters.
Notebook
References
- Birge, J. R. & Louveaux, F. (2011). Introduction to Stochastic Programming (2nd ed.). Springer. — VSS and EVPI, and the WS ≤ RP ≤ EEV ordering
- Dantzig, G. B. (1955). Linear programming under uncertainty. Management Science 1(3–4), 197–206. — the two-stage formulation
- Beale, E. M. L. (1955). On minimizing a convex function subject to linear inequalities. JRSS B 17(2), 173–184. — the same idea, independently
- De Livera, A. M., Hyndman, R. J. & Snyder, R. D. (2011). Forecasting time series with complex seasonal patterns using exponential smoothing. JASA 106(496), 1513–1527. — TBATS, for the three nested seasonalities