Energy System Optimization with Julia
Hamburg University of Applied Science - Summer 2025
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.
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\)
Constraints:
Additional Sets:
Additional Variables:
Additional Constraints:
Sets:
Variables:
Constraints:
Additional Sets:
Additional Variables:
Additional Constraints:
Note
Note: Lecture IX uses technology-specific sets and variables (e.g., \(\mathcal{X}\) for electrolyzers, \(\mathcal{S}_{\text{El}}\) and \(\mathcal{S}_{\text{H2}}\) for storage types). Only the storage modeling provides a template for a more general framework formulation.
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.
Investment Variables:
Operational Variables:
Tip
Key Difference: Unlike Lecture IX’s technology-specific approach, Lecture XI introduces a general framework that can be adapted to different MES setups by simply configuring the sets and parameters, making it applicable to various energy system configurations beyond just 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}\)
# Variables and basic types
x = 5.0 # Float64
y = [1, 2, 3] # Vector{Int64}
z = Dict("a" => 1, "b" => 2) # Dict{String, Int64}
# Arrays and matrices
A = [1 2; 3 4] # Matrix
B = zeros(3, 3) # 3x3 zero matrix# Loops
for i in 1:10
println(i)
end
# Conditionals
if x > 0
println("Positive")
elseif x < 0
println("Negative")
else
println("Zero")
endusing DataFrames
# Create DataFrame
df = DataFrame(
generator = ["G1", "G2", "G3"],
capacity = [100, 150, 200],
cost = [50, 60, 45]
)
# Access and manipulate
df.capacity[1] = 120
df[!, :efficiency] = [0.8, 0.85, 0.9]using JuMP, HiGHS
# Create model
model = Model(HiGHS.Optimizer)
# Variables
@variable(model, p[g] >= 0) # Power output
@variable(model, u[g, t], Bin) # Binary commitment
# Objective
@objective(model, Min, sum(cost[g] * p[g] for g in generators))
# Constraints
@constraint(model, power_balance[t in time],
sum(p[g] for g in generators) == demand[t])
# Solve
optimize!(model). . .
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!
Lecture XII - Course Repetition and Summary | Dr. Tobias Cors | Home