"The forecast was accurate on average. Unfortunately, the empty shelves were not average, the warehouse was not average, and the customer who needed the item on Friday did not buy the mean."
A Replenishment Planner Explaining Why RMSE Did Not Save the Quarter
Supply chain temporal AI is not demand forecasting with a business label attached. It is a closed decision system in which a predictive distribution becomes an order, an allocation, a price, a labor plan, or a capacity commitment. A retailer does not need the prettiest forecast curve; it needs enough of the right inventory at the right node before demand arrives, with cash, shelf space, spoilage, service level, and supplier lead time all pulling in different directions. That makes this domain the natural extension of Chapter 19 and Chapter 22: forecasts must be probabilistic, calibrated, reconciled across a hierarchy, and consumed by an explicit cost or service-level rule.
The data are awkward in exactly the ways that expose shallow forecasting. A demand panel has thousands or millions of related time series: SKU by store by day, category by region by week, warehouse by channel by season. The series are sparse, intermittent, censored by stockouts, distorted by promotions, and partly driven by known-future variables such as planned price and marketing calendars. The decision is made before the full future is visible, so the central leakage question is not "was this column in the data warehouse?" but "was this value known to the replenishment system when it ordered?" A planned holiday promotion may be a legitimate known-future covariate; a last-minute markdown chosen after weak sales is not.
The modern frontier adds foundation models and demand sensing to the classical stack. Chronos-style, TimesFM-style, Moirai-style, and retail-specific time-series foundation models make zero-shot, few-shot, and fine-tuned demand forecasting plausible at scales where hand-tuning one model per SKU is impossible. They do not remove the hard part. The hard part is still the bridge from a distribution to an action, and the audit of whether the action reduced stockouts, holding cost, lost sales, and service failures on a leakage-safe time split.
1. Demand Is Not Just Forecasting
A demand forecast becomes valuable only when it changes a decision. The simplest decision is the single-period newsvendor problem: choose an order quantity $q$ before observing demand $D$. If one extra unit costs $C_o$ when it goes unsold and one missing unit costs $C_u$ when demand exceeds stock, the optimal order is a quantile of the predictive demand distribution:
$$F_D(q^\star)=\frac{C_u}{C_u+C_o}.$$This equation is the supply-chain version of Chapter 19's quantile forecast. The service level is not an afterthought; it is a cost ratio. A high margin, high-service item uses an upper quantile. A perishable item with high disposal cost uses a lower one. The same predictive distribution can support multiple policies by changing the cost ratio, which is why a calibrated distribution is more useful than one point forecast.
Multi-period inventory adds lead time, review cadence, minimum order quantities, capacity, substitution, allocation, and supplier reliability. In a base-stock policy, the order at time $t$ replenishes inventory position up to a target $S_t$, often built from demand over lead time plus safety stock:
$$S_t = \widehat{\mu}_{t:t+L} + z_\alpha \widehat{\sigma}_{t:t+L}.$$The temporal model supplies the distribution of demand over the protection interval; the inventory policy turns that distribution into a number of units. Evaluating the forecast alone is therefore incomplete. A model that improves WAPE but worsens the upper quantiles can increase stockouts. A model that improves RMSE by smoothing peaks can damage the very days the business cares about most.
2. Hierarchies, Intermittency, Promotions, and Cold Start
Retail demand is hierarchical. The same sales event contributes to a SKU-store-day series, a SKU-region-week series, a category-store-month series, and a company-total series. Forecasts that ignore the hierarchy can tell contradictory stories: every store forecast rises while the regional total falls. Reconciliation fixes this by constraining bottom-level forecasts to add up through a summing matrix $S$. If $b_t$ is the vector of bottom-level forecasts and $y_t = S b_t$ is the coherent hierarchy, reconciliation adjusts independent forecasts toward a coherent set while preserving as much signal as possible.
Intermittent demand creates a different failure mode. Spare parts and long-tail SKUs have many zeros punctuated by bursts. A smooth model can look accurate by predicting tiny positive demand every day, yet it does not answer the replenishment question: how many units should be in stock before a rare burst? Croston-style decompositions, hurdle models, count distributions, quantile methods, and sample-path simulation are all ways to model the gap between demand occurrence and demand size.
Promotions and price changes are legitimate drivers only when they are known at decision time. A future planned flyer, a scheduled holiday, and a supplier lead time can be valid known-future covariates. A realized competitor reaction, an emergency markdown, or the final promotion calendar after the planning cutoff is leakage. Cold start completes the difficulty: new products borrow strength from product metadata, category analogs, image or text embeddings, and foundation-model pretraining rather than from a long own-history series.
3. From Quantiles to Orders
The deployment pipeline has five stages: construct an as-of feature table, forecast a predictive distribution, reconcile the hierarchy, simulate or optimize the inventory policy, and evaluate the decision on a future block. The policy can be as simple as a reorder point or as rich as a mixed-integer program, but the same invariants hold. The split is time-ordered. Features are as-of. The baseline is named. The uncertainty is calibrated. The score is the decision cost, not just a forecasting loss.
import numpy as np
def order_quantity(samples, underage_cost, overage_cost, on_hand=0, on_order=0):
"""Newsvendor order from calibrated demand samples."""
service_quantile = underage_cost / (underage_cost + overage_cost)
target_stock = np.quantile(samples, service_quantile)
inventory_position = on_hand + on_order
return max(0, int(np.ceil(target_stock - inventory_position)))
rng = np.random.default_rng(7)
lead_time_demand = rng.negative_binomial(n=8, p=0.35, size=5000)
q = order_quantity(lead_time_demand, underage_cost=9.0, overage_cost=2.0, on_hand=11)
print(q)
This short function is the practical bridge from Chapter 19 to operations. Replace the negative-binomial samples with samples from an ETS model, a gradient-boosted quantile model, a DeepAR-style recurrent model, or a time-series foundation model. The decision line does not change. What changes is the audit: are the samples calibrated, coherent across the hierarchy, and generated only from information that would have been available when the order was placed?
4. Researcher Benchmark Map
| Domain task | Public benchmark | Temporal unit and split | Baseline to beat | Modern model family | Prediction metric | Decision-value metric | Leakage trap |
|---|---|---|---|---|---|---|---|
| Hierarchical retail demand | M5 Forecasting | SKU-store-day, rolling origin | Seasonal naive, ETS, LightGBM | Global deep forecaster, foundation model, reconciled quantile model | WRMSSE, pinball loss | Stockout plus holding cost at service target | Reconciliation or scaling fitted on full sample |
| Grocery promotion demand | Corporacion Favorita, M5-style panels | Item-store-day with known calendar cutoff | Seasonal naive with promotion features | Gradient boosting, TFT, demand foundation model | WAPE, quantile loss | Lost sales avoided and inventory budget used | Future promotions that were not planned at order time |
| Intermittent spare parts | Intermittent-demand and inventory datasets in forecasting archives | SKU-location period, blocked by time | Croston, SBA, TSB | Hurdle model, count model, sample-path forecaster | MASE, scaled pinball loss | Fill rate at fixed working capital | Zeros caused by stockouts treated as true zero demand |
| Forecast-then-optimize replenishment | Public retail panels plus simulated lead times and costs | Order date to protection interval | Historical quantile base-stock rule | Decision-focused learning, stochastic optimization, foundation forecast plus optimizer | Calibration and interval coverage | Total cost: stockout, holding, spoilage, ordering | Using realized lead time or realized price unavailable at order time |
5. Frontier Stack and Researcher Checklist
Recent demand-forecasting work is moving in three connected directions. First, foundation models for time series make cross-domain pretraining useful for demand panels that are too broad for bespoke modeling. Second, hierarchy-aware probabilistic methods reconcile not only means but distributions, so a category service target and a SKU service target can be evaluated together. Third, forecast-then-optimize work measures the value of the forecast inside the inventory decision, closing the loop that point metrics leave open.
A demand model is good when the order it induces performs well under the costs and constraints of the operation. That is why the right comparison is co-computed in one pass: same split, same demand samples, same lead-time assumptions, same cost table, same policy class. Forecast metrics help diagnose the model, but service level and cost decide whether the system works.
A practical stack is Nixtla's statsforecast, mlforecast, neuralforecast, and hierarchicalforecast for baselines, global models, rolling-origin evaluation, and reconciliation; gluonts or darts for probabilistic deep forecasters; and cvxpy, pyomo, or a solver-backed planning system for replenishment policies. Foundation-model APIs and open weights can sit in the forecast stage, but the same as-of split, calibration audit, reconciliation audit, and decision-cost audit still govern the result.
6. Exercises
A retailer reports lower RMSE after adding future promotion flags. Identify which flags are valid known-future covariates and which are leakage. Consider planned holiday flyers, emergency markdowns chosen after weak sales, supplier-funded campaigns approved before the order cutoff, and competitor reactions observed later. Explain how the answer changes for replenishment, pricing, and post-season analysis.
On an M5-style hierarchy, produce SKU-store quantile forecasts, reconcile them to category totals, and compare two reorder policies by stockout plus holding cost rather than WAPE alone. Report all compared numbers from one config: same split, same cost table, same lead time, same calibration window, and same demand realizations.
Choose a retail setting with cold start, sparse demand, and promotions. Design a benchmark comparing a seasonal naive model, a gradient-boosted global model, and a time-series foundation model in zero-shot and fine-tuned form. Define the point metric, calibration metric, hierarchy-coherence check, and inventory-cost metric, then state the smallest result that would convince you the foundation model is worth its added complexity.