Simulation
Medicine supply digital twin (6/14): docks as a queue
Why going from 4 to 5 docks cuts the wait from two and a half hours to 17 minutes. The Erlang C formula, Little's law and a discrete-event simulation that checks them.
Supplier trucks arrive at the central warehouse all day. Each one goes through the gate, waits in the yard, pulls up to a dock, gets unloaded, has its load checked and leaves. If there aren’t enough docks, trucks queue in the yard and then in the street. A truck that waits three hours costs the supplier money and, in the cold chain, puts its load at risk.
The twin simulates the whole yard minute by minute, with every resource (gate lanes, yard slots, docks, forklifts, inspectors) and its capacity. But the heart of the problem fits in a classic model: the M/M/c queue.
The M/M/c model
The notation says three things:
- M: trucks arrive at random, uncoordinated. The time between arrivals is exponential, with arrivals per hour on average.
- M: unloading takes a random time, also exponential, with mean .
- c: there are docks working in parallel, and each arrival takes the first free one.
The stability condition
If on average more trucks arrive than can be unloaded, the queue grows without limit. The condition is
With 5 trucks an hour and 45 minutes per unload, : you need at least 4 docks. But “at least” is not “enough”, as we’re about to see.
The Erlang C formula
The probability that every dock is busy when a truck arrives is
and the mean wait in the yard is
The denominator is the spare capacity. As it approaches zero, the wait shoots up.
One dock fewer
Same trucks, 4 docks:
| Docks | Utilization | Wait | Mean wait | Trucks in yard |
|---|---|---|---|---|
| 4 | 93.8 % | 86 % | 156 min | 13.0 |
| 5 | 75.0 % | 46 % | 17 min | 1.4 |
| 6 | 62.5 % | 23 % | 4.5 min | 0.4 |
| 7 | 53.6 % | 10 % | 1.4 min | 0.1 |
Removing one dock multiplies the wait by nine. The cause is the factor: going from 75 % to 94 % utilization, spare capacity drops from 25 % to 6 %. A dock busy 94 % of the time looks efficient in a report and is a two-and-a-half-hour queue in the yard.
Little’s law
The last column comes from a relation that holds for almost any stable queue, no matter how arrivals or services are distributed:
On average, what’s inside a system equals what enters per unit time multiplied by how long each item takes to leave. With 5 trucks an hour and 0.277 hours of waiting, there are trucks waiting. It also works backwards: if you count 13 trucks in the yard and 5 arrive per hour, each one is waiting about 2.6 hours.
The national distribution center in 3D: gate, yard and docks, with trucks queuing in simulated time. (Interface in Spanish.) · Open full screen
What comes next
Among what arrives at the warehouse are medicines that must stay between 2 and 8 °C. The next two posts are about the cold chain: first, how long a fridge holds when the power goes out.