Companion film
Monte Carlo in a cell
Model revenue and cost as distributions, widen uncertainty, and watch the launch decision change with the odds.
21 secGrid 0.61.0
Open film page →Guided build · 19
Advance model time through seasonal demand, smoothed memory, delayed arrivals, stock flows, and replayable trajectories.
You will finish with: A 52-week warehouse experiment that can be rerun and compared without overwriting its assumptions.
A 52-week warehouse model with seasonal demand, smoothed forecasts, lead-time delay, inventory stocks, seeded uncertainty, and a replayable trajectory.
The key distinction is between a workbook point estimate and an experiment that advances model time. The same formulas serve both views.
Inventory remembers compares two saved 52-week runs, tracing forecast memory, four-week shipment delays, and accumulating inventory. The worked inventory-memory download contains the exact Grid 0.66.2 fixture exercised in the film.
Open the film page and transcript.
Open the Model-Time Warehouse Simulation example:
A1 = 480
A2 = 60
A3 = 4
A4 = 0.3
A5 IS currency = 2.40
These values describe opening inventory, baseline weekly demand, lead time, smoothing weight, and holding cost.
The simulation clock is hypothetical. Running it does not repeatedly overwrite these authored assumptions.
B1 = SIM_TIME() DEFAULT 0
B2 = SIM_STEP() DEFAULT 0
B3 = B2 > 0 THEN "in-run" ELSE "opening"
Outside a simulation, the clock functions are unavailable. DEFAULT 0 gives the ordinary workbook a useful opening view instead of an error.
Checkpoint:
B1 = 0,B2 = 0, andB3 = "opening".
C1 = A2 * (1 + 0.25 * SIN(2 * PI() * B1 / 13))
C2 = PREV(C3, A2)
C3 = A4 * C1 + (1 - A4) * C2
C1 reads model time. PREV supplies the prior simulated value of C3, with baseline demand as the initial fallback. Together they produce an exponentially smoothed forecast.
Opening checkpoint:
C1 = 60,C2 = 60, andC3 = 60.
D1 = C3 * (A3 + 2)
D2 = MAX(D1 - E1 - E2, 0)
D3 = DELAY(D2, 4, 0)
E1 = STOCK(A1, D3 - C1)
E2 = STOCK(0, D2 - D3)
E3 = STOCK(0, C1)
The order-up-to target covers lead time plus safety. DELAY represents the four-week shipment lag. STOCK integrates each net flow as simulated time advances.
Opening checkpoint: on-hand inventory is
480, on-order inventory is0, smoothed demand is60, and status is"covered".
G1 = [NORM.INV(RAND_SEEDED(seed), 1.0, 0.08) FOR seed IN 301..316]
G2 = ROUND(AVERAGE(G1), 3)
G3 = COUNTIF(G1, ">1.1") / 16
G4 = ROUND(D1 * MAX(G1), 0)
Fixed seeds make the 16 demand shocks replayable. Reopening or rerunning the same model should not silently invent a different comparison set.
The shock fan is separate from the time-stepped stock equations: one describes scenario uncertainty, while the other describes state evolution.
H1 = SIM_TRAJECTORY(E1, {t0: 0, dt: 1, steps: 52, timeUnit: "week"})
Render or run the trajectory and inspect on-hand inventory across the 52 weekly steps. The result is a finite read-only time series backed by the same E1 stock definition.
Check three things:
Use the run identifier and model history to compare experiments instead of copying result columns into a separate workbook.
For the complete Inventory remembers experiment, open the worked inventory-memory download and choose Experiments. Its design compares weekly demand 60 and 75 across 52 steps. Select Launch, wait for both runs to complete, then choose them as the baseline and candidate in Run comparison.
Select Inspect trajectory on each stored run. The Trajectory output selector exposes the memory mechanics:
Experiment admission saves exact cell identities. The selector may show those
identities (cell_16389 for E1, cell_49155 for C3, and cell_49156 for
D3) instead of the authored coordinates listed below.
| Output | Meaning | What to check |
|---|---|---|
R1C5 (E1) |
On-hand inventory | Starts at 480; each Euler step adds arrivals minus seasonal demand |
R3C3 (C3) |
Smoothed forecast | 0.3 × current demand + 0.7 × previous forecast |
R3C4 (D3) |
Shipment arrivals | The order from four steps earlier; initial arrivals are zero |
R1C3 (C1) |
Seasonal demand | Baseline demand times the authored 13-week seasonal factor |
R2C3 (C2) |
Previous forecast | The prior step's C3, with baseline demand as the opening fallback |
R2C4 (D2) |
New orders | The nonnegative gap between the coverage target and current stock plus orders |
R2C5 (E2) |
On-order stock | Accumulates orders and subtracts arrivals |
Each run contains 53 points: its opening state and 52 weekly steps. Compare the curves from the two retained run IDs. The higher-demand overlay changes the simulated path, while the authored workbook still has A2 = 60 and opening E1 = 480. Inspecting a verified replay neither reruns a new experiment nor writes the simulated closing inventory into the workbook.
The worked case deliberately separates deterministic memory from the seeded uncertainty exercise above. Both experiments use the same equations and one-week Euler steps; only the isolated demand parameter changes.
Save the baseline experiment. Raise weekly demand A2 from 60 to 75, rerun the same 52-week horizon, and compare:
"reorder-risk",Then restore A2 and increase lead time A3. Explain why the safety target moves immediately even though arrivals still follow the explicitly authored four-step DELAY in this example.