Simulation
Medicine supply digital twin (2/14): safety stock
How forecast uncertainty becomes units on the shelf. Where the square root of time comes from, what it costs to go from 95 to 99 %, and why an unpunctual supplier weighs more than variable demand.
The previous post ended with a forecast and a deviation . Today’s question is practical: a health unit receives medicine every seven days and an order takes another seven to arrive. How much should it order today?
If it orders exactly the forecast, half the time it runs out before the next delivery, because real demand ends up above the average half the time. Safety stock is the buffer that brings that probability down to an acceptable level.
The horizon to cover
What it orders today has to last from now until the delivery after the one it is ordering. That horizon is
where is the time until this order arrives and the time between deliveries. With days, .
Where the square root comes from
Demand over days is a sum of daily demands. If each day is independent with mean and variance , means and variances add up:
Standard deviations don’t add: their squares do. That is why the buffer grows with the square root of the horizon, not in proportion. Covering four times as many days doesn’t take four times the buffer, only twice.
If that sum is roughly normal (it is when isn’t too small, by the central limit theorem), for it to be enough with probability you need
What goes beyond the mean is the safety stock, . And the order is what’s missing to get there:
The price of the last point
grows faster and faster as the service level approaches 100 %:
| Service level | Value of | Example buffer |
|---|---|---|
| 90 % | 1.282 | 96 units |
| 95 % | 1.645 | 123 units |
| 99 % | 2.326 | 174 units |
| 99.9 % | 3.090 | 231 units |
Going from 90 to 95 % costs 27 units; from 99 to 99.9 %, 57. So it makes no sense to ask the same level for everything: a vital item deserves it, an antacid doesn’t. The twin uses 95 % as its baseline.
The warehouse (CEDIS) in 3D: racks, cold room, docks and trucks. Turn on the Inventory layer (“Inventario”) to see each item’s level against its safety stock. (Interface in Spanish.) · Open full screen
When the supplier is what varies
So far I assumed the order arrives in exactly days. If lead time also varies, with mean and deviation , the variance of demand during the wait has two sources:
The second term comes from the fact that if the wait stretches by days, extra units are used.
What the twin does
With the Holt-Winters forecast instead of a fixed mean, the calculation is the same: add up the forecast for the days, add and subtract what is on hand and in transit. The result is rounded up to the item’s pack size.
What comes next
This calculation works for a unit that orders every week. The central warehouse does the same for the whole network, with suppliers that are sometimes late or deliver short. In the next post I compare the warehouse’s two ways of ordering: fixed min-max against forecast-based ordering.