Skip to main content

Monte Carlo simulation

How AInventory generates ~1,000 demand scenarios per SKU (200 in batch processing) and evaluates every policy over the same scenarios.

What simulation is for

Inventory optimization requires knowing how a replenishment policy would behave against unknown future demand. The classic formula answers that question with an analytic approximation that assumes Normal demand; Monte Carlo simulation answers it with a representative sample of plausible futures, consistent with the observed uncertainty of the SKU.

Rather than asking "what is the optimal solution on average under distributional assumptions?", the system asks: "given this set of plausible scenarios, which policy produces the lowest expected total cost?". The difference is not philosophical: it is operational when demand is asymmetric, has heavy tails, or when history is short.

The analysis window W

The entire simulation operates over an analysis window W:

W = L + R

where L = lead time (periods from when the order is placed until it arrives) and R = review period (how often inventory is reviewed). The window defines the horizon during which inventory must cover demand with available stock plus the order just placed.

A single decision at t = 0

The model assumes the planner makes a single order decision Q at t = 0 and places no further orders during window W. This is consistent with a periodic review system: at each review cycle, a quantity is decided, and that quantity must last until the next cycle plus the lead time.

The arrival schedule is:

  • In-transit inventory (orders placed before t = 0) arrives at horizon h = 1.
  • Order Q placed at t = 0 arrives at h = L + 1.

The inventory identity at each horizon is strict:

inv_end[h] = inv_start[h] − sales[h]

There are no accumulated lost sales or backorders: units not served in one horizon are not carried to the next as pending demand (the model assumes the shortage is lost or resolved through means outside the scope of the current order).

Scenario generation and fixed seed

For each SKU, ~1,000 scenarios are generated (200 in batch processing for performance), each a demand path of W periods constructed from historical forecast errors according to the statistical cascade level.

Three sampling methods are available:

MethodDescriptionWhen it applies
Row resamplingResamples full rows from the error matrix (preserves within-horizon correlation)Default; all levels with history
Independent resamplingResamples individual error scalars (breaks inter-horizon correlation)Alternative when correlation is not relevant
Parametric fallbackSamples from Normal(0, σ_W/√W) when no error matrix is availableFallback for SKUs with little history

The seed is fixed per SKU and per run. This guarantees reproducibility: if a planner reviews a SKU's detail hours after running optimization, they will see exactly the same scenarios and costs that appear in the summary table. Both result views are identical because they compute over the same scenario bundle with the same seed.

Why all policies share the same scenarios

The five replenishment policies are evaluated over the same scenario bundle for each SKU. This is not a minor technical detail: it is what makes their costs directly comparable.

If each policy generated its own scenarios (even from the same distribution), cost differences between them would be contaminated by sampling variance. By sharing the same scenarios, the only source of difference is each policy's actual performance against the same possible future demand. The argmin of expected total cost across policies is therefore a clean ranking.

Error sign convention

Forecast error follows the convention:

error = actual_demand − forecast

A positive error means demand exceeded the forecast (the system underestimated demand). A negative error means the forecast was greater than actual demand. This convention is consistent with the interpretation of bias: a historical error distribution with a positive mean indicates the forecast tends to underestimate.