Validation, error measures, and limits of interpretation
The Observatory answers a conditional question: how much of a measured import target can a network serve after specified capacity restrictions? The model can be evaluated at several levels, and each requires different evidence. A correct solution of the optimization problem is necessary. It does not, by itself, establish that the capacity assumptions predict an actual crisis.
1. Three kinds of evidence
| Question | Appropriate comparison | What a positive result establishes |
|---|---|---|
| Is the implementation numerically correct? | Feasibility, max-flow/min-cut equality, and independent optimization | The code solves the stated mathematical problem to the specified tolerance |
| Does a model forecast trade accurately? | Predictions formed from an earlier information set against held-out observations | Predictive performance for the defined sample, horizon, and data vintage |
| Would following a different allocation policy have improved outcomes? | A causal design or a structural counterfactual with defensible behavioral assumptions | A policy effect conditional on identification and model assumptions |
The browser demo primarily belongs to the first category. Its historical view describes recorded changes. It does not fit the scenario parameters to those changes and does not expose a forecasting or causal-estimation routine.
2. Numerical quantities to check
Use the notation in the model specification. Let be the reported allocation, the post-shock supply capacity, the route capacity, and the baseline import target. Let and be the first two optimal objective values.
Feasibility residual
An absolute feasibility residual in million barrels is
where . A corresponding relative residual divides by , where . Reporting both prevents a tiny relative error on a large panel from obscuring its absolute scale.
The chosen final allocation must also preserve the maximum service,
and satisfy the permitted fairness floor. The implementation relaxes the optimum minimum service fraction by before the final minimum-change problem. The correct numerical comparison uses that relaxation, rather than requiring equality to every last printed digit.
Flow-cut gap
For a source-to-sink cut , let be the sum of the capacities on its forward crossing arcs. The maximum-flow calculation supplies a residual-network cut. Its certificate is
Feasibility and a matching cut capacity certify the first objective up to numerical tolerance. They do not certify the fairness and minimum-change priorities. Those require separate checks.
Agreement with an independent solver
Let , , and be independently solved objective values, with
Compare
The third comparison should impose the same total-service constraint and fairness relaxation as the browser calculation. Otherwise the solvers are solving slightly different final-stage problems.
Two optimal allocations can have identical objective values and different individual edges. That is not necessarily an error. The model can have multiple optimal solutions, and its three priorities do not uniquely select every route. A review should compare feasibility, ordered objective values, country envelopes, and economically relevant aggregates before treating an elementwise difference as a failure.
3. Structural properties that a release should preserve
These properties follow from the optimization model and provide useful checks across different scenario inputs.
No-disruption feasibility. With nonnegative headroom and zero selected cut, the baseline is feasible. A corridor at zero cut is capped at its baseline quantity, which still permits the baseline. Maximum service should therefore equal within numerical tolerance.
Severity monotonicity. Holding every other input fixed, increasing a supply or corridor cut weakens capacities. Maximum service cannot increase and aggregate loss cannot decrease.
Capacity monotonicity. Holding the shock fixed, increasing replacement supply or ordinary route headroom cannot reduce maximum service. In complete-route mode, ordinary link expansion is not used, so changing that parameter should leave the model unchanged.
Complete-route dominance. Complete candidates admit at least every feasible allocation on existing routes under the same supply, demand, and selected-corridor restrictions. The finite candidate bound is no smaller than a feasible flow can require after accounting for its exporter and importer capacities. Complete support therefore cannot produce a greater aggregate shortfall than existing support, apart from numerical tolerance.
Full-closure feasibility. A fully closed route must carry zero modeled flow. A fully removed supplier must have zero total outgoing allocation.
Unknown-state preservation. An unavailable observed quantity should remain unavailable in observed-baseline and observed-change exports. A numerical reference of zero used for optimization must not change its observation label.
Display invariance. Map filters, the number of drawn edges, sorting, pagination, and zoom must not change any objective or exported full-network quantity.
Fresh-result integrity. Changing a scenario invalidates its old allocation. The interface must not label or export an earlier allocation as the result for new settings while an asynchronous solve is pending.
These are model and interface properties. Passing them establishes internal consistency under the saved data and inputs, not a probability that a historical outcome will fall within a particular range.
4. Reproducing the numerical review
The review scripts compare the released browser implementation with
an independent linear-programming formulation using the saved panels.
The browser implementation is in solver.js. The independent
formulation is in validate_reference.py,
with browser cases exported by export_cases.mjs.
Install the separate review dependencies from requirements-validation.txt.
They are needed for the numerical review, not for running the website.
The machine-readable result is review/validation-results.json.
Keep that result with the exact source revision and input data when
comparing releases.
From the repository root, with Python and Node.js installed, run:
python3 -m pip install -r requirements-validation.txt
python3 scripts/validate_reference.pyThe Python script invokes the Node.js exporter, constructs sparse linear programs without importing the browser’s capacity-building function, and solves them with SciPy’s HiGHS interface. The report records the data and solver file hashes, software versions, tolerances, individual cases, and discrepancies.
Results for this release
The numerical comparison includes 21 three-stage allocations: 17 cases using the saved country panels and four seeded small networks. It includes supplier cuts, a joint supplier cut, regional and bilateral restrictions, a known-zero corridor, complete candidates, and total supply loss. The review also compares 23 country-envelope calculations, 50 severity/support points, and eight paired route-support cases.
| Quantity compared | Largest absolute discrepancy |
|---|---|
| Maximum service | million barrels |
| Optimal minimum service fraction | |
| Minimum absolute flow change | million barrels |
| Primal feasibility and ordered-objective residual | million barrels |
| Flow-cut certificate | million barrels |
For scale, the maximum-service discrepancy is about 0.0000146 barrels and the absolute-flow-change discrepancy is about 0.0299 barrels. The volume comparisons use a tolerance of million barrels, the fairness comparison uses , and the final absolute-change comparison uses ten times the volume tolerance. These are acceptance tolerances. The observed discrepancies in the table are substantially smaller.
The recorded environment used Python 3.12.14, NumPy 2.3.5, SciPy 1.17.0, and Node.js 24.22.3. The cases passed under those settings. This is a reproducible check of numerical correspondence on the included cases. It is not an exhaustive proof for every possible input, and it does not measure historical predictive accuracy.
The saved reference section of the browser dataset
provides additional comparison values. Agreement with those values is a
regression check against a prior computation. Independent formulations
are stronger evidence because they do not merely repeat the same
implementation.
5. Define prediction errors before reporting goodness of fit
No forecast error below is a live output of the scenario monitor. These definitions specify how a separate historical predictive study should be reported.
Let be a declared set of comparable evaluation cells. A cell might be an exporter-importer-year or an importer-month. For each , let be the observed quantity, the prediction made without access to that target, and
Positive error means overprediction. All models must use the same evaluation cells when their scores are compared.
Mean absolute error
MAE is the average absolute volume error per evaluation cell. It has the same unit as the target. Its magnitude depends on whether the cell is a country-month or a bilateral annual flow.
Root mean squared error
RMSE also has volume units. Squaring makes it more sensitive than MAE to large misses. Reporting both helps distinguish a broad improvement from a few large failures.
Weighted absolute percentage error
WAPE expresses total absolute error as a percentage of total observed volume. It remains usable when some target cells are zero, provided total observed volume is positive. It is undefined when that denominator is zero.
Pooled WAPE gives greater practical weight to large-volume countries and routes. A low pooled WAPE can coexist with large relative errors for smaller countries. Report per-country WAPE or another country-level distribution alongside it.
Signed volume bias
Bias records systematic overprediction or underprediction of total volume. Positive and negative errors can cancel. A bias near zero does not imply good bilateral or country fit.
Coefficient of determination
With ,
This definition is meaningful only when the observed targets have nonzero variance. An out-of-sample value can be negative. It compares squared error with the sample-mean reference used in the denominator. It should not be interpreted as a causal fraction explained or used as the only accuracy measure.
Bilateral composition error
When totals are positive, define observed and predicted shares on the same evaluated cells,
Then
For nonnegative quantities this lies between zero and one. It measures disagreement in the distribution of trade, after removing the total-volume difference. It complements volume-error metrics. The historical view’s share turnover has the same mathematical form for two observations, but is a descriptive change measure rather than a prediction error.
Direction-of-change accuracy
If is a pre-specified baseline, compare the signs of and . Report the share of cases whose signs agree. A practical zero-change tolerance must be fixed in advance to avoid classifying numerical noise as a directional success or failure. Also report the size of the changes, because correct direction alone can conceal a very poor magnitude prediction.
Avoid a plain mean absolute percentage error over individual bilateral cells when observed zeros are frequent. Terms of the form are undefined at zero and can be dominated by very small denominators. Arbitrarily dropping those cells changes the evaluation sample.
6. Aggregation can conceal allocation error
For importer , define its observed and predicted total as and . The triangle inequality gives
Thus a model can have a small country-total error while assigning trade to the wrong suppliers. A world-total error can be even smaller because errors cancel across countries as well.
The reverse issue occurs in a conditional allocation exercise that imposes the realized importer totals as constraints. Its country totals match by construction. Their zero error is not forecast skill. Such an exercise should be evaluated on bilateral allocation and described as conditional on the supplied margins.
For a serious review, report aggregate error, country-total error, bilateral error, and the distribution across countries. State the mask and denominator for every score. Do not compare a model scored on easy, well-reported countries with another scored on a broader or less complete sample.
7. A defensible 2022 evaluation
A retrospective study of the Russia-Ukraine disruption should distinguish three experiments.
A forecast made before the event
Freeze the training period, country cohort, parameter-selection procedure, and usable information set before predicting the evaluation year or month. Compare against simple benchmarks such as unchanged prior-year trade or a seasonal lag. If a release delay is assumed, identify it explicitly and apply it to every input.
This experiment asks whether a model predicts held-out trade better than the benchmarks. Using a recently revised historical database still makes it a retrospective exercise unless the actual historical release vintages are reconstructed.
A conditional reconstruction
Supply realized exporter or importer totals and ask the model to allocate them across bilateral routes. This can reveal whether the route structure or allocation rule is useful. It does not test the ability to forecast the imposed totals.
A policy counterfactual
Ask what would happen under a different capacity or allocation policy. The Observatory supports this type of conditional capacity calculation. A comparison with observed trade still does not identify the benefit of implementing the policy. Actual outcomes can involve changes in prices, demand, inventories, contracts, infrastructure, and strategic behavior that the model does not represent.
These experiments can complement each other, but their conclusions should remain separate.
8. Adjusting the model without fitting away the test
An error analysis is useful for revising the model. It becomes misleading if the same outcomes are repeatedly used both to choose the revision and to advertise its performance.
A disciplined adjustment procedure is:
- Fix the baseline specification and record its prediction errors on a common mask.
- Identify a concrete failure, such as persistent underprediction for countries opening new import capacity or a mismatch concentrated around a structural break.
- Specify an ablation that addresses that mechanism. Examples include a jump term, a separate capacity-opening indicator, or a mixed-integer route-activation model.
- Select parameters on a calibration period or through rolling validation that respects information timing.
- Freeze the resulting rule before a later evaluation period.
- Report both the baseline and the ablation, including countries or periods where the revision performs worse.
A jump model requires a declared jump-detection rule and a clear account of when the trigger becomes observable. A binary route-activation variable requires defensible activation costs and capacity links. Adding integer variables does not inherently reduce forecast error. It changes the feasible decisions and may make calibration and computation more difficult.
These extensions are research ablations. The released browser solver is continuous and contains neither a jump-estimation routine nor an integer-programming optimizer. Its replacement-supply and route-expansion controls are scenario assumptions, not coefficients estimated from the user’s selected outcome.
9. Four different kinds of uncertainty
Measurement uncertainty concerns reported trade, missing quantities, conversion assumptions, and the data vintage. It is addressed through alternative defensible data treatments and explicit coverage reporting.
Parameter uncertainty concerns shock severity, spare supply, and route expansion. The sensitivity curves and grid vary these assumptions. They are deterministic scenario comparisons, not confidence bands.
Allocation uncertainty concerns multiple maximum-service allocations. Country envelopes show what a country can receive across the first-stage optimal set. Their endpoints come from separate optimizations and cannot generally be attained simultaneously. They are not probabilities or statistical confidence intervals.
Structural uncertainty concerns omitted mechanisms, such as prices, inventories, terminals, substitution, or dynamic adjustment. A narrow sensitivity range within the current model does not eliminate those omissions.
A report should identify which of these four it is discussing. Combining them under a single unlabeled error bar would hide the interpretation.
10. What the results support
The model supports comparisons such as:
- Under a stated supply reduction and capacity allowance, the measured network can serve a specified fraction of its baseline imports.
- Holding supply fixed, allowing complete candidate routes changes the achievable total service by a specified amount.
- A country has a narrow or wide range of feasible allocations at maximum aggregate service.
- A selected supplier or corridor becomes binding at a particular severity under the current assumptions.
- Recorded bilateral flows changed between two selected years on a specified matched observation set.
It does not establish that an observed import decline was an involuntary shortage, that a map arc was a physical shipping route, that the selected allocation was historically attainable on the relevant date, or that implementing it would have produced a measured welfare gain.
In particular, unchanged or fully recovered import volume can coexist with a large price shock. This release has no price objective or consumer-welfare measure. Its natural interpretation is a transparent capacity and allocation stress test, supported by descriptive trade evidence and numerical verification of the stated optimization.