This script illustrates how to optimize the power generating schedule at Wolf Creek dam in order to minimize downstream violations in meeting the power target and without dropping below a specified target storage at Wolf Creek. There are 168 decision variables (release from Wolf Creek) and the objective function is
%% Cell type:code id:1ed54f38 tags:
``` python
# import required libraries
importpandasaspd
importpowersheds
importyaml
fromdataclassesimportdataclass
frompathlibimportPath
```
%% Cell type:code id:7a67ff6f tags:
``` python
# set up the model input
@dataclass
classReservoirData:
object_type:str
capacity:float
initial_storage:float
set_storage:list[float]
set_elevation:list[float]
tailwater_elevation:float
max_release:float
min_release:float
catchment_inflow:list[float]
target_release:list[float]
target_power:list[float]
hrpt_head:list[float]
hrpt_release:list[float]
hrpt_power:list[float]
simulation_order:int
downstream_object:str
@dataclass
classRiverData:
object_type:str
simulation_order:int
downstream_object:str
lag:int
legacy_flows:list[float]
@dataclass
classConfluenceData:
object_type:str
simulation_order:int
downstream_object:str
@dataclass
classCascadeData:
reservoirs:dict[str,ReservoirData]
rivers:dict[str,RiverData]
confluences:dict[str,ConfluenceData]
# Read the reservoir configuration
withopen('cascade_config.yaml','r')asfile:
config_dict=yaml.safe_load(file)
# Initialize dictionaries for reservoirs and rivers
reservoir_dict={}
river_dict={}
confluence_dict={}
forname,specsinconfig_dict.items():
#specs['simulation_order'] = simulation_orders[name] # Add simulation order to specs