6. Inventory Policy Simulation Lab
The earlier chapters derived policy settings under clear assumptions. In this lab, turn those settings into executable Python and inspect a small, reproducible demand trace. The data is deliberately supplied rather than randomly sampled: that makes timing and expected outputs easy to verify before you experiment with random demand.
The exercises use Python's standard library only. They focus on three practical tasks:
- Calculate continuous and periodic safety-stock targets.
- Simulate an policy with a fixed lead time and lost sales.
- Classify current on-hand against policy inventory reference levels.
Check the model before coding
Simulation assumptions and timing
1 / 5With fixed lead time L = 4 periods, which protection period is used by an (R, S) policy reviewed every R = 3 periods?
Pick an answer to see if you are right.
Start with the protection-period targets
Given per-period mean demand , standard deviation , lead time , review interval , and service factor , calculate:
Use the demand and time units consistently. The test data supplies directly, so the exercise can focus on translating the policy equations into code.
| Case | Mean demand / period | Demand SD / period | |||
|---|---|---|---|---|---|
| A | 40 | 13.6 | 4 | 1 | 1.645 |
| B | 100 | 10 | 4 | 5 | 1.0 |
Simulate a periodic-review policy
Use this six-period demand trace to test the order/receipt timing. The policy reviews every periods, targets units of inventory position, and has lead time period. Start with 8 units on hand and no pipeline stock. Unfilled demand is lost, not backordered.
| Period | Demand, trace A | Demand, trace B |
|---|---|---|
| 1 | 3 | 2 |
| 2 | 7 | 2 |
| 3 | 2 | 2 |
| 4 | 6 | 2 |
| 5 | 1 | 2 |
| 6 | 4 | 2 |
Use these timing rules:
- Receive any shipment due at the start of a period, then satisfy as much demand as on-hand stock allows.
- At the end of every second period, order .
- Inventory position is on-hand plus outstanding pipeline orders; lost sales are not subtracted as backorders.
- An order placed at the end of period with becomes available at the start of period , after one full intervening period in transit.
- A cycle is a block of periods. A cycle is successful only if every period in it has no stockout; period service counts individual no-stockout periods.
Rank the simulation loop
Put the steps in order for one run of the periodic policy.
Run one simulated period
1 / 1Order the recurring simulation steps, starting from a prepared demand series and initialized inventory state.
OrderDrag the handle to rearrange — top should be first.
- 1Record whether the period had a stockout.
- 2Apply current demand to on-hand stock and record fulfilled and unfilled units.
- 3Schedule any new order to arrive after the stated lead-time convention.
- 4Receive any shipment due at the start of the current period.
- 5At a review boundary, calculate inventory position and the order quantity.
Drag items into the correct order (or use ↑↓), then check.
Implement simulate_rs(demands, lead_time, review_period, target). Begin with target units on hand and no pipeline stock. Unfilled demand is lost, not backordered.
Classify an inventory snapshot
The values below are policy-analysis inputs. They are not all observations from the six-period traces above. For this exercise, the routine on-hand band runs from safety stock through safety stock plus maximum cycle stock. For continuous review, maximum cycle stock is ; for periodic review it is .
| Policy | Safety stock | Current on-hand | |||
|---|---|---|---|---|---|
| Continuous | 44.7 | 40 | 40 | 1 | 30 |
| Periodic | 50 | N/A | 40 | 1 | 65 |
Implement stock_zone(on_hand, safety_stock, maximum_cycle_stock). Return shortage at or below zero, below safety for a positive balance below safety stock, within cycle band through the upper reference, and above cycle range beyond it. This is a diagnostic label, not an order trigger; ordering decisions still use the policy's inventory-position rule.
Key takeaways
- Check inventory position and expected stock components separately; pipeline is not on-hand stock.
- Keep each policy's protection period and order rule explicit.
- Simulation results depend on receipt timing, review timing, and lost-sales versus backorder treatment.
- Data tables make a run inspectable; multiple deterministic tests catch timing and boundary errors before random demand is introduced.
Previous: Inventory Policies with Safety Stock.
Next: Beyond Normality — assess skewed demand and gamma-based inventory buffers.