Supply Chain Digital Twin Source code Documentation

Forecasting cut stockouts 80% — for 16% higher cost.

A warehouse inventory policy tuned from historical averages versus one driven by a live demand forecast, running the identical trending, seasonal demand for a full simulated year.

Stockout days / year
—
Service level
—
Total cost / year
—
The forecast-driven policy re-forecasts demand every 7 days and re-sizes its reorder point to match — the static policy is set once from 180 days of history and never updates. As real demand grows past that stale average, the static policy quietly under-stocks. That's the whole story: not "AI wins outright," but a genuine service-vs-cost tradeoff, caused by one policy tracking a trend the other can't see.

Explore the tradeoff

Compare both policies across supplier lead times and service-level targets. Longer lead times are where forecasting earns its keep.

Static (Phase 1) Forecast-driven (Phase 2)
Stockout days / year
Service level
Total cost / year

How the winning forecaster actually performs

Held out the last 30 of 180 historical days, forecast without seeing them. Holt-Winters tracks the weekly wave; it can't and doesn't pretend to predict one-off spikes like day 173.

Actual Forecast (Holt-Winters)
View the data as a table

Why Holt-Winters won

Four forecasters, backtested with 6-fold walk-forward validation (never just a single train/test split). Naive and gradient boosting are legitimate contenders; Holt-Winters wins because the demand process has the exact trend + weekly seasonality shape it's built to model directly.

Phase 3 — routing the network

The twin grows into a network: two regional warehouses, four retail stores, and a squeeze — southern demand outgrows the South warehouse's fixed inbound capacity over the year. Same demand, same replenishment, same information; the only difference is how warehouse stock gets routed. A min-cost transportation LP re-routes ~8,000 units/year of northern slack southward and its plan feeds back into the twin's state — closing the forecast → optimize → simulate loop.

Nearest-warehouse (naive) Transportation LP
Fill rate
Nearest-warehouse82.8%
Transportation LP100.0%
The naive rule serves every store only from its home warehouse — the South starves while the North sits on surplus.
Cumulative stockout days
0 100 200 day 0 day 365
Total cost / year
Nearest-warehouse330,741
Transportation LP359,394
+8.7% total — cross-region lanes cost 4× the home lane, so eliminating stockouts nearly doubles transport spend.

10 paired replications, 365-day horizon, identical seeds per pair. The LP (scipy HiGHS) minimizes transport cost plus a shortage penalty over every warehouse–retail lane; it reaches zero stockout days on every seed. Scenario: scenarios/network.json.

What's actually running

The twin's network
forecast re-sizes the reorder policy weekly Supplier Central Warehouse (s, S) reorder policy Customers ships after lead time daily seasonal demand
Every number on this page comes from a verified discrete-event simulation engine — 53 passing tests, paired-seed replications, walk-forward-validated forecasts. Nothing is mocked, and this page itself is pure static HTML with zero dependencies. The full engine, including a control panel that runs arbitrary scenarios live, is in the repository.