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

a=λμa = \frac{\lambda}{\mu}

measured in Erlangs: the average number of servers kept busy. Here a three-hour mean stay gives μ=0.333\mu = 0.333 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 cac \le a the backlog grows without bound. Erlang-C then converts cc 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 deliveredvalue
target wait probability0.20
simulated, averaged over the day0.20 — on target
hours breaching the target11 of 24
worst hour01: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 λ(t)\lambda(t) 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.

rosterserver-hours per day
point estimate of the arrival rate410
posterior median409
robust to the 95th percentile417 +8, about 2%

Notebook

References