You are on page 1of 49

Electricity Market Course

W3 Optimisation for Electricity Markets

Assoc. Prof. Hrvoje Pandžić


Marija Miletić

1
Contents
1. Introduction to Operational Research
2. Programming Languages and Solvers
3. Optimisation in Electricity Markets
4. The Exercises

2
INTRODUCTION TO
OPERATIONAL RESEARCH

3
Operational Research
 Operational Research is a discipline that
deals with the application of advanced
analytical methods to make better
decisions
 Used in the management of:
◼ Macroeconomics
◼ Corporate processes
◼ Natural sciences
◼ Engineering
◼ …

4
Applications of Operational Research

Source: Gacsályi-Meyer-Misz-Simonits: Economics II. Macroeconomics (National Textbook Publisher


2005.) – Hungary, svg version of Image

5
Applications of Operational Research

Source: Gernat, D.C., Brouwer, E. & Ottens, M. Aldehydes as Wort Off-Flavours in Alcohol-Free
Beers—Origin and Control. Food Bioprocess Technol 13, 195–216 (2020).
https://doi.org/10.1007/s11947-019-02374-z

6
Applications of Operational Research

Source: Newton, A. C. 2011. Social-ecological resilience and biodiversity conservation in a 900-year-


old protected area. Ecology and Society 16(4): 13.
http://dx.doi.org/10.5751/ES-04308-160413

7
Mathematical Programming

 Planning activities in order to achieve


the objective in the best of all possible
ways
 Key elements of mathematical
programming models are:
◼ Objective function
◼ Set of constraints

8
Linear programming

min 𝒄𝑇 ⋅ 𝒙 max 𝒄𝑇 ⋅ 𝒙
s.t. s.t.
𝑨⋅𝒙≥𝒃 𝑨⋅𝒙≤𝒃
𝒙≥0 𝒙≥0

9
Example 1
A girl who is very good at knitting wants to start
selling her products. She first needs to figure out is it
more profitable for her to make hats or gloves.
◼ For a hat, she needs 3 balls of yarn, and for a pair of
gloves she needs 2.
◼ It takes her 3 hours to knit a hat and 5 hours for the pair
of gloves.
◼ The profit she can make from selling the hats is 8 EUR
and from selling the gloves is 5 EUR.
◼ She can spend total of 30 hours knitting, and has 24
balls of yarn available.
How many products of each type should she knit to
achieve maximum profit?
10
Example 1

Available
Resource Hats Gloves
capacity

Time 3 5 30 hours

Yarn 3 2 24 balls

Profit per unit 8 EUR 5 EUR

Energy Storage Course


© Faculty of Electrical Engineering and Computing University of Zagreb 11
Example 1
 MIP problem formulation:
◼ xhats i xgloves – number of manufactured products of each type
◼ Z – profit
 The knitter can work at most 30 hours:
3 ⋅ 𝑥hats + 5 ⋅ 𝑥gloves ≤ 30
 She can use at most 24 balls of yarn:
3 ⋅ 𝑥hats + 2 ⋅ 𝑥gloves ≤ 24
 Since the produced quantities cannot be negative the
following constraints are imposed:
𝑥hats ≥ 0, 𝑥gloves ≥ 0

Energy Storage Course


© Faculty of Electrical Engineering and Computing University of Zagreb 12
Example 1

 Problem formulation:
max 𝑍 = 8 ⋅ 𝑥hats + 5 ⋅ 𝑥gloves
 Subject to:
3 ⋅ 𝑥hats + 5 ⋅ 𝑥gloves ≤ 30
3 ⋅ 𝑥hats + 2 ⋅ 𝑥gloves ≤ 24
𝑥hats ≥ 0
𝑥gloves ≥ 0

Energy Storage Course


© Faculty of Electrical Engineering and Computing University of Zagreb 13
Example 1
3 3
𝑨=
5 2
30
𝒃=
24
8
𝒄=
5
𝑥hats
𝒙=
𝑥gloves

14
Example 1: Feasible Region

15
Example 1: Graphical Solution

16
Linear Programming
„Linear Programming is viewed as a
revolutionary development giving us the ability
for the first time to state general objectives
and to find, by means of the simplex method,
optimal policy decisions to practical decision
problems of great complexity.”

George Dantzig

17
SOLVERS AND
PROGRAMMING LANGUAGES

18
Solvers and Programming Languages

 Solvers are tools for solving mathematical


programming problems
 Two parts of the solution process are
