This repository is the source code of paper Economic zone data-enabled predictive control for connected open water systems by X. Chen, X. Zhang, M. Han, A. W.-K. Law, and X. Yin.
python -m pip install -r requirements.txtYou may choose Bonmin or Knitro as the MINLP solver. Bonmin is used by default and is included with the official CasADi binaries. Knitro is a commercial software, which requires a separate installation and a valid license. Note that the results from different solvers are different. Knitro might be more robust when solving complex MINLP problems.
We demonstrate the proposed method on a simplified water system described below. Run python zdpc_mi_main.py --help for all controller, solver, horizon, regularization, and weighting options.
Run Bayesian optimization (BO)-based control target zone optimization with:
python zdpc_mi_main.py --system {system} --BO_opt --RDeePC_flag --gdpcThe default system is watersys_simple. After it finishes, pass the generated BO directory to:
python compute_optimal_zone.py results/{system}/{res_dir}The script reports the best evaluated zone ratio (best_observed) and the optimum of the fitted Gaussian-process posterior mean (gp_predicted).
We use gp_predicted.zone_ratio as the optimized zone ratio for final evaluation. Run closed-loop economic zone DeePC controller with:
python zdpc_mi_main.py --system {system} --RDeePC_flag --gdpc --zone_ratio 0.60Replace 0.60 with the value returned by your BO run. The control target zone ratio ranges from 0.0 (the zone center) to 1.0 (the desired zone).
Each run creates a new numbered directory under results/{system}/. Closed-loop results include the configuration and seeds in config.json, trajectories in data/, and a summary plot in fig/; BO results additionally include bayes_opt_log.log and the shared disturbance profile. Set RUN_DIR in plot_fig.ipynb to a result directory for further visualization.
The --seed parameter deterministically controls data generation, online disturbances, process noise, and BO sampling. After each run, the offline trajectories will be stored under data/{system}/offline_data by default. Use --offline_mode load and specific --seed to reuse the data for later runs.
The proposed economic zone DeePC approach combines three ideas:
- Data-enabled prediction. Hankel matrices constructed from offline input-output trajectories predict future behavior directly, without identifying an explicit state-space model.
- Lexicographic optimization. At each sampling instant, the upper level first minimizes water-level zone violation. The lower level then minimizes pump energy while constraining the zone-tracking loss to the upper-level optimum. Water-level regulation therefore has priority over energy saving.
- BO-based target-zone selection. BO selects a contraction ratio for a control target zone nested inside the desired zone. BO evaluates the trade-off between control performance and economic cost, and fits a Gaussian process surrogate to the resulting objective values.
The example contains one storage branch connected to an external river through one variable-speed outward pump and one outward sluice gate:
net inflow q_in
|
v
+-------------------+
| controlled branch | water level h
+-------------------+
| |
pump q_pump gate q_gate
| |
+-----+------+
v
external river h_out
Compared with the 14-branch system studied in the paper, this example uses a simplified network configuration and pump model. This example is provided to illustrate the implementation and workflow of the proposed method; it is not intended to reproduce the full case study presented in the paper.
If this code is useful in your research, please cite:
@article{chen2026economic,
title = {Economic zone data-enabled predictive control for connected open water systems},
author = {Chen, Xiaoqiao and Zhang, Xuewen and Han, Minghao and Law, Adrian Wing-Keung and Yin, Xunyuan},
journal = {Water Research},
volume = {291},
pages = {125181},
year = {2026},
doi = {10.1016/j.watres.2025.125181}
}The DeePC implementation is adapted from deepctools toolbox developed by Xuewen Zhang.