Lecture V - Economic Dispatch Problem

Energy System Optimization with Julia

Author
Affiliation

Dr. Tobias Cors

Hamburg University of Applied Science - Summer 2025

Quick Recap from last Week

JuMP

  • JuMP is a package for modeling optimization problems in Julia
  • It allows you to describe optimization problems in a way that is easy to understand and solve
  • It is a powerful tool for modeling and solving optimization problems

. . .

Tip

Use meaningful variable names and comments to make your model easier to understand.

Bounds

  • Variables in optimization models often need upper and lower bounds
  • Bounds can be set when declaring variables or added later as constraints
  • Common bounds include non-negativity (\(\leq 0\)) and capacity limits

Constraints

  • Constraints define the feasible region of the optimization problem
  • Can be equality (\(=\)) or inequality (\(\geq, \leq\)) constraints
  • Multiple constraints can be added using loops or array comprehensions

. . .

Tip

Conditional constraints allow flexible and dynamic model formulations reflecting conditions and dependencies in the constraint application.

Solver

  • JuMP supports many different solvers like HiGHS, GLPK, Gurobi
  • Solvers are specialized for different problem types (LP, MIP, NLP)
  • Can set solver parameters to control solution process

Model Setup

  • Start by creating a model with Model()
  • Add variables, objective function, and constraints
  • Call optimize!() to solve the model
  • Access results through solution queries

. . .

Tip

Always check the solution status before using the results to ensure the model solved successfully.

Solutions from last Week

  • The tutorials from last week will again be available on Friday
  • You can access them in the project folder on Github
  • Click on the little cat icon on the bottom right

. . .

Tip

You can ask questions anytime in class or via email!

Introduction

Power System Basic Models: Economic Dispatch

Power system system with generators and an aggregated demand

  • Generators have to be dispatched to meet the demand at an infinitesimal moment
  • Generators have different costs and operational constraints

Economic Dispatch Problem

  • Objective: Minimize the cost of producing electricity
  • Constraints in the simplest case:
    • Demand must be met
    • Generators have limits on their power output
    • Renewable power injection
  • Decision variables:
    • Power output of thermal generators
    • Power output of renewables, e.g. wind

How does the mathematical model look like?

Problem Structure

Objective

Question: What could be the objective?

Minimize the electricity supply cost while satisfying the demand and adhering to the production capacity.

Available Sets

Question: What are sets again?

. . .

Sets are collections of objects.

. . .

Question: What could be the sets here?

. . .

  • \(\mathcal{G}\) - Set of thermal generators indexed by \(g \in \{1,2,...,|\mathcal{G}|\}\)
  • \(\mathcal{W}\) - Set of wind turbines indexed by \(w \in \{1,2,...,|\mathcal{W}|\}\)

Available Parameters

Question: What are possible parameters?

. . .

  • \(c^{var}_g\) - Cost of thermal generator \(g\in\mathcal{G}\) in [\(EUR/\text{MWh}\)]
  • \(c^{var}_w\) - Cost of wind turbine \(w\in\mathcal{W}\) in [\(EUR/\text{MWh}\)]
  • \(p^{\min}_g\) - Minimum power output of thermal generator \(g\in\mathcal{G}\) in [MW]
  • \(p^{\max}_g\) - Maximum power output of thermal generator \(g\in\mathcal{G}\) in [MW]
  • \(p^{f}_w\) - Forecasted power output of wind turbine \(w\in\mathcal{W}\) in [MW]
  • \(d^f\) - Forecasted demand in [MW]

Decision Variables?

We have the following sets:
  • Thermal generators indexed by \(g \in \{1,2,...,|\mathcal{G}|\}\)
  • Wind turbines indexed by \(w \in \{1,2,...,|\mathcal{W}|\}\)

. . .

Our objective is to:

Minimize the electricity supply cost while satisfying the demand and adhering to the production capacity.

. . .

Question: What could be our decision variable/s?

Decision Variables

  • \(p_g\) - Power output of thermal generator \(g\in\mathcal{G}\)
  • \(p_w\) - Power injection of wind turbine \(w\in\mathcal{W}\)

Model Formulation

Objective Function?

Our objective is to:

Minimize the electricity supply cost while satisfying the demand and adhering to the production capacity.

. . .

Question: What could be our objective function?

. . .

We need the following variables:
  • \(p_g\) - Power output of thermal generator \(g\in\mathcal{G}\)
  • \(p_w\) - Power injection of wind turbine \(w\in\mathcal{W}\)

Objective Function

We need the following parameters:
  • \(c^{var}_g\) - Cost of thermal generator \(g\in\mathcal{G}\) in [€/]
  • \(c^{var}_w\) - Cost of wind turbine \(w\in\mathcal{W}\) in [€/]

. . .

\(\text{Minimize} \quad \sum_{g=1}^{\mathcal{G}} (c^{var}_g p_g) + \sum_{w=1}^{\mathcal{W}} (c^{var}_w p_w)\)

Constraints

Question: What constraints?

  • generator limits
  • renewable power injection
  • Fulfill the power demand while maintaining power balance

Generator Limits Constraints?

The goal of these constraints is to:

Minimum and maximum power limits the power output of generators.

. . .

We need the following variables and parameters:
  • \(p_g\) - Power output of thermal generator \(g\in\mathcal{G}\)
  • \(p^{\min}_g\) - Minimum power output of thermal generator \(g\in\mathcal{G}\) in [MW]
  • \(p^{\max}_g\) - Maximum power output of thermal generator \(g\in\mathcal{G}\) in [MW]

. . .

Question: What could the constraint look like?