implemented in every solver:
◼ Solving continuous problem, e.g. by using
Simplex algorithm
◼ Solving mixed-integer problem, e.g. by branch-
and-bound method
 Programming languages enable us to use
solvers in a simple way

19
Analogy

Programming
language

Solver

Global optimum

20
Solvers
 CPLEX
◼ Solves linear and mixed-integer problems, as
well as more complex problems such as
quadratic programming
◼ Academic licence available
 Gurobi
◼ Solves linear problems, mixed-integer
problems, quadratic problems, etc.
◼ Academic licence available

21
Solver Resources
 Gurobi optimizer: https://www.gurobi.com/downloads/gurobi-
optimizer-eula/
 Gurobi academic license:
https://www.gurobi.com/academia/academic-program-and-
licenses/
 CPLEX optimisation studio:
https://www.ibm.com/support/pages/how-do-i-download-cplex-
optimization-studio
 CPLEX licensing: https://www.ibm.com/products/ilog-cplex-
optimization-studio/pricing

22
GAMS
 GAMS (General Algebraic Modeling
System) is a computer environment
developed to model and solve optimisation
problems
 The model written in GAMS is independent
from the solution method, and it can be
solved by different solution methods just by
changing solvers
 GAMS has its own sintax
 Available in the Department’s computer
labs

23
GAMS Resources
 Download: https://www.gams.com/download/
 Tutorials:
https://www.gams.com/latest/docs/UG_MAIN.html#UG_Tutorial_
Examples

24
Python
 A versatile programming language popular
for performing optimisation
 Each solver has its own additional
commans
 Very popular in combination with Gurobi
solver

25
Python Resources
 Download: https://www.python.org/downloads/
 Documentation: https://www.python.org/doc/
 Manual for setting-up: http://matthiaswalter.org/intpm/Gurobi-
Python3-Howto.pdf

26
MATLAB / YALMIP
 MATLAB is a a powerful programming
environment used for solving many
mathematical and technical problems
 YALMIP is a MATLAB toolbox for
optimisation and modelling
 Similar to GAMS, models written in
YALMIP can be solved by any solver
 YALMIP uses MATLAB sintax with
additional functions from the toolbox
27
MATLAB / YALMIP
 Installation tutorial: https://yalmip.github.io/tutorial/installation/
 YALMIP various resources: https://yalmip.github.io/

28
Comparison
MATLAB
GAMS Python
YALMIP

Solver independent
yes no yes
of the model

Solver integrated in
yes no no
the environment

Simple code for


yes no no
large models
MATLAB free
Python free, solver
License available academic, not free academic, solver free
free academic
academic

Possibility of
no yes yes
working from home

Possibility of me
debugging your no no no
code

29
OPTIMISATION IN
ELECTRICITY MARKETS

30
Electricity Markets
 Economic dispatch
 Unit commitment
 Network-constrained or unconstrained

31
Example 2: Economic Dispatch
Consider a centralised, network-unconstrained
day-ahead market with the following participants:
◼ 5 conventional generators, constrained by their
minimum and maximum capacity
◼ 4 perfectly inelastic suppliers
◼ 3 wind power plants, wind spillage is allowed with
a penalty
Write mathematical formulation of market
clearing for this market. Solve optimisation
problem for the input data given on the following
slides.

32
Example 2: Generators
Marginal cost
Generator Production bid [MW]
[EUR/MWh]

G1 120 30

G2 50 10

G3 100 40

G4 80 35

G5 70 20

33
Example 2: Suppliers

Supplier Demand bid [MW] Cost [EUR/MWh]

S1 200 95

S2 150 100

S3 100 105

S4 70 120

34
Example 2: Wind Power Plants
Spillage penalty
Supplier Production bid [MW]
[EUR/MWh]

W1 50 10

W2 40 20

W3 70 15

35
Example 2: Sets
Generators:
𝐺 = 𝑔1 , … , 𝑔𝑁𝐺 , 𝑁𝐺 = 5
Suppliers:
𝑆 = 𝑠1, … , 𝑠𝑁𝑆 , 𝑁𝑆 = 4
Wind power plants:
𝑊 = 𝑤1, … , 𝑤𝑁𝑊 , 𝑁𝑤 = 3

36
Example 2: Objective function
Social welfare maximisation:
max 𝑆𝑊
𝑆𝑊 = ෍ 𝐶𝑜𝑠𝑡 𝑠 ⋅ 𝐷 𝑠 − ෍ 𝑀𝐶 𝑔 ⋅ 𝑝 𝑔 − ෍ 𝑆𝑃 𝑤 ⋅ 𝑣(𝑤)
𝑠∈𝑆 𝑔∈𝐺 𝑤∈𝑊

