Lecture X - Intermission: Exam Preparation

Energy System Optimization with Julia

Author
Affiliation

Dr. Tobias Cors

Hamburg University of Applied Sciences - Summer 2025

Intermission

Today’s lecture

  • Today’s lecture is a little bit different
  • Manage your expectations
  • Give you a better idea of what to expect from the exam
  • We will go through some examples together!

Energy System Optimization Exam

  • Duration: 90 minutes
  • Total Points: 60 points
  • Structure: Three parts (Modeling, Theory, Programming)
  • Allowed: One handwritten DIN A4 sheet

. . .

Important

You can take a handwritten DIN A4 sheet of paper with you!

Each point corresponds to approximately 1.5 minutes of work!

Exam Structure

  • Part I: Energy System Modeling (30 points)
  • Part II: Theory and Concepts (15 points)
  • Part III: Julia Programming (15 points)

Exam Preparation Checklist

Before starting the exam:

Part I

Energy System Modeling

1.a (8 Points)

A power system operator needs to optimize the economic dispatch of thermal generators to meet electricity demand. The system consists of:

  • Multiple thermal generators with different variable costs
  • Wind turbines with forecasted power output
  • A single aggregated demand that must be met

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.

1.b (4 Points)

Based on your notation from 1.a, write the objective function for the Economic Dispatch problem.

1.c (6 Points)

Write all necessary constraints for the Economic Dispatch problem using your notation from 1.a.

1.d (6 Points)

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.

1.e (6 Points)

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.

Part II

Theory and Concepts

2.a (3 Points)

What is the main difference between Economic Dispatch and Unit Commitment problems? Explain in 2-3 sentences.

2.b (3 Points)

Explain what a “tight formulation” means in the context of Mixed-Integer Linear Programming (MILP) problems like Unit Commitment.

2.c (3 Points)

What is the purpose of storage systems in energy system optimization? Name three key constraints that are typically included in storage modeling.

2.d (3 Points)

Explain the concept of “two-stage stochastic programming” in the context of energy system design problems.

2.e (3 Points)

What are the main advantages of using Julia and JuMP for energy system optimization compared to other programming languages and modeling frameworks?

Part III

Julia Programming

Hints

Programming Tips
  • Pay attention to variable names and consistency
  • Check for proper package imports
  • Verify array indexing
  • Remember to use the correct comparison operators
  • Make sure to use proper JuMP syntax

3.a (8 Points)

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)

3.b (4 Points)

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.

3.c (3 Points)

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.

Wrap Up

Key Takeaways

Remember
  • Time management is crucial (1.5 minutes per point)
  • Read questions carefully
  • Show your mathematical work clearly
  • Use your cheat sheet strategically
  • Double-check your Julia syntax

The end

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?

Literature

Literature

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.