Skip to main content

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:

  1. Calculate continuous and periodic safety-stock targets.
  2. Simulate an (R,S)(R,S) policy with a fixed lead time and lost sales.
  3. Classify current on-hand against policy inventory reference levels.

Check the model before coding​

Quiz

Simulation assumptions and timing

1 / 5

With 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 μ\mu, standard deviation σ\sigma, lead time LL, review interval RR, and service factor zz, calculate:

SSs,Q=zσL,s=μL+SSs,QSS_{s,Q}=z\sigma\sqrt{L},\qquad s=\mu L+SS_{s,Q} SSR,S=zσL+R,S=μ(L+R)+SSR,SSS_{R,S}=z\sigma\sqrt{L+R},\qquad S=\mu(L+R)+SS_{R,S}

Use the demand and time units consistently. The test data supplies zz directly, so the exercise can focus on translating the policy equations into code.

CaseMean demand / periodDemand SD / periodLLRRzz
A4013.6411.645
B10010451.0

Simulate a periodic-review policy​

Use this six-period demand trace to test the order/receipt timing. The policy reviews every R=2R=2 periods, targets S=8S=8 units of inventory position, and has lead time L=1L=1 period. Start with 8 units on hand and no pipeline stock. Unfilled demand is lost, not backordered.

PeriodDemand, trace ADemand, trace B
132
272
322
462
512
642

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 max⁡(0,S−inventory position)\max(0,S-\text{inventory position}).
  • Inventory position is on-hand plus outstanding pipeline orders; lost sales are not subtracted as backorders.
  • An order placed at the end of period tt with L=1L=1 becomes available at the start of period t+2t+2, after one full intervening period in transit.
  • A cycle is a block of RR 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.

Quiz

Run one simulated period

1 / 1

Order the recurring simulation steps, starting from a prepared demand series and initialized inventory state.

OrderDrag the handle to rearrange — top should be first.

  1. 1Record whether the period had a stockout.
  2. 2Apply current demand to on-hand stock and record fulfilled and unfilled units.
  3. 3Schedule any new order to arrive after the stated lead-time convention.
  4. 4Receive any shipment due at the start of the current period.
  5. 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 QQ; for periodic review it is μR\mu R.

PolicySafety stockQQμ\muRRCurrent on-hand
Continuous (s,Q)(s,Q)44.74040130
Periodic (R,S)(R,S)50N/A40165

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.