USER GUIDEο
1. INTRODUCTIONο
PURPOSE AND SCOPEο
The NaivePyDESSEM Project Suite is a pedagogical framework designed to provide a transparent, modular, and fully reproducible environment for the study and experimentation of power system operation and expansion planning. The suite comprises three complementary packages β NaivePyDESSEM, NaivePyDECOMP, and MDI β which collectively simulate, analyze, and optimize short-term dispatch, medium-term operation, and data integration within the energy systems domain.
This User Guide is intended for researchers, graduate students, and professionals seeking to understand the internal logic, structure, and usage of the NaivePyDESSEM ecosystem. The document adopts a formal technical tone consistent with academic and professional documentation standards, offering detailed explanations of modeling principles, solver integration, data preparation, and output interpretation.
CONCEPTUAL FOUNDATIONSο
The NaivePyDESSEM family mirrors the conceptual hierarchy established in the CEPEL models β DESSEM for short-term operation, DECOMP for medium-term optimization, and MDI for long-term expansion planning β while maintaining a simplified yet analytically rigorous structure suitable for academic research and classroom experimentation.
Each package is built atop the Pyomo optimization framework, leveraging its declarative modeling language to define decision variables, constraints, and objective functions for deterministic and stochastic optimization problems. The design emphasizes clarity of implementation, mathematical transparency, and reproducibility, allowing users to directly inspect, modify, and extend each model component.
TARGET AUDIENCEο
This guide addresses three primary user profiles:
Students and Educators β who require a didactic framework for demonstrating fundamental principles of energy systems operation and optimization.
Researchers and Developers β who seek a modular foundation for developing or benchmarking novel optimization methodologies, including stochastic, metaheuristic, or decomposition-based approaches.
Industry Professionals β who wish to experiment with open, interpretable models before transitioning to large-scale proprietary tools.
SYSTEM REQUIREMENTSο
To ensure optimal performance and reproducibility, the following environment is recommended:
Operating System: Linux (preferred), macOS, or Windows 10/11.
Python Version: 3.9 or higher.
Required Dependencies:
pyomo,pandas,numpy,yaml,matplotlib, andmealpy(for metaheuristic integration).Optional Solvers:
GLPK,CPLEX,Gurobi, orIPOPT- Any solver, including open-source that works with Pyomo and meets the problemβs requirements will work with NaivePyDESSEM. Please refer to Pyomo Documentation and Solverβs Documentation for instalation instructions.
2. INSTALLATION GUIDEο
The following instructions describe the complete setup procedure for NaivePyDESSEM, including environment initialization, package installation, and solver configuration.
1. CREATE AND ACTIVATE A VIRTUAL ENVIRONMENTο
It is strongly recommended to install NaivePyDESSEM inside an isolated Python environment to ensure dependency consistency and avoid version conflicts.
# Create a virtual environment (Python β₯ 3.9 recommended)
virtalenv venv
# Activate the environment
# On Linux / macOS:
source venv/bin/activate
# On Windows (PowerShell):
venv\Scripts\activate
2. INSTALL NaivePyDESSEMο
OPTION A β FROM PyPI (RECOMMENDED FOR MOST USERS)ο
pip install naivepydessem
Optionally, install with some open-source solvers:
pip install naivepydessem[solvers]
OPTION B β FROM SOURCE (HTTPS)ο
git clone https://github.com/superflanker/NaivePyDESSEM.git
cd NaivePyDESSEM
pip install -e .
OPTION C β FROM SOURCE (SSH)ο
git clone git@github.com:superflanker/NaivePyDESSEM.git
cd NaivePyDESSEM
pip install -e .
3. BUILD PYOMO EXTENSIONSο
NaivePyDESSEM automatically installs Pyomo as a dependency.
However, certain solvers require Pyomoβs compiled extensions to be available.
Execute the following command once after installation:
pyomo download-extensions
pyomo build-extensions
4. INSTALL AND CONFIGURE OPTIMIZATION SOLVERSο
NaivePyDESSEM relies on external solvers for mixed-integer linear programming (MILP) and nonlinear optimization.
The following options are supported:
IBM CPLEXο
Install IBM ILOG CPLEX Optimization Studio from:
https://www.ibm.com/products/ilog-cplex-optimization-studioSet the environment variable
CPLEX_HOME(if not automatically configured).Verify installation:
cplex -version
GUROBIο
Install the Gurobi Optimizer from:
https://www.gurobi.com/downloads/Obtain an academic or trial license and activate it:
grbgetkey <license-key>Confirm installation:
gurobi_cl --version
SCIPο
Install SCIP Optimization Suite (open-source alternative):
https://www.scipopt.org/Depending on your platform:
# On Debian/Ubuntu sudo apt install scipopt # Or via conda (recommended) conda install -c conda-forge pyscipopt
Verify installation:
scip --version
5. VALIDATE THE ENVIRONMENTο
To confirm successful installation, open a Python session and run:
import pyomo as pyo
try:
import NaivePyDESSEM
except ModuleNotFoundError as e:
print(e)
try:
import NaivePyDECOMP
except ModuleNotFoundError as e:
print(e)
try:
import MDI
except ModuleNotFoundError as e:
print(e)
print("Pyomo version:", pyo.__version__)
If no errors occur, the environment is properly configured.
6. (OPTIONAL) UPGRADE OR UNINSTALLο
To upgrade:
pip install --upgrade naivepydessem
To uninstall:
pip uninstall naivepydessem
β INSTALLATION CHEATSHEET
Component |
Purpose |
Installation |
|---|---|---|
Virtualenv |
Isolated environment |
|
Virtualenv Activation |
Isolated environment |
|
NaivePyDESSEM |
Core library |
|
Pyomo Extensions |
Solver interfaces |
|
Solvers (CPLEX, Gurobi, SCIP) |
Optimization engines |
External installation required |
Note: Some solvers (e.g., CPLEX, Gurobi) require valid licenses.
Ensure environment variables (e.g., PATH, CPLEX_HOME, GUROBI_HOME) are correctly configured before executing optimization models.
3. PROBLEM FORMULATION AND MATHEMATICAL MODELINGο
This chapter formalizes the mathematical structures that underpin each model, providing a unified notation and formulation style across planning horizons. Each model is expressed as a mixed-integer or linear optimization problem, with explicit definitions of sets, parameters, decision variables, objective functions, and constraints.
Each model represents a specific temporal and operational scope within the decision hierarchy of the SIN (National Interconnected System):
DESSEM (Short-Term Hydrothermal Scheduling Model):
Formulates the hourly dispatch problem with detailed operational constraints for hydro, thermal, renewable, and storage units. It employs mixed-integer linear programming (MILP) formulations to capture short-term dynamics, including reservoir balance, ramping, and startup/shutdown logic.DECOMP (Medium-Term Hydrothermal Operation Model):
Represents weekly scheduling decisions using deterministic dual dynamic programming (PDDD). It approximates the inflow process and optimizes hydrothermal coordination under energy balance constraints, accounting for the trade-off between hydraulic and thermal generation costs.MDI (Long-Term Expansion Planning Model):
Determines the optimal investment and operation plan for generation and storage over a multi-year horizon. It is formulated as a Mixed-Integer Linear Programming (MILP) problem, aiming to minimize total system cost while satisfying capacity adequacy, reliability, and environmental criteria.
In summary, these models together form a consistent multi-horizon optimization chain:
Model |
Horizon |
Decision Type |
Mathematical Nature |
Main Objective |
|---|---|---|---|---|
DESSEM |
Short-term (hoursβdays) |
Operational dispatch |
MILP/MIQP/MINLP/LP |
Minimize operating cost |
DECOMP |
Medium-term (weeksβmonths) |
Operation planning |
Linear or PDDD |
Optimize hydrothermal coordination |
MDI |
Long-term (years) |
Expansion planning |
MILP |
Minimize investment + operation cost |
Each formulation in this chapter includes the complete definition of sets, parameters, decision variables, objective function, and constraints.
The presentation follows a standardized mathematical notation to facilitate comparison and integration across planning horizons.
MATHEMATICAL MODELING OF DESSEMο
HYDROPOWER PLANTSο
SETS AND INDICESο
\(\mathcal{T} = \{1,\dots,T\}\) β hourly periods
\(\mathcal{H} = \{\text{UHE}_1, \dots, \text{UHE}_{n_h}\}\) β hydropower plants
\(\mathcal{U}(h) \subseteq \mathcal{H}\) β set of upstream hydropower plants of \(h\)
PARAMETERS (DATA)ο
\(a_{h,t}\) β natural inflow to plant \(h\) in period \(t\) (m\(^3\)/s)
\(d_t\) β demand in period \(t\) (MWh/h)
\(\zeta_{\text{vol}}\) β volumeβflow conversion factor (hm\(^3\)/h) \(\Rightarrow \frac{3600}{10^6}\)
\(\zeta\) β hydraulic constant \(\Rightarrow \frac{9.81}{1000}\) (MW per m\(^3\)/sm of head)
\(V_{{\min}_h},\,V_{{\max}_h}\) β volume limits (hm\(^3\))
\(Q_{{\min}_h},\,Q_{{\max}_h}\) β turbined flow limits (m\(^3\)/s)
\(V_{{\text{ini}}_h}\) β initial reservoir volume (hm\(^3\))
\(V_{{\text{meta}}_h}\) β target terminal volume (hm\(^3\))
\(C_{{\text{def}}}\) β unitary cost of deficit ($/MWh)
\(\alpha_{h,k},\,\beta_{h,k},\,\gamma_{h,k}\) β polynomial coefficients for \(h_{\text{up}}\), \(h_{\text{down}}\), \(h_{\text{loss}}\)
\(\rho_{h,k}\) β polynomial coefficients of the specific productivity \(\rho_h\)
DECISION VARIABLESο
\(Q_{h,t} \ge 0\) β turbined flow (m\(^3\)/s)
\(S_{h,t} \ge 0\) β spillage (m\(^3\)/s)
\(V_{h,t} \ge 0\) β stored volume (hm\(^3\))
\(G_{h,t} \ge 0\) β hydropower generation (MWh/h)
\(D_{b,t} \ge 0\) β energy deficit (MWh/h)
HYDRAULIC POLYNOMIAL FUNCTIONS FOR PLANT \(h\)ο
\(\rho(Q, H_{\text{net}}) = \zeta \,\Big( \rho_0 + \rho_1 Q + \rho_2 H_{\text{net}} + \rho_3 Q H_{\text{net}} + \rho_4 Q^2 + \rho_5 H_{\text{net}}^2 \Big), \text{ (CEPEL, 2023)}\)
\(h_{\text{up},h}(V) = \sum_{k=0}^{K_a} \alpha_{h,k}\, V^k, \)
\(h_{\text{down},h}(q) = \sum_{k=0}^{K_b} \beta_{h,k}\, q^k,\)
\(h_{\text{loss},h}(Q) = \sum_{k=0}^{K_\gamma} \gamma_{h,k}\, Q^k.\)
HYDROPOWER PRODUCTION FUNCTION (HPF)ο
\(H_{{\text{net}}_{h,t}} = h_{\text{up},h}(V_{h,t})- h_{\text{down},h}(Q_{h,t}+S_{h,t}) - h_{\text{loss},h}(Q_{h,t}),\)
\(G_{h,t} = \zeta \, Q_{h,t}\, \rho_h(Q_{h,t}, H_{{\text{net}}_{h,t}})\, H_{{\text{net}}_{h,t}} \quad \textbf{(Exact HPF)},\)
\(G_{h,t} = \zeta \mathrm{PE} H_{{\mathrm{net}}_{h,t}} Q_{h,t} \quad \textbf{(HPF with constant PE)},\)
\(G_{h,t} = \mathrm{P} Q_{h,t} \quad \textbf{(Linearized HPF)}.\)
TOTAL INSTANTANEOUS INFLOW (CASCADE WITHOUT DELAY)ο
CONSTRAINTSο
GENERATIONο
RESERVOIR MASS BALANCEο
\(V_{h,1} = V_{{\text{ini}}_h} + \zeta_{\text{vol}} ( I_{h,1} - Q_{h,1} - S_{h,1}),\)
\(V_{h,t} = V_{h,t-1} + \zeta_{\text{vol}} ( I_{h,t} - Q_{h,t} - S_{h,t}), \quad \forall t=2,\dots,T.\)
TARGETS AND OPERATIONAL LIMITSο
\(V_{h,T} \ge V_{{\text{meta}}_h},\)
\(V_{{\min}_h} \le V_{h,t} \le V_{{\max}_h},\)
\(Q_{{\min}_h} \le Q_{h,t} \le Q_{{\max}_h},\)
\(S_{h,t},\, G_{h,t},\, D_t \ge 0.\)
THERMAL POWER PLANTSο
SETS AND INDICESο
\(\mathcal{T} = \{1,\dots,T\}, \quad\)
\(\mathcal{G} = \{\text{UTE}_1,\dots,\text{UTE}_{n_g}\}.\)
PARAMETERSο
\(d_t\) β system demand (MW)
\(P_{{\min}_g},\, P_{{\max}_g}\) β generation limits of plant \(g\) (MW) (CEPEL, 2023)
\(a_g,\, b_g,\, c_g\) β thermal cost coefficients of plant \(g\)
\(SC_g\) β startup cost of plant \(g\)
\(R U_g,\, R D_g\) β ramp-up/ramp-down rates (MW per interval)
\(t_{{\uparrow}_g},\, t_{{\downarrow}_g}\) β minimum up/down times (h)
\(C_{\text{def}}\) β deficit penalty cost (R$/MWh)
\(u_{g,0},\, p_{g,0}\) β initial on/off status and generation (from initial status data)
DECISION VARIABLESο
\(p_{g,t}\ge 0,\quad\)
\(u_{g,t}, y_{g,t}, w_{g,t}\in\{0,1\},\quad\)
\(D_t\ge 0.\)
(where \(u\) = on, \(y\) = startup, \(w\) = shutdown.)
CONSTRAINTSο
POWER BALANCEο
CONDITIONAL CAPACITYο
STARTUP/SHUTDOWN LOGICο
RAMPING LIMITSο
\(p_{g,t} - p_{g,t-1} \le RU_g + P_{{\max}_g} y_{g,t}\)
\(p_{g,t-1} - p_{g,t} \le RD_g + P_{{\max}_g} w_{g,t}\)
MINIMUM UP/DOWN TIMEο
\(\sum_{\tau=t-t^{\uparrow}_g+1}^{t} y_{g,\tau} \le u_{g,t},\)
\(\sum_{\tau=t-t^{\downarrow}_g+1}^{t} w_{g,\tau} \le 1-u_{g,t}.\)
CONSISTENT INITIAL CONDITIONSο
RENEWABLE ENERGIES AND STORAGEο
SETS AND INDICESο
\(\mathcal{T} = \{1,\dots,T\},\quad\)
\(\mathcal{R} = \{1,\dots,R_{n_r}\},\quad\)
\(\mathcal{S} = \{1,\dots,S_{n_s}\}.\)
PARAMETERSο
\(\overline{g}_{r,t}\) β exogenous renewable availability profile (MW avg)
\(\Delta t\) β time step (typically 1 h)
\(E_{{\min}_s},\,E_{{\max}_s}\) β energy storage limits (MWh)
\(E_{{\mathrm{ini}}_s}\) β initial energy (MWh)
\(\overline{P}_{{\mathrm{ch}}_{s}},\,\overline{P}_{{\mathrm{dis}}_{s}}\) β max charge/discharge power (MW)
\(\eta_{{\mathrm{c}}_{s}},\,\eta_{{\mathrm{d}}_{s}}\) β charge and discharge efficiencies
DECISION VARIABLESο
\(g_{{\mathrm{ren}}_{r,t}} \ge 0\) β dispatched renewable generation (MW)
\(E_{s,t} \ge 0\) β stored energy (MWh)
\(P_{{\mathrm{ch}}_{s,t}},\,P_{{\mathrm{dis}}_{s,t}} \ge 0\) β charging/discharging power (MW)
CONSTRAINTSο
RENEWABLE GENERATION β AVAILABILITY LIMITο
STORAGE β ENERGY BALANCE (SoC)ο
STORAGE β STATE OF CHARGE (SoC) LIMITSο
STORAGE β POWER LIMITSο
TRANSMISSION LINES AND CONNECTION BARSο
SETS AND INDICESο
\(\mathcal{T} = \{1,\dots,T\}\) β time periods (typically hourly)
\(\mathcal{L} = \{\text{LINE}_{1}, \dots, \text{LINE}_{n_\ell}\}\) β transmission lines
\(\mathcal{CB} = \{\text{BAR}_{1}, \dots, \text{BAR}_{n_b}\}\) β connection bars (buses)
\((i,j) \in \mathcal{E} \subseteq \mathcal{CB}\times\mathcal{CB}\) β ordered pair of bars defining endpoints of line \(\ell\)
\(\mathcal{L}(b)\) β set of lines incident to bar \(b\)
\(\mathcal{H}(b)\), \(\mathcal{G}(b)\), \(\mathcal{R}(b)\), \(\mathcal{S}(b)\) - generator attached to bar \(b\)
PARAMETERSο
\(b_{\ell}\) β susceptance of line \(\ell\) (p.u. or 1/x)
\(\overline{F}_{\ell}\) β transmission capacity limit (MW)
\(\theta_{b,0}\) β reference (slack) bus angle (rad)
\(p_{\text{base}}\) β system base power (MW)
\(b \in \mathcal{CB}\) β bar with associated demand \(d_{b,t}\) and deficit \(D_{b, t}\)
DECISION VARIABLESο
\(F_{\ell,t}\) β active power flow through line \(\ell\) (MW)
\(\theta_{b,t}\) β phase angle at bus \(b\) (radians)
DC FLOW APPROXIMATIONο
For each line \(\ell = (i,j)\) and time \(t\):
TRANSMISSION CAPACITY LIMITSο
POWER BALANCE AT EACH BUSο
Each bar \(b\) satisfies Kirchhoffβs Current Law (KCL) in the DC approximation:
where \(\delta_{b,\ell} = +1\) if bar \(b\) is the sending end of \(\ell\), \(-1\) if the receiving end, and \(0\) otherwise.
NETWORK REFERENCE (SLACK BUS)ο
One bar must be defined as the phase-angle reference:
BUS ANGLE LIMITSο
For non-slack buses, the phase-angle is restricted as follows:
OBJECTIVE FUNCTIONο
The hydrothermal dispatch problem is formulated as a minimization of total generation and deficit costs, including:
Thermal generation costs;
Deficit costs (represented by a thermal deficit unit with fixed cost, as per Unsihuay, 2023);
Penalty for reservoir spillage.
MATHEMATICAL MODELING OF DECOMPο
HYDROPOWER PLANTSο
SETS AND INDICESο
\(\mathcal{T} = \{1,\dots,T\}\) β periods
\(\mathcal{H} = \{\text{UHE}_1, \dots, \text{UHE}_{n_h}\}\) β hydropower plants
\(\mathcal{U}(h) \subseteq \mathcal{H}\) β set of upstream hydropower plants of \(h\)
PARAMETERS (DATA)ο
\(a_{h,t}\) β natural inflow to plant \(h\) in period \(t\) (hm\(^3\))
\(d_t\) β demand in period \(t\) (MWh)
\(V_{{\min}_h},\,V_{{\max}_h}\) β storage limits (hm\(^3\))
\(Q_{{\min}_h},\,Q_{{\max}_h}\) β turbined flow limits (hm\(^3\))
\(V_{{\text{ini}}_h}\) β initial reservoir volume (hm\(^3\))
\(V_{{\text{meta}}_h}\) β target terminal volume (hm\(^3\))
\(C_{{\text{def}_b}}\) β unitary cost of deficit ($/MWh)
DECISION VARIABLESο
\(Q_{h,t} \ge 0\) β turbined flow (hm\(^3\))
\(S_{h,t} \ge 0\) β spillage (m\(^3\))
\(V_{h,t} \ge 0\) β stored volume (hm\(^3\))
\(G_{h,t} \ge 0\) β hydropower generation (MWmed)
\(D_{b,t} \ge 0\) β energy deficit (MWh/h)
HYDROPOWER PRODUCTION FUNCTION (HPF)ο
CONSTRAINTSο
TOTAL INSTANTANEOUS INFLOW (CASCADE WITHOUT DELAY)ο
RESERVOIR MASS BALANCEο
THERMAL UNITSο
SETS AND INDICESο
PARAMETERSο
DECISION VARIABLESο
CONSTRAINTSο
CAPACITYο
RENEWABLE ENERGIES AND STORAGEο
SETS AND INDICESο
\(\mathcal{T} = \{1,2,\dots,T\} \quad\) β periods
\(\mathcal{R} = \{1,2,\dots,N_R\} \quad\) β set of renewable units (wind/solar)
\(\mathcal{S} = \{1,2,\dots,N_S\} \quad\) β set of storage units (batteries)
PARAMETERSο
For each \(t \in \mathcal{T}\), \(r \in \mathcal{R}\), and \(s \in \mathcal{S}\):
\(\overline{g}_{r,t} \text{ β exogenous renewable availability profile (MWmed)}\)
\(\Delta t \text{ β time step (T), typically } \Delta t = 1\)
\(E_{\min_s}, E_{\max_s} \text{ β min/max stored energy limits (MWh)}\)
\(E_{\text{ini}_s} \text{ β initial energy (MWh)}\)
\(\overline{P}_{\text{ch}_s}, \overline{P}_{\text{dis}_s} \text{ β maximum charge/discharge power (MW)}\)
\(\eta_{\text{c}_s}, \eta_{\text{d}_s} \in (0,1] β \text{ β charging and discharging efficiencies}\)
DECISION VARIABLESο
\(g_{\text{ren}_{r,t}} \ge 0 \text{ β dispatched renewable generation of unit } r \text{ at } t \text{ (MWavg)}\)
\(E_{s,t} \ge 0 \text{ β stored energy (SoC) of battery } s \text{ at } t \text{ (MWh)}\)
\(P_{\text{ch}_{s,t}}, P_{\text{dis}_{s,t}} \ge 0 \text{ β charge/discharge powers (MW)}\)
CONSTRAINTSο
RENEWABLE SOURCES β AVAILABILITY LIMITο
STORAGE β ENERGY BALANCE (SoC)ο
STORAGE - STATE OF CHARGE (SoC) LIMITSο
STORAGE β POWER LIMITSο
TRANSMISSION LINES AND CONNECTION BARSο
SETS AND INDICESο
\(\mathcal{T} = \{1,\dots,T\}\) β time periods (typically hourly)
\(\mathcal{L} = \{\text{LINE}_{1}, \dots, \text{LINE}_{n_\ell}\}\) β transmission lines
\(\mathcal{CB} = \{\text{BAR}_{1}, \dots, \text{BAR}_{n_b}\}\) β connection bars (buses)
\((i,j) \in \mathcal{E} \subseteq \mathcal{CB}\times\mathcal{CB}\) β ordered pair of bars defining endpoints of line \(\ell\)
\(\mathcal{L}(b)\) β set of lines incident to bar \(b\)
\(\mathcal{H}(b)\), \(\mathcal{G}(b)\), \(\mathcal{R}(b)\), \(\mathcal{S}(b)\) - generator attached to bar \(b\)
PARAMETERSο
\(b_{\ell}\) β susceptance of line \(\ell\) (p.u. or 1/x)
\(\overline{F}_{\ell}\) β transmission capacity limit (MW)
\(\theta_{b,0}\) β reference (slack) bus angle (rad)
\(p_{\text{base}}\) β system base power (MW)
\(b \in \mathcal{CB}\) β bar with associated demand \(d_{b,t}\) and deficit \(D_{b, t}\)
DECISION VARIABLESο
\(F_{\ell,t}\) β active power flow through line \(\ell\) (MW)
\(\theta_{b,t}\) β phase angle at bus \(b\) (radians)
DC FLOW APPROXIMATIONο
For each line \(\ell = (i,j)\) and time \(t\):
TRANSMISSION CAPACITY LIMITSο
POWER BALANCE AT EACH BUSο
Each bar \(b\) satisfies Kirchhoffβs Current Law (KCL) in the DC approximation:
where \(\delta_{b,\ell} = +1\) if bar \(b\) is the sending end of \(\ell\), \(-1\) if the receiving end, and \(0\) otherwise.
NETWORK REFERENCE (SLACK BUS)ο
One bar must be defined as the phase-angle reference:
BUS ANGLE LIMITSο
For non-slack buses, the phase-angle is restricted as follows:
OBJECTIVE FUNCTIONο
The hydrothermal dispatch problem is formulated as the minimization of total generation and deficit costs, namely:
Thermal generation costs
Deficit cost (represented by a thermal unit with fixed cost, as in Unsihuay, 2023)
Spillage penalty (energy waste)
For the PDDD case, the future cost term \(\alpha\) (FCF) is included
SINGLE LP OBJECTIVE FUNCTIONο
OBJECTIVE FUNCTION FOR PDDDο
MATHEMATICAL MODELING OF MDIο
The objective of this model is to determine the optimal expansion plan of the electric generation system, minimizing the total investment and operation cost, considering the availability of multiple technologies (hydroelectric, thermal, solar, wind, and battery storage), the demand satisfaction in two load levels (peak and off-peak), and the distinction between existing and candidate units.
This constitutes a Mixed-Integer Linear Programming (MILP) problem, solved by decomposition methods or Branch and Bound, as discussed in the theoretical overview.
SETSο
\(\mathcal{G}\) β total set of generating units (hydroelectric, thermal, solar, and wind)
\(\mathcal{G}_E \subset \mathcal{G}\) β subset of existing plants
\(\mathcal{G}_C \subset \mathcal{G}\) β subset of candidate plants
\(\mathcal{S}\) β total set of storage units (batteries)
\(\mathcal{S}_E \subset \mathcal{S}\) β subset of existing batteries
\(\mathcal{S}_C \subset \mathcal{S}\) β subset of candidate batteries
\(\mathcal{T}\) β planning periods
\(\mathcal{P}\) β load levels
\(\mathcal{L} = \{\text{LINE}_{1}, \dots, \text{LINE}_{n_\ell}\}\) β transmission lines
\(\mathcal{L}_E \subset \mathcal{L}\) β subset of existing transmission lines
\(\mathcal{L}_C \subset \mathcal{L}\) β subset of candidate transmission lines
\(\mathcal{CB} = \{\text{BAR}_{1}, \dots, \text{BAR}_{n_b}\}\) β connection bars (buses)
\((i,j) \in \mathcal{E} \subseteq \mathcal{CB}\times\mathcal{CB}\) β ordered pair of bars defining endpoints of line \(\ell\)
\(\mathcal{L}(b)\) β set of lines incident to bar \(b\)
\(\mathcal{G}(b)\) β set of generators attached to bar \(b\)
\(\mathcal{S}(b)\) β set of batteries attached to bar \(b\)
PARAMETERSο
\(C_{\text{inv}_g}\) β investment cost of generator \(g\)
\(C_{\text{op}_g}\) β operating cost of generator \(g\) [$ /MWh]
\(C_{\text{inv}_s}\) β investment cost of battery \(s\)
\(C_{\text{op}_s}\) β operating cost of battery \(s\) [$ /MWh]
\(C_{\text{inv},\ell}\) β investment cost of line \(\ell\)
\(C_{\text{op},\ell}\) β operation cost of line \(\ell\) [$ /MWh]
\(P_{\text{max}_g}\) β maximum capacity of generator \(g\) [MW]
\(E_{\text{max}_s}\), \(E_{\text{min}_s}\) β state-of-charge limits for battery \(s\) [MWh]
\(P_{\text{ch}_{\text{max}_s}}\), \(P_{\text{dis}_{\text{max}_s}}\) β maximum charge/discharge power of battery \(s\) [MW]
\(E_{0_s}\) β initial state of charge of battery \(s\) [MWh]
\(\eta_{c_s}\), \(\eta_{d_s}\) β charge/discharge efficiencies (0.95)
\(D_{b,p,t}\) β demand in load level \(p\) and period \(t\) [MW] per bus
\(h_p\) β duration of load level \(p\) [h/year]
\(x_{g,0}\) β 1 if generator \(g\) exists at the beginning of the horizon, 0 otherwise
\(x_{s,0}\) β 1 if battery \(s\) exists at the beginning of the horizon, 0 otherwise
\(x_{\ell,0}\) β 1 if line \(\ell\) exists at the beginning of the horizon, 0 otherwise
\(b_{\ell}\) β susceptance of line \(\ell\) (p.u. or 1/x)
\(\overline{F}_{\ell}\) β transmission capacity limit (MW)
\(\theta_{b,0,p}\) β reference (slack) bus angle (rad)
\(p_{\text{base}}\) β system base power (MW) (only for line transmission power conversion - optional if the system has no explicit topology)
DECISION VARIABLESο
\(y_{g,t} \in \{0,1\}\) β construction (1) or not (0) of candidate generator \(g\) in period \(t\)
\(y_{s,t} \in \{0,1\}\) β construction (1) or not (0) of candidate battery \(s\) in period \(t\)
\(y_{\ell,t} \in \{0,1\}\) β construction (1) or not (0) of candidate transmission line \(\ell\) in period \(t\)
\(x_{g,t} \in \{0,1\}\) β existence of generator \(g\) in period \(t\) (1 if built up to \(t\))
\(x_{s,t} \in \{0,1\}\) β existence of battery \(s\) in period \(t\) (1 if built up to \(t\)) _
\(x_{\ell,t} \in \{0,1\}\) β existence of transmission line \(\ell\) in period \(t\) (1 if built up to \(t\))
\(P_{g,t,p} \ge 0\) β generation of unit \(g\) in load level \(p\) and period \(t\) [MW]
\(P^{c}_{s,t,p} \ge 0\) β charging power of battery \(s\) in load level \(p\) and period \(t\) [MW/level]
\(P^{d}_{s,t,p} \ge 0\) β discharging power of battery \(s\) in load level \(p\) and period \(t\) [MW/level]
\(E_{s,t,p}\) β state of charge (SoC) of battery \(s\) [MWh]
\(F_{\ell,t,p}\) β active power flow through line \(\ell\) (MW)
\(\theta_{b,t,p}\) β phase angle at bus \(b\) (radians) and level \(p\)
CONSTRAINTSο
DEMAND REQUIREMENT PER BUSο
This ensures power balance at each period and load level: total net generation (generation plus storage balance) equals system demand.
CAPACITY ADEQUACYο
Guarantees that total available capacity (generation + discharge) is sufficient to meet demand in all time steps.
GENERATION LIMITSο
Ensures that generation of each unit does not exceed its maximum capacity and is zero when inactive.
STORAGE DYNAMICSο
Ensures energy continuity across load levels and periods, applying charge/discharge efficiencies and introducing initial energy only when the unit is built.
STATE OF CHARGE LIMITSο
Keeps the state of charge within the operational range, proportional to the unitβs availability.
CHARGE/DISCHARGE POWER LIMITSο
Restricts charging and discharging powers according to the installed battery capacity and availability.
EXPANSION DYNAMICS (EXISTENCE ACCUMULATION)ο
Guarantees temporal coherence of the expansion plan: units exist only if previously constructed.
DC FLOW APPROXIMATIONο
For the DC model, this constraint ensures that the power flow is proportional to the angular difference between the buses connected by the transmission line. In the transportation model, this constraint is disregarded. It is worth noting that the formulation of this constraint is valid only in cases where \(\sin(\theta_{i,t,p} - \theta_{j,t,p}) \approx \theta_{i,t,p} - \theta_{j,t,p}\), that is, for angular differences up to \(\frac{\pi}{6}\).
TRANSMISSION CAPACITY LIMITSο
Ensures that transmission power flow of each transmission line unit does not exceed its maximum capacity and is zero when inactive.
NETWORK REFERENCE (SLACK BUS)ο
One bar must be defined as the phase-angle reference:
BUS ANGLE LIMITSο
For non-slack buses, the phase-angle is restricted as follows:
UNIQUE CONSTRUCTIONο
Prevents multiple constructions of the same unit within the planning horizon.
MONOTONIC GROWTHο
Ensures that the set of existing units grows monotonically, avoiding deactivation after construction and maintaining temporal consistency in expansion.
OBJECTIVE FUNCTIONο
Where:
\(Z\) β total objective function value (minimum system cost)
\(t_x\) β discount rate (\(t_x \in [0,1)\))
\(C^{\text{inv}}_{g}, C^{\text{inv}}_{s} , C^{\text{inv}}_{\ell}\) β investment costs for generation and storage units [$]
\(C^{\text{op}}_{g}, C^{\text{op}}_{s}, C^{\text{op}}_{\ell}\) β operating costs for generation and storage units [$/MWh]
\(x_{g,t}, x_{s,t}, x_{\ell,t}\) β binary variables for existence of generation/storage units
\(P_{g,t,p}\) β generated power [MW]
\(P^{d}_{s,t,p}, P^{c}_{s,t,p}\) β discharging and charging powers [MW]
\(F_{l,t,p}\) - transmission line power flux [MW]
\(h_p\) β duration of load level \(p\) [h]
This objective minimizes total system cost across the planning horizon, combining investment and operating costs weighted by the duration of each load level. The formulation captures the trade-off between capacity expansion and operation, ensuring an economically optimal solution under technical and energy constraints.
4. MODEL ARCHITECTUREο
OVERVIEWο
The NaivePyDESSEM package follows a layered architecture that mirrors the hierarchical structure of the Brazilian energy models (MDI, DECOMP, and DESSEM).
Its design ensures separation between data ingestion, mathematical formulation, solver execution, and post-processing, allowing flexible experimentation, teaching, and research on hydrothermal coordination.
The architecture is implemented in Python 3.9+, following object-oriented principles and extensive documentation through docstrings compliant with the NumPy style guide.
The NaivePyDESSEM package follows a layered architecture that mirrors the hierarchical structure of the Brazilian energy models (MDI, DECOMP, and DESSEM).
Its design ensures separation between data ingestion, mathematical formulation, solver execution, and post-processing, allowing flexible experimentation, teaching, and research on hydrothermal coordination.
The architecture is implemented in Python 3.11+, following object-oriented principles and extensive documentation through docstrings compliant with the NumPy style guide.
PACKAGE HIERARCHYο
The repository is organized into three primary modules β NaivePyDESSEM, NaivePyDECOMP, and MDI β each corresponding to a specific temporal stage of the Brazilian hydrothermal planning chain.
The modular design ensures independent testing, scalability, and interoperability through a unified modeling interface based on Pyomo and YAML-driven configuration.
βββ src
β βββ MDI
β β βββ cli
β β β βββ __init__.py
β β β βββ cli.py
β β β βββ plot_cli.py
β β βββ ConnectionBar
β β β βββ __init__.py
β β β βββ ConnectionBarBuilder.py
β β β βββ ConnectionBarConstraints.py
β β β βββ ConnectionBarDataTypes.py
β β β βββ ConnectionBarEquations.py
β β β βββ ConnectionBarVars.py
β β βββ Generator
β β β βββ __init__.py
β β β βββ GeneratorBuilder.py
β β β βββ GeneratorConstraints.py
β β β βββ GeneratorDataTypes.py
β β β βββ GeneratorEquations.py
β β β βββ GeneratorObjectives.py
β β β βββ GeneratorVars.py
β β βββ Storage
β β β βββ __init__.py
β β β βββ StorageBuilder.py
β β β βββ StorageConstraints.py
β β β βββ StorageDataTypes.py
β β β βββ StorageEquations.py
β β β βββ StorageObjective.py
β β β βββ StorageVars.py
β β βββ TransmissionLine
β β β βββ __init__.py
β β β βββ TransmissionLineBuilder.py
β β β βββ TransmissionLineConstraints.py
β β β βββ TransmissionLineDataTypes.py
β β β βββ TransmissionLineEquations.py
β β β βββ TransmissionLineVars.py
β β βββ __init__.py
β β βββ Builder.py
β β βββ DataFrames.py
β β βββ Formatters.py
β β βββ ModelCheck.py
β β βββ ModelFormatters.py
β β βββ PlotSeries.py
β β βββ Reporting.py
β β βββ Solver.py
β β βββ Utils.py
β β βββ YAMLLoader.py
β βββ NaivePyDECOMP
β β βββ cli
β β β βββ __init__.py
β β β βββ cli.py
β β β βββ pddd_cli.py
β β β βββ plot_cli.py
β β βββ ConnectionBar
β β β βββ __init__.py
β β β βββ ConnectionBarBuilder.py
β β β βββ ConnectionBarConstraints.py
β β β βββ ConnectionBarDataTypes.py
β β β βββ ConnectionBarEquations.py
β β β βββ ConnectionBarVars.py
β β βββ HydraulicGenerator
β β β βββ __init__.py
β β β βββ HydraulicConstraints.py
β β β βββ HydraulicDataTypes.py
β β β βββ HydraulicEquations.py
β β β βββ HydraulicGeneratorBuilder.py
β β β βββ HydraulicObjectives.py
β β β βββ HydraulicVars.py
β β β βββ SimplifiedConstantProductivityFPH.py
β β βββ RenewableGenerator
β β β βββ __init__.py
β β β βββ RenewableConstraints.py
β β β βββ RenewableDataTypes.py
β β β βββ RenewableEquations.py
β β β βββ RenewableGeneratorBuilder.py
β β β βββ RenewableObjectives.py
β β β βββ RenewableVars.py
β β βββ Storage
β β β βββ __init__.py
β β β βββ StorageBuilder.py
β β β βββ StorageConstraints.py
β β β βββ StorageDataTypes.py
β β β βββ StorageEquations.py
β β β βββ StorageObjective.py
β β β βββ StorageVars.py
β β βββ ThermalGenerator
β β β βββ __init__.py
β β β βββ ThermalConstraints.py
β β β βββ ThermalDataTypes.py
β β β βββ ThermalEquations.py
β β β βββ ThermalGeneratorBuilder.py
β β β βββ ThermalObjectives.py
β β β βββ ThermalVars.py
β β βββ TransmissionLine
β β β βββ __init__.py
β β β βββ TransmissionLineBuilder.py
β β β βββ TransmissionLineConstraints.py
β β β βββ TransmissionLineDataTypes.py
β β β βββ TransmissionLineEquations.py
β β β βββ TransmissionLineVars.py
β β βββ __init__.py
β β βββ Builder.py
β β βββ BuilderPDDD.py
β β βββ DataFrames.py
β β βββ Formatters.py
β β βββ ModelCheck.py
β β βββ ModelFormatters.py
β β βββ PDDDMergeModels.py
β β βββ PlotSeries.py
β β βββ Reporting.py
β β βββ Solver.py
β β βββ SolverPDDD.py
β β βββ Utils.py
β β βββ YAMLLoader.py
β βββ NaivePyDESSEM
β β βββ cli
β β β βββ __init__.py
β β β βββ cli.py
β β β βββ plot_cli.py
β β βββ ConnectionBar
β β β βββ __init__.py
β β β βββ ConnectionBarBuilder.py
β β β βββ ConnectionBarConstraints.py
β β β βββ ConnectionBarDataTypes.py
β β β βββ ConnectionBarEquations.py
β β β βββ ConnectionBarVars.py
β β βββ HydraulicGenerator
β β β βββ __init__.py
β β β βββ ConstantProductivityFPH.py
β β β βββ ExactFPH.py
β β β βββ HydraulicConstraints.py
β β β βββ HydraulicDataTypes.py
β β β βββ HydraulicEquations.py
β β β βββ HydraulicGeneratorBuilder.py
β β β βββ HydraulicObjectives.py
β β β βββ HydraulicVars.py
β β β βββ PEFPH.py
β β β βββ SimplifiedConstantProductivityFPH.py
β β βββ RenewableGenerator
β β β βββ __init__.py
β β β βββ RenewableConstraints.py
β β β βββ RenewableDataTypes.py
β β β βββ RenewableEquations.py
β β β βββ RenewableGeneratorBuilder.py
β β β βββ RenewableObjectives.py
β β β βββ RenewableVars.py
β β βββ Storage
β β β βββ __init__.py
β β β βββ StorageBuilder.py
β β β βββ StorageConstraints.py
β β β βββ StorageDataTypes.py
β β β βββ StorageEquations.py
β β β βββ StorageObjective.py
β β β βββ StorageVars.py
β β βββ ThermalGenerator
β β β βββ __init__.py
β β β βββ ThermalConstraints.py
β β β βββ ThermalDataTypes.py
β β β βββ ThermalEquations.py
β β β βββ ThermalGeneratorBuilder.py
β β β βββ ThermalObjectives.py
β β β βββ ThermalPieceWise.py
β β β βββ ThermalVars.py
β β βββ TransmissionLine
β β β βββ __init__.py
β β β βββ TransmissionLineBuilder.py
β β β βββ TransmissionLineConstraints.py
β β β βββ TransmissionLineDataTypes.py
β β β βββ TransmissionLineEquations.py
β β β βββ TransmissionLineVars.py
β β βββ __init__.py
β β βββ Builder.py
β β βββ DataFrames.py
β β βββ Formatters.py
β β βββ ModelCheck.py
β β βββ ModelFormatters.py
β β βββ PlotSeries.py
β β βββ Reporting.py
β β βββ Solver.py
β β βββ Utils.py
β β βββ YAMLLoader.py
β βββ naivepydessem.egg-info
β βββ dependency_links.txt
β βββ entry_points.txt
β βββ PKG-INFO
β βββ requires.txt
β βββ SOURCES.txt
β βββ top_level.txt
βββ tests
βββ LICENSE
βββ MANIFEST.in
βββ pyproject.toml
βββ README.md
βββ requirements.txt
βββ setup.cfg
Each main module contains domain-specific subpackages:
cli/ β Command-line interfaces for model execution, plotting, and data export.
Generator/, HydraulicGenerator/, ThermalGenerator/, RenewableGenerator/, Storage/, ConnectionBar/, TransmissionLine/ β Contain builder, constraint, variable, and objective definitions for each asset type.
Builder.py β Central class responsible for assembling the Pyomo model using data and configuration inputs.
Solver.py β Wrapper for solver execution (CPLEX, Gurobi, SCIP) and result handling.
DataFrames.py, Reporting.py, PlotSeries.py β Modules for data manipulation, result visualization, and reporting in cli formats.
YAMLLoader.py β Responsible for reading model configurations, parameters, and instance data from YAML files.
ModelCheck.py and ModelFormatters.py β Implement internal consistency checks and formatting utilities for validation and debugging.
DESIGN OVERVIEWο
The architecture follows a layered modular pattern:
Data Layer β YAML configuration parsing, type definitions, and validation.
Model Layer β Definition of decision variables, constraints, and objectives for each subsystem.
Solver Layer β Interfaces with external solvers and manages solution logging.
Visualization Layer β Generation of time series plots and value/CTRL tables in LaTex format.
This hierarchy promotes clarity, reusability, and transparency in both model development and numerical experimentation.
π§ COMMAND-LINE INTERFACE (CLI)ο
Each module provides a lightweight command-line interface (CLI) that allows direct model execution and visualization without requiring manual scripting.
Each command-line tool encapsulates a complete modeling workflow, including:
YAML-based configuration parsing;
Model construction and validation;
Solver execution and result export;
Optional visualization and reporting.
The CLI is implemented with the Click framework, ensuring cross-platform compatibility, structured argument parsing, and reproducibility through declarative configuration files.
1. SOLVING A MODELο
Each model variant can be solved directly via its respective command-line entry point.
Input data and settings are defined in a YAML file describing system topology, parameters, and solver options.
DESSEM-like dispatch (short-term)
Solves the hourly hydrothermal scheduling problem.
pydessem-solve path/to/case.yaml --out_dir results/ --out_file dispatch.csv
DECOMP-like dispatch (short-term)
Single-LP (Linear Program):
pydecomp-solve path/to/case.yaml --out_dir results/ --out_file dispatch.csv
Using PDDD (Deterministic Dual Dynamic Programming):
pydecomp-pddd-solve path/to/case.yaml --out_dir results/ --out_file dispatch.csv
MDI-like generation expansion planning (long-term) Determines the optimal multi-year investment and operation plan.
mdi-solve path/to/case.yaml --out_dir results/ --out_file dispatch.csv
2. PLOTTING RESULTSο
pydessem-plot results/dispatch.csv --mode plot --category G V --plot-style line
pydecomp-plot results/dispatch.csv --mode plot --category G V --plot-style line
mdi-plot results/dispatch.csv --mode plot --category G --plot-style line
5. CLI ARGUMENTSο
1. SOLVER CLIο
All solver commands share three common command-line arguments:
{yaml_file}β the first positional argument, corresponding to the YAML input file defining the case configuration.--out_dirβ the output directory where the resulting case solutions (CSV, Excel, or Parquet) will be saved.--out_fileβ the name of the results file to be generated.
All three arguments are mandatory.
2. PLOT CLIο
The basic plot CLI commands share the following options:
input_file
Path to the input data file.
Supported formats:.csv,.xlsx,.parquet.--mode
Defines the export or visualization mode.
Options:tableβ Generates a LaTeX-formatted table.plotβ Creates a graphical plot (line or bar).ctrlβ Exports a control matrix (U/Y/W).
--category,-c
Specifies one or more variable categories to visualize or export.
Example:--category G ctrl BAT cost.--plot-style
Defines the plot style when--mode plotis selected.
Options:lineβ Line plot.barβ Bar plot.
--stacked
Enables stacked bars (applies only to bar plots).
Useful for cumulative or component-based visualizations.--level
Specifies the generation level for categories such asGorGT.
Example:--level Pontaor--level Fora.--title
Custom title for the plot or caption for LaTeX table output.--ylabel
Y-axis label for plots (e.g., βEnergy [MWh]β).--out-dir
Output directory for the generated file.--out-file
Name of the output file (plot image or.textable).--label
LaTeX label identifier for referencing generated tables or figures.
6. YAML CONFIGURATIONο
All models in the NaivePyDESSEM suite are configured via YAML files, which define system data, solver settings, and simulation parameters in a human-readable format.
π§© STEP-BY-STEP: BUILDING A DESSEM CONFIGURATION FILEο
This section provides a structured walkthrough for creating a NaivePyDESSEM configuration file (.yaml), guiding the user through each key section β from meta information to hydropower, thermal, renewable, and storage data.
All keywords, indentation levels, and formats must follow the conventions shown below.
πͺΆ 1. HEADER AND METADATA (meta)ο
Start by defining general model information and global parameters under the meta: key.
This section includes the case name, time horizon, solver options, and system demand.
meta:
name: "CaseName-Study1" # Descriptive case identifier
horizon: 24 # Number of hourly periods (e.g., 24 for one day)
p_base: 1_000 # Base Power (defaults to 1.0 when not defined)
delta_t: 1.0 # Duration of each time step [h]
Cdef: 1000.0 # Deficit penalty cost [$ / MWh]
c_pmax: 10_000 # Deficit max power
Solver: mindtpy # Main solver (MILP/MINLP)
Solver_Options: # Optional fine-tuning of solver parameters
mip_solver: cbc
nlp_solver: cyipopt
strategy: OA
time_limit: 300
demand: [700, 750, 850, 950, 1000, 1100, 1150, 1200,
1250, 1400, 1500, 1400, 1400, 1300, 1400, 1600,
1700, 1900, 2000, 1800, 1300, 1100, 900, 800] # MW per hour
π Notes
horizondefines the number of time intervals (typically 24 for daily cases).Cdefimposes a high penalty to discourage energy deficits.Cdefanddemanddefined in meta section are used to create a connection bar if none is definedSolver_Optionscan be adjusted according to the installed solvers (e.g.,cbc,gurobi, orcplex).
π 2. HYDROPOWER DATA (hydro)ο
Define hydraulic parameters, reservoir characteristics, and inflows for each hydro unit.
The hydro block starts with two constants β zeta (hydraulic constant) and zeta_vol (volumeβflow conversion factor) β followed by a units: dictionary.
hydro:
zeta: 0.00981 # MW per (m3/s * m)
zeta_vol: 0.0036 # hm3 per (m3/s * h)
units:
UHE_1:
bar: BAR_1 # optional for a one bar system - Cdef and demand are defined in meta section anyway
Qmin: 0.0 # Minimum turbined flow [m3/s]
Qmax: 600.0 # Maximum turbined flow [m3/s]
Vmin: 1000.0 # Minimum volume [hm3]
Vmax: 3000.0 # Maximum volume [hm3]
Vmeta: 2000.0 # Target final volume [hm3]
Vini: 2500.0 # Initial reservoir volume [hm3]
afluencia: [200, 210, 220, ..., 170] # Natural inflows [m3/s]
upstreams: [] # Upstream reservoirs (if any)
a: [4.012e+2, 5.010e-2, -1.573e-5, 3.297e-9, -2.883e-13] # h_up(V)
b: [3.719e+2, 1.932e-3, -8.530e-8, 2.376e-12, -2.616e-17] # h_down(Q+S)
rho: [6.895e-2, 3.007e-3, 5.559e-3, 5.840e-6, -4.637e-6, -3.636e-5] # Productivity curve
losses: [0.0, 0.0, 1.375e-5] # h_loss(Q)
pe: 0.92 # Specific productivity [MW/(m3/s)]
p: 0.92 # Global productivity (simplified)
mode: "exact" # {"constant","specific","exact","simplified"}
compute_total_inflow: true
π Notes
modeselects the type of hydraulic head computation.When using
"exact"or"specific", coefficientsa,b,rho, andlossesmust be provided.If the plant has upstream reservoirs, list them under
upstreams.
Add subsequent hydropower units (UHE_2, UHE_3, etc.) following the same structure.
π₯ 3. THERMAL DATA (thermal)ο
The thermal section defines each thermal generation unit, including operational limits and cost coefficients.
thermal:
units:
UT_1:
bar: BAR_1 # Optional for one bar system
Pmin: 150 # Minimum generation [MW]
Pmax: 455 # Maximum generation [MW]
RU: 50 # Ramp-up limit [MW/h]
RD: 50 # Ramp-down limit [MW/h]
a: 1000 # Fixed cost [$ / h]
b: 16.19 # Linear cost [$ / MWh]
c: 0.00048 # Quadratic cost [$ / (MWh)^2]
SC: 4500 # Start-up cost [$]
t_up: 8 # Minimum up-time [h]
t_down: 8 # Minimum down-time [h]
init_status_h: 8 # Initial on-state duration [h]
u0: 1 # Initial unit status (1 = on)
p0: 0.0 # Initial generation [MW]
gamma: 0.0 # Reserved for future use
pw_breaks: null # (optional) for piecewise cost
pw_costs: null # (optional) for piecewise cost
has_history: true # Indicates that initial conditions are defined
π Notes
Each UT_x corresponds to a thermal unit (e.g., gas or coal plant).
Cost coefficients follow a quadratic cost function:
\( C(p) = a + b\,p + c\,p^2 \)Use
has_history: trueto indicate the model should consider previous operational states.
π¬οΈ 4. RENEWABLE DATA (renewable)ο
This section defines renewable generation units such as wind (EOL) and solar (SOL), with their availability profiles.
renewable:
units:
EOL_1:
bar: BAR_1 # optional for one bar systems
gbar: [110, 112, 110, 105, 100, 85, 80, 60,
55, 50, 45, 40, 40, 45, 50, 55,
60, 80, 85, 100, 105, 110, 112, 110]
SOL_1:
bar: BAR_1 # optional for one bar systems
gbar: [0, 0, 0, 0, 0, 0, 40, 65,
90, 120, 140, 160, 170, 170, 160, 130,
100, 60, 20, 0, 0, 0, 0, 0]
π Notes
gbarrepresents the maximum available renewable power per hour (in MW).Values are typically derived from normalized wind or solar resource profiles.
The model will optimize dispatch up to these limits.
β‘ 5. STORAGE DATA (storage)ο
The storage block specifies battery storage characteristics, including energy and power constraints.
storage:
delta_t: 1.0
units:
BAT_1:
bar: BAR_1 # optional for one bar systems
Emin: 300.0 # Minimum state of charge [MWh]
Emax: 1500.0 # Maximum state of charge [MWh]
Eini: 400.0 # Initial stored energy [MWh]
Pch_max: 150.0 # Maximum charging power [MW]
Pdis_max: 150.0 # Maximum discharging power [MW]
eta_c: 0.95 # Charging efficiency
eta_d: 0.95 # Discharging efficiency
π Notes
The state of charge (SoC) evolves dynamically via the energy balance equation.
Ensure that
delta_tis consistent with the value defined inmeta.delta_t.
ππ² 6. TRANSMISSION LINES AND CONNECTION BARSο
Define the bars and lines sections as described below if you are modeling a multi-bar or multi-line system.
Once defined, these sections override the meta-level parameters for Cdef and demand.
# ===============================
# CONNECTION BARS (ConnectionBar)
# ===============================
bars:
units: # Dict[str, ConnectionBar]
BAR_1: # convention: {BAR}_{INDEX}
slack: True # Slack bus indicator
Cdef: 1000.0 # Deficit penalty [$/MWh]
c_pmax: 10_000 # Deficit max power
demand: [140, 150, 170, 190, # Demand time series (MW)
200, 220, 230, 240,
250, 280, 300, 280,
280, 260, 280, 320,
340, 380, 400, 360,
260, 220, 180, 160]
BAR_2: # Dict[str, ConnectionBar]
slack: False # Non-slack bus
Cdef: 1000.0 # Deficit penalty [$/MWh]
c_pmax: 10_000 # Deficit max power
demand: [560, 600, 680, 760, # Demand per bar (MW)
800, 880, 920, 960,
1000, 1120, 1200, 1120,
1120, 1040, 1120, 1280,
1360, 1520, 1600, 1440,
1040, 880, 720, 640]
# ===============================
# TRANSMISSION LINES (TransmissionLine)
# ===============================
lines:
units: # Dict[str, TransmissionLine]
LINE_1: # convention: {LINE}_{INDEX}
model: "dc" # Transmission model ("transport" or "dc")
b: 2.0 # Line susceptance (p.u.)
pmax: 1000 # Maximum power flow (MW)
endpoints: ["BAR_1", "BAR_2"] # Line endpoints (sending, receiving)
If no connection bar is defined, the model automatically reverts to single-bus mode (monobarra configuration). This ensures backward compatibility with models that do not employ explicit network topology.
β 7. FINAL CHECKSο
Before running the model:
Validate YAML indentation (2 spaces per level, no tabs).
Ensure lists (
[...]) have exactlyhorizonentries for time-dependent parameters.Confirm that all units are consistent (MW, MWh, mΒ³/s, hmΒ³).
Save the file as, for example:
DESSEM_CaseX.yaml
To execute:
pydessem-solve DESSEM_CaseX.yaml --out_dir results/ --out_file dispatch.csv
π§ SUMMARY
Section |
Keyword |
Description |
|---|---|---|
|
General model setup |
Time, solver, and demand |
|
Hydropower configuration |
Reservoirs, inflows, polynomials |
|
Thermal generation data |
Unit limits, cost curves, dynamics |
|
Renewable generation |
Solar and wind profiles |
|
Energy storage |
SoC, efficiency, charge/discharge power |
|
Connector |
network topology |
|
Wire Connection |
network topology |
This structure ensures full compatibility with NaivePyDESSEM, maintaining transparent, reproducible, and standardized model definitions for academic and professional use.
π§© STEP-BY-STEP: BUILDING A DECOMP CONFIGURATION FILEο
This section presents a detailed guide for constructing a NaivePyDECOMP configuration file (.yaml), representing a medium-term hydrothermal operation model based on the Brazilian DECOMP structure.
Each block must respect the same naming conventions, indentation, and parameter formatting as the example below.
πͺΆ 1. HEADER AND METADATA (meta)ο
The meta section defines the simulation scope, solver configuration, and demand series.
It establishes the number of time periods (typically months), the duration of each period, and the optimization solver.
meta:
name: "CaseName-DECOMP" # Case identifier
horizon: 12 # Number of monthly periods (e.g., 12 months)
delta_t: 1.0 # Duration of each period [months]
Cdef: 500.0 # deficit penalty [$ / MWh]
c_pmax: 10_000 # Deficit max power
p_base: 10_000 # base power (lines in p.u)
Solver: cbc # MILP solver
Solver_Options: # Optional solver fine-tuning
mip_solver: glpk
nlp_solver: cyipopt
strategy: OA
time_limit: 3600
demand: [100, 120, 150, 100, 120, 150, 100, 120, 150, 100, 120, 150]
π Notes
The demand vector (
demand) defines total system load per period (in MWmed or MWh/month).Cdefspecifies the cost of non-served energy, typically between 500β2000 R$/MWh.Solver configurations can be adapted for Gurobi or CPLEX when available.
π 2. HYDROPOWER DATA (hydro)ο
The hydro block contains reservoir and flow parameters for all hydroelectric plants.
Each unit is defined by physical limits, initial conditions, inflows, and upstream relationships.
hydro:
units:
UHE_1:
bar: BAR_1 # optional for one bar system
Qmin: 0.0 # Minimum turbined flow [hm3]
Qmax: 60.0 # Maximum turbined flow [hm3]
Vmin: 20.0 # Minimum storage [hm3]
Vmax: 100.0 # Maximum storage [hm3]
Vini: 100.0 # Initial volume [hm3]
afluencia: [16, 14, 11, 16, 14, 11, 16, 14, 11, 16, 14, 11]
upstreams: ['UHE_2'] # Upstream plant(s)
p: 0.95 # Specific productivity [MW/(hm3/month)]
compute_total_inflow: true
UHE_2:
bar: BAR_1 # optional for one bar system
Qmin: 0.0
Qmax: 80.0
Vmin: 40.0
Vmax: 200.0
Vini: 130.0
afluencia: [15, 12, 10, 15, 12, 10, 15, 12, 10, 15, 12, 10]
upstreams: [] # No upstream plants
p: 0.90
compute_total_inflow: true
π Notes
All flows and volumes are in hmΒ³, consistent with monthly scales.
pdefines the linear productivity for each plant in MW per hmΒ³/month.compute_total_inflow: trueensures automatic addition of upstream releases and spillage.
π₯ 3. THERMAL DATA (thermal)ο
The thermal block defines dispatchable thermal plants, typically simplified with constant cost and capacity limits.
thermal:
units:
UT_1:
bar: BAR_1 # optional for one bar system
Gmin: 0 # Minimum generation [MW]
Gmax: 30 # Maximum generation [MW]
Cost: 10 # Average operating cost [$ / MWh]
UT_2:
bar: BAR_1 # optional for one bar system
Gmin: 0
Gmax: 20
Cost: 25
π Notes
Each thermal unit contributes to meeting the demand and adds a fixed cost proportional to energy produced.
Units can be expanded to include ramping or startup constraints if needed.
π¬οΈ 4. RENEWABLE DATA (renewable)ο
Defines variable renewable generation (wind and solar) with exogenous availability profiles.
renewable:
units:
EOL_1:
bar: BAR_1 # optional for one bar system
gbar: [30, 25, 40, 30, 25, 40, 30, 25, 40, 25, 25, 40] # Wind generation [MW]
SOL_1:
bar: BAR_1 # optional for one bar system
gbar: [25, 20, 30, 25, 10, 30, 25, 10, 30, 10, 10, 30] # Solar generation [MW]
π Notes
The
gbarlist defines the available renewable power per month.Renewable energy is treated as non-dispatchable (upper bound).
The model optimizes renewable curtailment implicitly.
β‘ 5. STORAGE DATA (storage)ο
The storage section specifies battery-type energy storage systems with energy and power constraints.
storage:
delta_t: 1.0
units:
BAT_1:
bar: BAR_1 # optional for one bar system
Emin: 50.0 # Minimum state of charge [MWh]
Emax: 500.0 # Maximum state of charge [MWh]
Eini: 60.0 # Initial energy [MWh]
Pch_max: 50.0 # Maximum charging power [MW]
Pdis_max: 50.0 # Maximum discharging power [MW]
eta_c: 0.95 # Charge efficiency
eta_d: 0.95 # Discharge efficiency
π Notes
Monthly time steps imply slower charge/discharge dynamics compared to DESSEM.
Units are compatible with multi-period optimization and dual dynamic programming (PDDD) extensions.
ππ² 6. TRANSMISSION LINES AND CONNECTION BARSο
Define the bars and lines sections as described below if you are modeling a multi-bar or multi-line system.
Once defined, these sections override the meta-level parameters for Cdef and demand.
# ===============================
# CONNECTION BARS (ConnectionBar)
# ===============================
bars:
units: # Dict[str, ConnectionBar]
BAR_1: # convention: {BAR}_{INDEX}
slack: True # Slack bus indicator
Cdef: 500.0 # Deficit penalty [$/MWmed]
c_pmax: 10_000 # Deficit max power
demand: [20, 24, 30, # demand per bar (MWmed)
20, 24, 30,
20, 24, 30,
20, 24, 30]
BAR_2: # Dict[str, ConnectionBar]
slack: False # Non-slack bus
Cdef: 500.0 # Deficit
c_pmax: 10_000 # Deficit max power
demand: [80, 96, 120, # demand per bar (MWmed)
80, 96, 120,
80, 96, 120,
80, 96, 120]
# ===============================
# TRANSMISSION LINES (TransmissionLine)
# ===============================
lines:
units: # Dict[str, TransmissionLine]
LINE_1: # convention: {LINE}_{INDEX}
model: "dc" # Transmission model ("transport" or "dc")
b: 2.0 # Line susceptance (p.u.)
pmax: 10_000 # Maximum power flow (MW)
endpoints: ["BAR_1", "BAR_2"] # Line endpoints (sending, receiving)
If no connection bar is defined, the model automatically reverts to single-bus mode (monobarra configuration). This ensures backward compatibility with models that do not employ explicit network topology.
β 7. FINAL CHECKSο
Before execution:
Verify YAML structure (two-space indentation, no tabs).
Ensure all lists (
[...]) match the declaredhorizon(12 elements).Keep consistent units: MW, MWh, and hmΒ³.
Save as:
DECOMP_CaseX.yaml
Execute the model:
pydecomp-solve DECOMP_CaseX.yaml --out_dir results/ --out_file dispatch.csv
Or, using PDDD:
pydecomp-pddd-solve DECOMP_CaseX.yaml --out_dir results/ --out_file dispatch.csv
π§ SUMMARY
Section |
Keyword |
Description |
|---|---|---|
|
Simulation setup |
Time, solver, and demand definition |
|
Hydropower model |
Reservoirs, inflows, productivity |
|
Thermal units |
Capacity and cost |
|
Renewable generation |
Wind and solar data |
|
Energy storage |
Capacity, SoC limits, and efficiency |
|
Connector |
network topology |
|
Wire Connection |
network topology |
This template ensures full compliance with NaivePyDECOMP, promoting transparent modeling of hydrothermal coordination problems with monthly resolution.
π§© STEP-BY-STEP: BUILDING AN MDI CONFIGURATION FILEο
This document provides a comprehensive guide for constructing a NaivePyMDI configuration file (.yaml), used for generation expansion planning (long-term).
Each section defines parameters and structures that control investment, operation, and energy balance between peak and off-peak demand levels.
πͺΆ 1. HEADER AND METADATA (meta)ο
The meta section defines simulation parameters, solver configuration, and load segmentation into Ponta and Fora de Ponta levels.
meta:
name: "CaseName-MDI" # Case identifier
horizon: 10 # Number of planning periods (e.g., 10 years)
delta_t: 0.5 # Duration of each period [years]
parcel_investment: True # Annualize investment costs (True/False)
p_base: 100 # power base - lines in p.u
parcel_investment: True # Annualize investment costs (True/False)
interest_rate: 0.1 # interest rate
Cdef: 500 # deficit operational cost
c_pmax: 10_000 # deficit max power
Solver: cbc # MILP solver
Solver_Options:
mip_solver: glpk
nlp_solver: cyipopt
strategy: OA
time_limit: 3600
demand:
Ponta: [200, 350, 350, 400, 500, 600, 650, 750, 850, 1000]
Fora: [100, 150, 200, 250, 300, 350, 400, 450, 450, 500]
level_hours:
Ponta: 2000
Fora: 6740
level_precedence: ["Ponta", "Fora"]
π Notes
parcel_investment: Truespreads investment costs evenly across the horizon (annualized model).demanddefines two load segments β Ponta (peak) and Fora (off-peak) β each with a vector of MW values - levels are at your will, thereβs no rigid structure here, just follow what you define in level_hours and it would be fine.level_hoursspecifies the duration of each level in hours per year.The order of load levels is given by
level_precedence, ensuring temporal consistency.
βοΈ 2. GENERATOR DATA (generator)ο
The generator section defines generation units (existing and candidate) across multiple technologies β hydro, thermal, solar, wind, and deficit (penalty) units.
generator:
units:
UHE_1:
bar: BAR_1 # optional for one bar systems
state: 1 # Existing (1)
p_max: 600 # Installed capacity [MW]
c_op: 0 # Operating cost [$ / MWh]
c_inv: 0 # Investment + O&M cost [$]
include_cap: True # Include in capacity constraint
UHE_2:
bar: BAR_1 # optional for one bar systems
state: 0 # Candidate (0)
p_max: 500
c_op: 0
c_inv: 75_000_000
include_cap: True
UTE_1:
bar: BAR_1 # optional for one bar systems
state: 1
p_max: 250
c_op: 55
c_inv: 0
include_cap: True
UTE_2:
bar: BAR_1 # optional for one bar systems
state: 0
p_max: 250
c_op: 40
c_inv: 15_000_000
include_cap: True
SOL_1:
bar: BAR_1 # optional for one bar systems
state: 0
p_max: 100
c_op: 0
c_inv: 15_000_000
include_cap: True
EOL_1:
bar: BAR_1 # optional for one bar systems
state: 0
p_max: 100
c_op: 0
c_inv: 10_000_000
include_cap: True
π Notes
Each generator has a binary state:
1β existing plant, active from the first period;0β candidate plant, may be built during the horizon.
c_inv(investment) applies only to candidate units.The βDefβ (deficit) unit provides load balance at very high cost, enforcing the penalty mechanism.
include_capensures participation in the adequacy constraint (capacity margin).
β‘ 3. STORAGE DATA (storage)ο
The storage section defines battery systems with power and energy limits, as well as investment and operation costs.
storage:
delta_t: 0.5
units:
BAT_1:
bar: BAR_1 # optional for one bar systems
state: 0 # Candidate
c_op: 0 # Operating cost [$ / MWh]
c_inv: 5_000 # Investment + O&M cost [$]
Emin: 50.0 # Minimum state of charge [MWh]
Emax: 500.0 # Maximum state of charge [MWh]
Eini: 100.0 # Initial stored energy [MWh]
Pch_max: 300.0 # Maximum charging power [MW]
Pdis_max: 300.0 # Maximum discharging power [MW]
eta_c: 0.95 # Charge efficiency
eta_d: 0.95 # Discharge efficiency
include_cap: True # Include in capacity adequacy constraint
π Notes
The
stateflag distinguishes existing (1) and candidate (0) storage units.Efficiency parameters (
eta_c,eta_d) capture energy conversion losses.The model considers investment and operation costs for optimal expansion planning.
Storage units can offset peak demand, reducing thermal generation and investment needs.
ππ² 4. TRANSMISSION LINES AND CONNECTION BARSο
Define the bars and lines sections as described below if you are modeling a multi-bar or multi-line system.
Once defined, these sections override the meta-level parameters for Cdef and demand.
# ===============================
# CONNECTION BARS (ConnectionBar)
# ===============================
bars:
units: # Dict[str, ConnectionBar]
BAR_1: # convention: {BAR}_{INDEX}
slack: True # Slack bus indicator
Cdef: 5000.0 # Deficit penalty [$/MWmed]
c_pmax: 10_000 # Deficit max power
demand:
Ponta: [40, 70, 70, 80, 100,
120, 130, 150, 170, 200]
Fora: [20, 30, 40, 50, 60,
70, 80, 90, 90, 100]
BAR_2: # Dict[str, ConnectionBar]
slack: False # Non-slack bus
Cdef: 5000.0 # Deficit
c_pmax: 10_000 # Deficit max power
demand:
Ponta: [160, 280, 280, 320, 400,
480, 520, 600, 680, 800]
Fora: [80, 120, 160, 200, 240,
280, 320, 360, 360, 400]
# ===============================
# TRANSMISSION LINES (TransmissionLine)
# ===============================
lines:
units: # Dict[str, TransmissionLine]
LINE_1: # convention: {LINE}_{INDEX}
state: 1 # existing
c_op: 0 # Operating cost [$ / MWh]
c_inv: 0 # Investment + O&M cost [$] b: 2.0 # Line susceptance (p.u)
pmax: 10_000 # max_power flow (MW)
endpoints: ["BAR_1", "BAR_2"] # Line endpoints (sending, receiving)
If no connection bar is defined, the model automatically reverts to single-bus mode (monobarra configuration). This ensures backward compatibility with models that do not employ explicit network topology.
β 5. FINAL CHECKSο
Before running the simulation:
Validate YAML indentation and syntax (2 spaces per level).
Ensure both
PontaandForademand vectors have the same length as the planning horizon.Check that all capacity and cost parameters are positive and consistent in units (MW, MWh, years).
Save as:
MDI_CaseX.yaml
Execute:
mdi-solve MDI_CaseX.yaml --out_dir results/ --out_file dispatch.csv
π§ SUMMARY
Section |
Keyword |
Description |
|---|---|---|
|
Simulation setup |
Time horizon, solver, and demand segmentation |
|
Generation units |
Capacity, investment, and operation costs |
|
Energy storage |
Dynamic SoC, efficiency, and investment data |
|
Connector |
network topology |
|
Wire Connection |
network topology |
This configuration schema fully aligns with MDI-Like model implemented, supporting deterministic or investment-based planning for academic, research, and professional applications.
7. MORE EXAMPLESο
A comprehensive collection of configuration files and command-line interface (CLI) usage examples is available at:
β‘οΈ GitHub Repository Of NaivePyDESSEM β Examples and Templates
This repository contains curated examples illustrating:
Complete YAML configurations for hydropower, thermal, renewable, and mixed systems;
Step-by-step demonstrations of CLI commands for simulation, and reporting;
Advanced case studies integrating multi-bar, multi-line, and storage modules;