NaivePyDESSEM 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 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_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ο
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.
Power Balance (Load Supply)ο
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}}}\) β 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_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ο
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ο
Power Balance (Load Requirement)ο
The load balance constraint requires that the total generation from all available sources, plus battery discharge and any incurred deficit, exactly meets the system demand:
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{B}\) β total set of storage units (batteries)
\(\mathcal{B}_E \subset \mathcal{B}\) β subset of existing batteries
\(\mathcal{B}_C \subset \mathcal{B}\) β subset of candidate batteries
\(\mathcal{T}\) β planning periods (\(t = 1,\dots,10\))
\(\mathcal{P}\) β load levels (peak and off-peak)
Parametersο
\(C_{\text{inv}_g}\) β investment cost of generator \(g\) [R$ /MW]
\(C_{\text{op}_g}\) β operating cost of generator \(g\) [R$ /MWh]
\(P_{\text{max}_g}\) β maximum capacity of generator \(g\) [MW]
\(C_{\text{inv}_b}\) β investment cost of battery \(b\) [R$ /MW]
\(C_{\text{op}_b}\) β operating cost of battery \(b\) [R$ /MWh]
\(E_{\text{max}_b}\), \(E_{\text{min}_b}\) β state-of-charge limits for battery \(b\) [MWh]
\(P_{\text{bat}_{\text{max}_b}}\) β maximum charge/discharge power of battery \(b\) [MW]
\(E_{0_b}\) β initial state of charge of battery \(b\) [MWh]
\(\eta_{c_b}\), \(\eta_{d_b}\) β charge/discharge efficiencies (0.95)
\(D_{p,t}\) β demand in load level \(p\) and period \(t\) [MW]
\(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_{b,0}\) β 1 if battery \(b\) exists at the beginning of the horizon, 0 otherwise
Decision Variablesο
\(y_{g,t} \in \{0,1\}\) β construction (1) or not (0) of candidate generator \(g\) in period \(t\)
\(y_{b,t} \in \{0,1\}\) β construction (1) or not (0) of candidate battery \(b\) in period \(t\)
\(x_{g,t} \in \{0,1\}\) β existence of generator \(g\) in period \(t\) (1 if built up to \(t\))
\(x_{b,t} \in \{0,1\}\) β existence of battery \(b\) in period \(t\) (1 if built up to \(t\))
\(P_{g,p,t} \ge 0\) β generation of unit \(g\) in load level \(p\) and period \(t\) [MW]
\(P^{c}_{b,p,t} \ge 0\) β charging power of battery \(b\) [MW]
\(P^{d}_{b,p,t} \ge 0\) β discharging power of battery \(b\) [MW]
\(E_{b,p,t}\) β state of charge (SoC) of battery \(b\) [MWh]
Constraintsο
Demand Requirementο
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.
Initial Stateο
Defines the initial energy level for each battery, ensuring consistency in the dynamic storage model.
Expansion Dynamics (Existence Accumulation)ο
Guarantees temporal coherence of the expansion plan: units exist only if previously constructed.
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)
\(C^{\text{inv}}_{g}, C^{\text{inv}}_{b}\) β investment costs for generation and storage units [$]
\(C^{\text{op}}_{g}, C^{\text{op}}_{b}\) β operating costs for generation and storage units [$/MWh]
\(x_{g,t}, x_{b,t}\) β binary variables for existence of generation/storage units
\(P_{g,t,p}\) β generated power [MW]
\(P^{d}_{b,t,p}, P^{c}_{b,t,p}\) β discharging and charging powers [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
β β βββ 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
β β βββ __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
β β βββ 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
β β βββ __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
β β βββ 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
β β βββ __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/ β 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-pddsolve 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)
delta_t: 1.0 # Duration of each time step [h]
Cdef: 1000.0 # Deficit penalty cost [$ / MWh]
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.Solver_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:
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:
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:
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:
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:
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. 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 |
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 cost [$ / MWh]
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:
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:
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:
Gmin: 0 # Minimum generation [MW]
Gmax: 30 # Maximum generation [MW]
Cost: 10 # Average operating cost [$ / MWh]
UT_2:
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:
gbar: [30, 25, 40, 30, 25, 40, 30, 25, 40, 25, 25, 40] # Wind generation [MW]
SOL_1:
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:
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. 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 |
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)
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.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:
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:
state: 0 # Candidate (0)
p_max: 500
c_op: 0
c_inv: 75_000_000
include_cap: True
UTE_1:
state: 1
p_max: 250
c_op: 55
c_inv: 0
include_cap: True
UTE_2:
state: 0
p_max: 250
c_op: 40
c_inv: 15_000_000
include_cap: True
SOL_1:
state: 0
p_max: 100
c_op: 0
c_inv: 15_000_000
include_cap: True
EOL_1:
state: 0
p_max: 100
c_op: 0
c_inv: 10_000_000
include_cap: True
Def_1:
state: 1
p_max: 10000
c_op: 5000
c_inv: 0
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:
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. 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 |
This configuration schema fully aligns with NaivePyMDI, supporting deterministic or investment-based planning for academic, research, and professional applications.