Generator Limits Constraints

\(p^{\min}_g \leq p_g \leq p^{\max}_g \quad \forall g\in\mathcal{G}\)

. . .

Remember, these are the variables and parameters:
  • \(p_g\) - Power output of thermal generator \(g\in\mathcal{G}\)
  • \(p^{\min}_g\) - Minimum power output of thermal generator \(g\in\mathcal{G}\) in [MW]
  • \(p^{\max}_g\) - Maximum power output of thermal generator \(g\in\mathcal{G}\) in [MW]

. . .

Question: What does \(\forall g\in\mathcal{G}\) mean?

Renewable Power Injection Constraints?

The goal of these constraints is to:

Renewable power injection into the grid or power balance is limited by the renewable power forecast, e.g. wind power.

. . .

We need the following variables and parameters:
  • \(p_w\) - Power injection of wind turbine \(w\in\mathcal{W}\)
  • \(p^{f}_w\) - Forecasted power output of wind turbine \(w\in\mathcal{W}\) in [MW]

. . .

Question: What could the second constraint be?

Wind Power Injection Constraints

:::

\(0 \leq p_w \leq p^f_w \quad \forall w\in\mathcal{W}\)

:::

. . .

Question: What kind of constraint is this? Think about what is limited.

Power Balance Constraints?

The goal of these constraints is to:

Maintain that produced and consumed power in the system is equal.

. . .

We need the following variables and parameters:
  • \(p_g\) - Power output of thermal generator \(g\in\mathcal{G}\)
  • \(p_w\) - Power injection of wind turbine \(w\in\mathcal{W}\)
  • \(d^f\) - Forecasted demand in [MW]

Power Balance Constraints

\[\sum_{g=1}^{\mathcal{G}} p_g + \sum_{w=1}^{\mathcal{W}} p_w = d^f\]

. . .

And that’s basically it!

Economic Dispatch: Objective Function

\(\text{Minimize} \quad \sum_{g=1}^{\mathcal{G}} (c^{var}_g p_g) + \sum_{w=1}^{\mathcal{W}} (c^{var}_w p_w)\)

The goal of the objective function and model is to:

Minimize the electricity supply cost while satisfying the demand and adhering to the production capacity.

Economic Dispatch: Constraints

\(p^{\min}_g \leq p_g \leq p^{\max}_g \quad \forall g\in\mathcal{G}\)$

\(0 \leq p_w \leq p^f_w \quad \forall w\in\mathcal{W}\)$

\(\sum_{g=1}^{\mathcal{G}} p_g + \sum_{w=1}^{\mathcal{W}} p_w = d^f\)$

Our constraints ensure:

Generator limits are respected, wind power is bounded by forecast, and power balance is maintained.

Economic Dispatch: Variable Domains

\(p_g \geq 0 \quad \forall g\in\mathcal{G}\)

\(p_w \geq 0 \quad \forall w\in\mathcal{W}\)

The variable domains make sure that:

All power outputs are non-negative.

. . .

Question: Are these necessary?

Economic Dispatch: Complete Model

\(\text{Minimize} \quad \sum_{g=1}^{\mathcal{G}} (c^{var}_g p_g) + \sum_{w=1}^{\mathcal{W}} (c^{var}_w p_w)\)

subject to

\(\sum_{g=1}^{\mathcal{G}} p_g + \sum_{w=1}^{\mathcal{W}} p_w = d^f\)

\(p^{\min}_g \leq p_g \leq p^{\max}_g \quad \forall g\in\mathcal{G}\)

\(0 \leq p_w \leq p^f_w \quad \forall w\in\mathcal{W}\)

Model Characteristics

Some Basics

There exist several types of optimization problems:

  • Linear (LP): Linear constraints and objective function
  • Mixed-integer (MIP): Linear constraints and objective function, but discrete variable domains
  • Quadratic (QP): Quadratic constraints and/or objective
  • Non-linear (NLP): Non-linear constraints and/or objective
  • And more!

Solution Algorithms

  • Simplex algorithm to solve LPs
  • Branch & Bound to solve MIPs
  • Outer-Approximation for mixed-integer NLPs
  • Math-Heuristics (e.g., Fix-and-Optimize, Tabu-Search, …)
  • Decomposition methods (Lagrange, Benders, …)
  • Heuristics (greedy, construction method, n-opt, …)
  • Graph theoretical methods (network flow, shortest path)

Model Characteristics

Questions: On model characteristics

  • Is the model formulation linear/ non-linear?
  • What kind of variable domains do we have?
  • What kind of solution algorithm could we use?

Model Assumptions

Questions: On model assumptions

  • What assumptions have we made?
  • What is the problem with the generator production and power balance?
  • Any idea how to solve it?

Impact

Can this be applied?

Utility companies

The ED problem is the smallest and simplest form of operational planning every utility company has to perform.

What are further considerations to make?

  • on/off status of system components -> unit commitment (UC) problem
  • efficiency losses
  • ramp rates
  • minimum up- and downtimes
  • storages -> multiple timesteps
  • uncertainty in forecasts

Any idea how to

adapt the ED to UC?

Power System Basic Models: Unit Commitment

  • considers binary decisions if a unit, e.g., thermal generator, in the power system is switched on or off
  • decision are made over a time horizon, which means that variables are also indexed by timesteps.

We will cover the unit commitment problem in the next lecture.

. . .

And that’s it for todays lecture!

We now have covered the basics of the ED and are ready to start solving some tasks in the upcoming tutorial.

Questions?

Literature

Literature I

For more interesting literature to learn more about Julia, take a look at the literature list of this course.

Literature II