Queueing — Emergency Department Capacity
Python · NumPyro · Data: UnityPoint Health ED arrivals (hourly, Iowa, 2014–2017, via Dryad)
When The Constraint Is A Queue
Sub-arc A asked what a demand distribution is worth once an optimizer acts on it. This one changes the constraint. When the bottleneck is a queue, the decision is not how much to order but how much service capacity to build — and the mathematics that answers it is older than any of the machine learning in this arc.
The arrivals are real: the same hourly emergency-department series as the staffing example, 33,984 hours of it. Demand is strongly time-varying — 6.0 arrivals per hour at 17:00 against 1.6 at 04:00, a near four-fold swing across the day — which is exactly the condition under which the textbook formula turns out to mislead.
The classical treatment is the M/M/c queue. In Kendall's notation the three slots are the arrival process, the service-time distribution, and the number of parallel servers: M for Markovian — memoryless, meaning Poisson arrivals and exponential service times — and c servers working in parallel from one shared line. The quantity that drives everything is the offered load
measured in Erlangs: the average number of servers kept busy. Here a three-hour mean stay gives per hour, and the evening peak works out at 18 Erlangs. That number alone sets a floor — with 18 servers' worth of work arriving continuously you need at least 19 servers for the queue to be stable at all, because at the backlog grows without bound. Erlang-C then converts into the probability an arrival has to wait, and hitting a 20% service-level target at the peak takes 23 servers — five more than the naive load figure suggests.
The Formula Hits Its Average And Fails Half The Day
Applying that hour by hour is SIPP — stationary independent period-by-period — which treats each hour as its own steady-state queue. It produces a plausible-looking roster and a defensible daily total: 410 server-hours at the standard target, against 358 for a lenient one and 444 for a tight one.
And it is wrong in a way the formula cannot see. Rebuilding the day as a discrete-event simulation — an explicit event loop over arrivals and service completions, with the server count changing by hour — the average lands exactly on target, overall P(wait) 0.20, mean wait 17.7 minutes. The hour-by-hour picture is another matter: 11 of 24 hours breach the target, and the worst is 01:00, where P(wait) reaches 0.73 and the mean wait is 110 minutes.
| what the plan promised, and what it delivered | value |
|---|---|
| target wait probability | 0.20 |
| simulated, averaged over the day | 0.20 — on target |
| hours breaching the target | 11 of 24 |
| worst hour | 01:00, P(wait) 0.73, mean wait 110 min |
The failure has a mechanism worth stating, because it generalises. Service here takes three hours, which is long relative to how fast arrivals move. Beds are therefore still occupied by the evening surge well after midnight — but SIPP sized the overnight hours on their own low arrival rate and cut staff accordingly, leaving too few servers to work off inherited load. A stationary formula applied period by period assumes each period starts empty, and a queue with a long service time never does. That is the case for simulating rather than trusting the closed form, and it is invisible in the daily average.
Pricing The Uncertainty In The Arrival Rate
Finally the arrival rate itself is uncertain — it was estimated from data, not handed down. Putting a Bayesian posterior on and re-solving gives a distribution over the required roster rather than a single one. The posterior-median plan costs 409 server-hours against the point estimate's 410, which is the reassuring part; a plan robust to the 95th percentile costs 417. Insuring against arrival-rate uncertainty costs 8 server-hours a day — about 2% — and that number, not a vague sense of caution, is what makes the decision arguable.
| roster | server-hours per day |
|---|---|
| point estimate of the arrival rate | 410 |
| posterior median | 409 |
| robust to the 95th percentile | 417 +8, about 2% |
Notebook
References
- Erlang, A. K. (1917). Solution of some problems in the theory of probabilities of significance in automatic telephone exchanges. Post Office Electrical Engineers' Journal 10, 189–197. — the formula, from telephone switchboards
- Kendall, D. G. (1953). Stochastic processes occurring in the theory of queues. Annals of Mathematical Statistics 24(3), 338–354. — the A/B/c notation
- Little, J. D. C. (1961). A proof for the queuing formula L = λW. Operations Research 9(3), 383–387. — how P(wait) becomes an expected wait
- Green, L. V., Kolesar, P. J. & Whitt, W. (2007). Coping with time-varying demand when setting staffing requirements for a service system. Production and Operations Management 16(1), 13–39. — SIPP, and exactly when it fails
- Whitt, W. (1991). The pointwise stationary approximation for Mt/Mt/s queues is asymptotically correct as the rates increase. Management Science 37(3), 307–314. — the conditions under which the shortcut is safe