ucd-cws / calvin

reservoir network optimization
MIT License
21 stars 13 forks source link
glpk network-flow-model optimization pyomo water-resources

CALVIN Network Flow Optimization Model

Network flow optimization of California's water supply system. Requires: NumPy/SciPy/Pandas (all available in the Anaconda Distribution, and Pyomo.

Recommended command-line method to install Pyomo:

conda install -c conda-forge pyomo

Recommended command-line method to install GLPK solver:

conda install -c conda-forge glpk

This will install the GLPK solver. Pyomo can also connect to other solvers, including CBC and CPLEX, and Gurobi. Installation of these solvers is not covered here. UC Davis: these are installed on HPC1 in /group/hermangrp/.

Recommended command-line method to install Gurobi solver:

conda install -c gurobi gurobi

Gurobi is a commercial solver but free for academic users. License activation is required for gurobi. Please see here

Quick Start

Running in parallel

Several of the solvers available through Pyomo support shared-memory parallelization. (Importantly GLPK is one exception that does not support parallelization). To take advantage of this, change the script above to include:

calvin.solve_pyomo_model(solver='gurobi', nproc=32, debug_mode=True)
# do the same again for the non-debug mode run

Several job scripts are included to support running on a SLURM cluster such as HPC1 at UC Davis. These will need to be customized for each system.

Example Data Visualization: Supply Portfoilio

In general, plotting results is left to the user. A few useful plot types will be included in calvin/plots.py. One example is the supply portfolio stacked bar chart, which plots the sum of flows by each region, supply type, and urban/agricultural link type:

PyVIN Supply Portfolio Figure

More Info

The Documentation describes the model in more detail. This refers to an earlier version of the model using Pyomo's AbstractModel type, but the setup is mostly the same in the current ConcreteModel. There is also detailed Pyomo documentation.