Energy System Optimization with Julia
Hamburg University of Applied Science - Summer 2026
This course has been organized into three main parts:
Tip
This repetition lecture will help you consolidate your understanding of all key concepts covered throughout the course.
Course arc: ED (V) → UC (VI) → UC + storage (VII) → stochastic design (VIII) → multi-energy design (IX) → general MES framework (XI).
for and while loops for iterationusing and importPkgSets:
Parameters:
Decision Variables:
Objective:
\(\min \sum_{g \in \mathcal{G}} c^{var}_g p_g + \sum_{w \in \mathcal{W}} c^{var}_w p_w\) (wind costs are typically zero)
Constraints:
Additional Sets:
Additional Variables:
Additional Constraints:
Sets:
Variables:
Constraints:
Objective:
\(\min \sum_{s} AC^{inv}_s + \sum_{w} AC^{inv}_w + \sum_{v} AC^{inv}_v + \sum_{\omega \in \Omega} \pi_{\omega} (AC^{grid,imp}_{\omega} - AR^{grid,exp}_{\omega})\)
First-stage variables: \(e^{nom}_s\), \(p^{ch,nom}_s\), \(p^{dis,nom}_s\), \(p^{nom}_w\), \(p^{nom}_v\)
Second-stage variables: \(p_{w,t,\omega}\), \(p_{v,t,\omega}\), \(p^{in}_{t,\omega}\), \(p^{out}_{t,\omega}\), \(p^{ch}_{s,t,\omega}\), \(p^{dis}_{s,t,\omega}\), \(e_{s,t,\omega}\)
Key constraints:
Additional Sets:
Additional Variables:
Additional Constraints:
Note
Lecture IX uses a technology-specific formulation (wind, PV, electrolyzer, storage subsets). Lecture XI generalizes this into a configurable framework — the hydrogen value chain is one specialization of that framework.
Note
Note: Lecture X was dedicated to test exam preparation, where students practiced exam-style problems together in class. This session focused on applying the concepts learned throughout the course to prepare for the final examination.
Sets (technology-agnostic):
Investment Variables:
Operational Variables:
Key constraint blocks:
Tip
Key Difference: Lecture IX models a specific hydrogen value chain. Lecture XI introduces a general framework that can be adapted to different MES setups by configuring sets (\(\mathcal{E}\), \(\mathcal{G}\)) and parameters (\(\sigma\), \(\Theta\)) — applicable beyond electricity-hydrogen systems.
\(\min f(x)\)
subject to:
\(g_i(x) \leq 0 \quad \forall i \in \mathcal{I}\) \(h_j(x) = 0 \quad \forall j \in \mathcal{J}\) \(x \in \mathcal{X}\)
Relevant for MILP problems such as Unit Commitment (Lectures VI–VIII) and exam preparation (Lecture X).
A formulation is tight when the LP relaxation is close to the integer optimum — solvers find solutions faster.
Example — generator commitment:
A formulation is compact when it uses fewer variables or constraints while remaining equivalent.
Example — minimum up time:
Note
Tightness and compactness involve a trade-off: tighter relaxations help the solver, while compact models reduce problem size. Choose based on problem structure and solver performance.
Note
Set naming convention: Mathematical sets (\(\mathcal{G}\), \(\mathcal{T}\), …) are defined as Julia variables (G, T, …) and used in JuMP as g in G, t in T. This is the standard pattern in all course tutorials. Lecture X exam examples sometimes use 1:nrGenerators when the set-up block is omitted.
using JuMP, HiGHS
model = Model(HiGHS.Optimizer)
# Sets (mirror mathematical notation 𝒢, 𝒯)
G = keys(dictThermalGenerators)
T = 1:length(scenario.datetime)
# Variables
@variable(model, p_g[g in G, t in T] >= 0)
@variable(model, u_g[g in G, t in T], Bin)
# Objective
@objective(model, Min,
sum(dictThermalGenerators[g].variable_cost * p_g[g, t] for g in G, t in T))
# Constraints
@constraint(model, power_balance[t in T],
sum(p_g[g, t] for g in G) == scenario.demand_forecast[t])
optimize!(model)# Link power to on/off status
@constraint(model, gen_max[g in G, t in T],
p_g[g, t] <= dictThermalGenerators[g].max * u_g[g, t])
# Minimum up time (compact formulation)
@constraint(model, min_up[g in G, t in T],
sum(u_g[g, tau] for tau in t:min(t + dictThermalGenerators[g].min_up_time - 1, T[end]))
>= dictThermalGenerators[g].min_up_time * (u_g[g, t] - u_g[g, t-1])). . .
Important
Remember: You can bring one handwritten DIN A4 sheet with notes to the exam!
. . .
Tip
The skills you’ve learned in this course are valuable for many careers in energy, operations research, and data science!
✅ Understanding Optimization: You can now recognize and formulate optimization problems
✅ Julia Programming: You can write, debug, and optimize Julia code
✅ Energy System Modeling: You understand how to model energy system problems
✅ Real-World Applications: You can apply optimization to practical energy problems
✅ Team Collaboration: You’ve worked effectively in groups on complex problems
. . .
Note
Thank you for your active participation throughout this course. Your questions and engagement have made this a rewarding experience for everyone!
For the full course bibliography, see the literature list.
Lecture XII - Course Repetition and Summary | Dr. Tobias Cors | Home