Energy System Optimization with Julia
Hamburg University of Applied Sciences - Summer 2025
Important
You can take a handwritten DIN A4 sheet of paper with you!
Each point corresponds to approximately 1.5 minutes of work!
Before starting the exam:
A power system operator needs to optimize the economic dispatch of thermal generators to meet electricity demand. The system consists of:
Each generator has minimum and maximum power output limits. The wind turbines have zero variable cost but their output is limited by the forecast.
Define all sets, parameters, and variables required to model this Economic Dispatch problem. Use clear notation and explicitly state which elements are sets, parameters, and variables.
Based on your notation from 1.a, write the objective function for the Economic Dispatch problem.
Write all necessary constraints for the Economic Dispatch problem using your notation from 1.a.
Now extend the Economic Dispatch model to include Unit Commitment decisions. The generators can be turned on/off and have additional start-up costs.
Define the additional sets, parameters, and variables needed for the Unit Commitment problem.
Write the (a) objective function and (b) start-up variable definition for the Unit Commitment problem using your notation from 1.d. In addition, consider that (c) generator 1 and 2 use the same grid connection which is currently limited so that they cannot be on at the same time. An additional constraint is that (d) due to personnel reasons the startup of generator 3 has to be at least 3 timesteps away from startup of generator 4.
What is the main difference between Economic Dispatch and Unit Commitment problems? Explain in 2-3 sentences.
Explain what a “tight formulation” means in the context of Mixed-Integer Linear Programming (MILP) problems like Unit Commitment.
What is the purpose of storage systems in energy system optimization? Name three key constraints that are typically included in storage modeling.
Explain the concept of “two-stage stochastic programming” in the context of energy system design problems.
What are the main advantages of using Julia and JuMP for energy system optimization compared to other programming languages and modeling frameworks?
Programming Tips
The following Julia code contains four errors related to implementing an Economic Dispatch model. Identify and briefly describe each error.
# Load the necessary packages
using JuMP
using HiGHS
# Define the size of the problem instance
nrGenerators = length(generatorCosts)
nrWindTurbines = length(windForecast)
# Create model instance
dispatch = Model(HiGHS.Optimizer)
# Define variables
@variable(dispatch_model, p_g[g = 1:nrGenerators] >= 0)
@variable(dispatch_model, p_w[w = 1:nrWindTurbines] >= 0)
# Define objective
@objective(dispatch_model, Max,
sum(generatorCosts[g] * p_g[g] for g in 1:nrGenerators)
)
# Define the constraints
@constraint(dispatch_model,
power_balance,
sum(p_g[g] for g in 1:nrGenerators) + sum(p_w[w] for w in 1:nrWindTurbines) === demand
)
@constraint(dispatch_model,
generator_limits[g=1:nrGenerators],
p_g[g] <= maxPower[g]
)
@constraint(dispatch_model,
wind_limits[w=1:nrWindTurbines],
p_w[w] <= windForecast[w]
)
# Start optimization
solve_model(dispatch_model)
Write the Julia code to define a binary variable for generator commitment status in a Unit Commitment model. The variable should indicate whether generator g is on at time t.
Write the Julia constraint that links generator power output to its commitment status, ensuring that if a generator is off (u[g,t] = 0), its power output must be zero.
Remember
Good luck with your exam!
This test exam covers the main concepts from the Energy System Optimization course. Make sure to review the course materials and practice implementing the models in Julia.
Questions?
For more information about energy system optimization and Julia programming, refer to the course materials and the literature list in the general section of this course.
Lecture X - Intermission: Exam Preparation | Dr. Tobias Cors | Home