Cost minimisation:
min 𝐶
𝐶 = ෍ 𝑀𝐶 𝑔 ⋅ 𝑝 𝑔 + ෍ 𝑆𝑃 𝑤 ⋅ 𝑣(𝑤)
𝑔∈𝐺 𝑤∈𝑊

37
Example 2: Constraints
Generator production:
0 ≤ 𝑝 𝑔 ≤ 𝑃max 𝑔 , ∀𝑔 ∈ 𝐺
Wind spillage:
0 ≤ 𝑣 𝑤 ≤ 𝑃w 𝑤 , ∀𝑤 ∈ 𝑊
Power balance:
෍ 𝑝 𝑔 + ෍ 𝑃w 𝑤 − 𝑣 𝑤 = ෍𝐷 𝑠 ∗
𝑔∈G 𝑤∈𝑊 𝑠∈𝑆

38
Example 2: Solution
Social welfare: 𝑆𝑊 = 43000 EUR
Costs: 𝐶 = 9900 EUR
Generators: production at the upper level for
all except G3

39
Example 4: Unit Commitment
Consider a centralised, network unconstrained
day-ahead market with the following participants:
◼ 3 conventional generators, constrained by their
minimum and maximum capacity and ramping
potential, with fixed and variable production costs
◼ Demand, predicted by the system operator
Write mathematical formulation of unit
commitment for this market. Solve optimisation
problem for the input data given on the following
slides.

43
Example 4: Generators
Min Max Ramp Ramp No load Variable
Generator
output output up down cost cost

1 100 500 250 250 480 27

2 300 700 400 400 390 33

3 0 400 180 180 475 36

44
Example 4: Demand

Time [h] t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12

Demand
285 285 290 357 415 458 463 463 458 458 458 449
[MW]

Time [h] t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24

Demand
454 478 483 483 463 439 401 352 304 348 327 311
[MW]

45
Example 4: Sets
Generators:
𝐺 = 𝑔1 , … , 𝑔𝑁𝐺 , 𝑁𝐺 = 3
Time:
𝑇 = 𝑡1 , … , 𝑡𝑁𝑇 , 𝑁𝑇 = 24

46
Example 4: Objective function
Cost minimisation:
min 𝐶𝑜𝑠𝑡𝑠
𝐶𝑜𝑠𝑡𝑠 = ෍ ෍ 𝐶𝑉 𝑝 ⋅ 𝑝 𝑔, 𝑡 + 𝐶𝐹 𝑔 ⋅ 𝑥 𝑔, 𝑡
𝑔∈𝐺 𝑡∈𝑇

47
Example 4: Constraints
Generator production:
𝑝 𝑔, 𝑡 ≥ 𝑃min 𝑔 ⋅ 𝑥 𝑔, 𝑡 , ∀𝑔 ∈ 𝐺, 𝑡 ∈ 𝑇
𝑝 𝑔, 𝑡 ≤ 𝑃max 𝑔 ⋅ 𝑥 𝑔, 𝑡 , ∀𝑔 ∈ 𝐺, 𝑡 ∈ 𝑇
Generator ramping:
𝑝 𝑔, 𝑡 − 𝑝 𝑔, 𝑡 − 1 ≥ 𝑅𝑈 𝑔 , ∀𝑔 ∈ 𝐺, 𝑡 ∈ 𝑇
𝑝 𝑔, 𝑡 − 1 − 𝑝 𝑔, 𝑡 ≥ 𝑅𝐷 𝑔 , ∀𝑔 ∈ 𝐺, 𝑡 ∈ 𝑇
Power balance:
෍ 𝑝 𝑔, 𝑡 = 𝐷 𝑡 , ∀𝑡 ∈ 𝑇
𝑔∈G

48
EXERCISES

50
Exercises
 Purpose: learning the mechanisms behind
the electricity markets
 Two rounds of laboratory exercises:
1. October 29 – November 15
2. After the midterm exam (TBA)

51
Tasks
1. Decide what programming language and
solver you will use.
2. Tell me your decision by replying to this
conversation.
3. Write mathematical models for Examples 2
and 4 using your preferred tools.
4. Write a short report on the results (400-500
words).
5. Submit your report by November 15.
52
Reports
 Reports must contain:
◼ A written report 400-500 words long (.pdf
format)
◼ All files necessary to run your code
 Reports should be submitted to the MS
Teams file Laboratory Exercises/Round 1
◼ Create a folder with your full name and upload
all files there

53

You might also like