Validate and communicateLesson 57 of 76 · 7 min
Push the boundaries deliberately
Check invariants, extreme inputs and physical constraints before trusting an estimate.
An invariant is a relationship that should hold throughout the calculation, such as a probability lying between zero and one or a stock ledger never creating negative served demand. Extreme inputs can expose errors a typical case does not reach.
Test an inventory allocation rule with zero stock, zero demand and a demand far above stock. Served units must lie between zero and demand. Served plus unmet demand must equal demand. These accounting identities hold independently of any distribution used to generate demand.
Also test whether input units and supports are compatible with the model. An assertion that a sampled number is positive does not justify clipping an inappropriate generator. Stop and revise an invalid input or model rather than quietly transforming evidence until tests pass.
- Demand and stock
- Serve what is possible
- Check both ledgers
Which is stronger evidence for a ledger than merely getting a positive average?
Write a prediction (optional)
Seeded teaching simulation
Select Run Python below with the code unchanged.
A saved draft is open. To run the published example, open Tools and select Restore example. Recover draft brings your code back.
Execution error
Technical error details
Your result
Published example output
This result comes from the original Python. Your runs appear above. Build environment ↗
stock: 0 served: [0 0 0 0] unmet: [ 0 1 10 1000] stock: 5 served: [0 1 5 5] unmet: [ 0 0 5 995] stock: 100 served: [ 0 1 10 100] unmet: [ 0 0 0 900] Ledger invariants passed for extreme cases.
Read the first result
The ledger checks every listed trial. A mean can hide both positive and negative errors that cancel.
Try an edit
Replace served = np.minimum(demand, stock) with served = demand. Select Run Python again. Read the execution error. Which ledger condition fails when the model serves more than it has in stock? Open Tools, select Restore example and run once more to confirm Ledger invariants passed for extreme cases.
Scope. These invariants verify an allocation rule, not the empirical suitability of a demand forecast.
Try a fresh case
A model produces negative durations. What is the useful first response?
Need a hint?
Hint 1
Check whether the invalid result was generated or calculated.
Hint 2
State the revised assumption if you change the model.