Model Supply Allocation as a Minimum-Cost Flow with OR-Tools
This tutorial shows how to translate a supply-allocation problem into a minimum-cost-flow model with OR-Tools.
1. Build the network
Represent plants, warehouses and demand points as nodes. Represent feasible lanes as arcs.
2. Encode supply and demand
Assign available supply to origin nodes and required quantities to demand nodes. Reconcile totals or define an explicit mechanism for shortage and excess.
3. Add lane capacities
Use arc capacities for transport, handling or policy limits. Constraints that are genuinely hard should remain hard rather than being converted into weak penalties.
4. Add unit costs
Attach economically meaningful costs to flows. Keep artificial penalty costs clearly separated from observed transport or handling costs.
5. Solve and inspect
Review the selected flows, total cost and binding capacities. Large or counter-intuitive reallocations should trigger an assumption review.
6. Stress the model
Test demand spikes, capacity reductions and lane closures. Verify that the resulting reallocations remain feasible and understandable.
Failure controls
- Supply-demand reconciliation.
- Explicit infeasibility handling.
- Lane-capacity tests.
- Cost sensitivity analysis.
- Baseline comparison.
