Reservoir Flood-Control Release Scheduling¶
Background¶
A reservoir can create temporary flood-storage capacity by releasing water before a forecast inflow peak, then refill as the event passes. The schedule must respect both the safe storage range and the finite outlet capacity, while preserving an appropriate post-event inventory.
This example optimizes releases for a deterministic ten-day hydrograph. It is a compact water-resources optimal-control problem with explicit volumetric and flow units.
Water-balance model¶
Let \(S(t)\) be reservoir storage in million cubic meters and \(q(t)\) the controlled release in million cubic meters per day. The forecast inflow is
With precipitation, evaporation, seepage, and uncontrolled spill omitted, the lumped conservation equation is
The storage and release histories therefore satisfy the full-horizon identity
Objective and constraints¶
The horizon is \(T=10\ \mathrm{days}\). The normalized objective keeps storage near its 40 million m³ reference while discouraging unnecessary departure from a 5 million m³/day reference release:
Storage begins and ends at the same level,
so the optimizer cannot leave the reservoir depleted after the event. The operating constraints are
Variables, parameters, and units¶
| Symbol | Meaning | Value or unit |
|---|---|---|
| \(t\) | Time from start of forecast | day |
| \(S\) | Reservoir storage | million m³ |
| \(q_{\mathrm{in}}\) | Forecast inflow | million m³/day |
| \(q\) | Controlled downstream release | million m³/day |
| \(S_{\min},S_{\max}\) | Operating storage limits | \(20,\ 80\) million m³ |
| \(q_{\max}\) | Outlet-capacity limit | \(15\) million m³/day |
| \(J\) | Integral of normalized penalties | day |
Modeling choices and limits¶
The endpoint storage constraint makes the ten-day schedules comparable and represents an inventory-recovery requirement. The two cost terms are scaled before weighting, so their coefficients are not directly physical damage prices. A \(100\times2\) Lobatto mesh is used, and the initial release guess is the mean forecast inflow.
The hydrograph is assumed known perfectly. The model has one well-mixed storage volume, one ideal outlet, and no outlet ramp limit, routing delay, tailwater effect, spillway logic, evaporation, environmental minimum flow, downstream tributaries, forecast uncertainty, or receding-horizon update. It demonstrates deterministic release scheduling, not an operational flood rule curve.
Run the example¶
Save the figure without opening a window:
Independent numerical validation¶
The solution is reconstructed at 4,001 times. The script checks storage and release bounds and independently applies cumulative trapezoidal quadrature to \(q_{\mathrm{in}}-q\) over every prefix of the horizon. The reported residual is the maximum absolute mismatch in the conservation identity above, not merely the terminal volume error.
| Quantity | Verified value |
|---|---|
| Objective \(J\) | \(0.09006368\) |
| Minimum storage | \(36.589691\ \mathrm{million\ m^3}\) |
| Maximum storage | \(43.411201\ \mathrm{million\ m^3}\) |
| Peak release | \(15.000000\ \mathrm{million\ m^3/day}\) |
| Maximum full-horizon cumulative water-balance residual | \(2.248\times10^{-2}\ \mathrm{million\ m^3}\) |
The cumulative residual is \(0.02248\) million m³, or about \(22\,480\) m³. It is below the script's \(0.03\) million m³ validation tolerance; it reflects dense interpolation and numerical quadrature, not an unmodeled source of water. Peak release reaches the outlet-capacity constraint during the event.

Source code¶
See the complete runnable example:
examples/reservoir_flood_control.py.