Note: this post was originally published on March 13^{th}, 2022 but was lost during a recent WordPress update.

During the last week, I was happy to participate in the 8^{th} Workshop on Mathematical Solutions for Industrial Problems (also known as the *Brazilian Study Group with Industry*). More specifically, I worked on the problem posed by CCEE/Cepel and coordinated by Juan Pablo Luna, Claudia Sagastizábal and Paulo J. S. Silva; called *Analysis of the pricing mechanism by supply in the Brazilian electricity market (in Portuguese)*.

It was an interesting opportunity to get acquainted with how pricing mechanisms may be mathematically modeled by optimization and market equilibrium models, as well as learn a little bit about the computational tools involved in solving them and how to efficiently work in a team environment. In what follows, I will describe a simplified version of the treated problem schematically divided in three sequential steps: 1. the context, 2. mathematical modelling and 3. computer simulation.

## 1. The context

The context which motivates the problem is the current transition of energy markets to distributed generation involving renewable sources. This situation makes it paramount to generate accurate price signals for energy in the short-term (up to a day, considering hour increments) as to incentivize the entry of new actors in the energy market, thus contributing to create a competitive energy market.

Concretely, the context translates to the tasks of designing mathematical models to determine the price of energy in the short-term, implementing computer simulations of those models and comparing its results.

## 2. Mathematical modelling

### 2.1. Notation

We denote the **price of energy** by \(\pi\). We will denote the index set of **consumers** by \(C\) and the index set of **energy sources** by \(S\). Given \(c \in C\) or \(s \in S\),

- \(p_c\) \((p_s)\) denotes the
**utility of energy**for \(c\) (**cost of energy generation**for \(s\)); - \(q_c\) \((q_s)\)denotes the maximum amount of energy that \(c\)
**would consume**(\(s\)**can generate**); - denotes the
**dispatch**to \(c\) (from \(s\)), i.e., how much energy \(c\) will effectively consume (\(s\) will effectively generate).

Finally, we collect the terms \(\alpha_a\) for any \(\alpha \in \{q, p, \ell\}\) and \(a \in C \cup S\) to define \(\alpha \in (C \cup S)^{\mathbb{R}}\).

### 2.2. The formulations

Two formulations were considered for pricing: in the first one, a central entity (an Independent System Operator, such as the Brazilian ONS) would determine the dispatches as to maximize a predetermined objective function (for example, the **social welfare function**, \(f_{\mathrm{SW}} (\ell) = \sum_{c \in C} p_c \ell_c – \sum_{s \in S} p_s \ell_s \).) In the second formulation, each consumer \(c \in C\) (source \(s \in S\)) tries to maximize its utility \((p_c – \pi) \ell_c\) (maximize its profit \((\pi – p_s) \ell_c\) by strategically setting \(q_c > 0\) (\(q_s > 0\)).

#### 2.2.1. Optimization problem: maximization of *social welfare*

In the first formulation, the ISO solves the linear optimization problem

$$

\begin{array}{r l l}

\text{maximize}

&

f_{\mathrm{SW}} (\ell)

\\

\text{subject to}

&

\sum_{c \in C} \ell_c – \sum_{s \in S} \ell_s = 0;

\\

&

0 \leq \ell_c \leq q_c,

&

c \in C;

\\

&

0 \leq \ell_s \leq q_s,

&

s \in S.

\end{array}

$$

Note that the first restriction indicates that all energy that is generated is also consumed, while the second and third specify the possible values for the dispatches. Once the ISO solves the aforementioned optimization problem, it determines the **optimal dispatch** \(\bar{\ell}\) and the **equilibrium price** \(\bar{\pi} \in \mathrm{conv} \{p_\alpha: \alpha \in C \cup D\}\) under which the exchange of energy corresponds to the maximization of social welfare.

#### 2.2.2. Equilibrium problem: maximization of utility/profit

In the second formulation, each consumer \(c \in C\) wants to solve the linear optimization problem

$$

\begin{array}{r l}

\text{minimize}

&

– (p_c – \pi) \ell_c

\\

\text{subject to}

&

0 \leq \ell_c \leq q_c,

\\

&

q_c \leq q_{\mathrm{max}_c}

\end{array}

$$

and each source \(s \in S\) wants to solve the problem

$$

\begin{array}{r l}

\text{maximize}

&

(\pi – p_s) \ell_s

\\

\text{subject to}

&

0 \leq \ell_s \leq q_s,

\\

&

q_c \leq q_{\mathrm{max}_s}.

\end{array}

$$

They try to do so by strategically setting \(q_c\) and \(q_s\). In this situation, the price of energy is decided by a *market clearing agent* which solves the problem below with respect to the decision variable \(\pi\),

$$

\begin{array}{r l}

\text{maximize}

&

\pi \left(

\sum_{c \in C} \ell_c – \sum_{s \in S} \ell_s

\right)

\end{array},

$$

and the dispatches are decided by a market clearing agent which solves the problem below with respect to the decision variable \(\ell\),

$$

\begin{array}{r l l}

\text{maximize}

&

\sum_{c \in C} (p_c – \pi) \ell_c

–

\sum_{s \in S} (p_s – \pi) \ell_s

\\

\text{subject to}

&

0 \leq \ell_c \leq q_c,

&

c \in C;

\\

&

0 \leq \ell_s \leq q_s,

&

s \in S.

\end{array}

$$

#### 2.2.3. A remark on the simplifications

The models presented above are simplified for the sake of brevity. Among the simplifications, note that I did not mention the dependence on time, there is the hypothesis that there is no deficit (i.e., all of the energy that is generated is also consumed) and elasticity of demand is tacitly ignored.

## 3. Computer simulation

The mathematical models were implemented as GAMS scripts. These were run considering an adaptation of the IEEE 24-Bus System with hydro and thermal power sources of Subsistema Sudeste (in Portuguese) as source data with the intent of comparing the results so obtained with the DESSEM model, which is currently employed by the ONS.