Scenarios and SAA: deciding before demand is known
Sensitivity, two-stage decisions, VSS, and computational uncertainty for evaluating a logistics network.
Series: from data to logistics decisions
- From orders to a logistics network: an optimization and machine learning project
- MILP: turning a logistics decision into a verifiable model
- Linear relaxation: how much better could a solution become?
- Greedy and local search: build quickly, then improve deliberately
- LNS: reorganizing part of a network to escape a local optimum
- Predicting demand: from a population baseline to Poisson and boosting
- Population forecasting: trends, damping, and temporal testing
- K-means: finding municipal profiles without inventing natural categories
- Candidate scoring: learning to filter without losing good decisions
- Scenarios and SAA: deciding before demand is known
Investment precedes certainty
A warehouse is leased before every future order is known. Two-stage stochastic programming represents that sequence: choose centers first, then assign regions after observing a scenario, using the selected centers. It resembles choosing a room’s size before attendance is confirmed: seating can be rearranged afterward, but the building cannot magically expand.
Sample Average Approximation, or SAA, replaces the expectation with an average over training scenarios. The project generates mean-preserving multiplicative lognormal shocks; sigma controls dispersion, while rho is the share of latent normal shock variation common to all regions. Rho is not directly the final correlation between lognormal demands. A market growing simultaneously in many places requires that shared component to be considered.

A first small experiment
from alocacao_capacitada.analysis.study import tiny_instance
from alocacao_capacitada.analysis.stochastic import assess
report = assess(tiny_instance(), sigma=0.3, rho=0.5,
n_train=4, n_test=8, time_limit_s=2.0, seed=0)
print(report.rp, report.eev, report.ws)
print(report.vss, report.vss_ci95, report.max_solver_gap)
print(report.same_policy)These sizes explore the interface rather than provide strong statistical evidence. The time limit applies to multiple internal solves: two seconds does not mean two seconds for the entire experiment. To evaluate a policy, freeze its facility openings and solve assignments in new scenarios. Use the same test scenarios for both policies so that differences are paired.
What RP, EEV, WS, and VSS mean
In the report, RP is the stochastic policy’s mean test cost; EEV evaluates the policy designed for mean demand; WS allows center selection with each scenario already known. VSS=EEV−RP estimates the benefit of modeling uncertainty, and EVPI=RP−WS compares against perfect information. These are out-of-sample estimates with potentially approximate solves, not exact values for a fully known stochastic problem.
The implemented VSS interval uses the mean scenario difference plus or minus 1.96 standard errors. If it includes zero, the experiment does not clearly distinguish an advantage. This approximation is particularly fragile with few observations and does not itself include optimization error or uncertainty about scenario generation. Negative VSS requires investigating these factors before concluding that modeling uncertainty is harmful.
Separate sensitivity from robustness
Sensitivity asks what changes when a parameter changes. To stress higher demand, keep capacity and penalties fixed; increasing capacity too answers a different question. The integrated study tested an independent demand-capacity grid whose largest solver gap reached 44.99%. Small cost differences in those cells cannot support precise conclusions. Always read cost alongside service and computational quality.
For practical use, define minimum acceptable service, plausible scenarios, and investment budget before comparing policies. Then evaluate the same network without conveniently redesigning it for every future. The series ends where a responsible decision begins: algorithms organize evidence and alternatives, but operational assumptions must be checked against the operation that will actually be served.