
\newcommand{\thistitle}{Lecture 8: Electricity Markets}

\input{title.tex}


\section{Introduction to Electricity Markets}


\begin{frame}
  \frametitle{The Economic Operation of the Electricity Sector}


  Given the many different ways of consuming and generating
  electricity:

  \begin{itemize}
    \item   What is the \alert{most efficient} way to deploy consuming and generating
  assets in the short-run?
    \item How should we invest in assets in the long-run to \alert{maximise economic welfare}?
  \end{itemize}

  The operation of electricity markets is intimately related to
  \alert{optimisation}.

  In the past and still in many countries today, electricity was
  provided centrally by `vertically-integrated' monopoly utilities
  that owned generating assets, the electricity networks and
  retailing.  Given that these utilities owned all the infrastructure,
  it was hard for third-party generators to compete, even if they were
  allowed to.

  From the 1980s onwards, countries began to liberalise their
  electricity sectors, separating generation from transmission, and
  allowing regulated competition for generation in \alert{electricity markets}.
\end{frame}


\begin{frame}
  \frametitle{Electricity Markets}

  Electricity markets have several important differences compared to
  other commodity markets.

  At every instant in time, consumption must be balanced with
  generation.

  If you throw a switch to turn on a light, somewhere a generator will
  be increasing its output to compensate.

  If the power is not balanced in the grid, the power supply will
  collapse and there will be blackouts.

  It is not possible to run an electricity market for every single
  second, for practical reasons (the network must be checked for
  stability, etc.).

  So electricity is traded in blocks of time, e.g. hourly,
  14:00-15:00, or quarter-hourly, 14:00-14:15, well in advance of the
  time when it is actually consumed (based on forecasts).

  Additional markets trade in backup balancing power, which step in if the
  forecasts are wrong.


\end{frame}



\begin{frame}
  \frametitle{Baseload versus Peaking Plant}

  \alert{Load} (= Electrical Demand) is low during night; in Northern Europe in the winter, the peak is in the evening.
  To meet this load profile, \alert{baseload} generation with low fuel and running costs runs the whole time; more expensive \alert{peaking plant} covers the difference.

  \centering
  \includegraphics[width=9cm]{baseload-peaking}

  \source{Tom Brown}

\end{frame}


\begin{frame}
  \frametitle{Effect of varying demand for fixed generation}

  \centering
  \includegraphics[width=10cm]{demand-supply}

  \source{Tom Brown}

\end{frame}




\begin{frame}
  \frametitle{Example market 1/3}

  \centering

  \includegraphics[width=11cm]{germany_generation-price-2015-01-06-2015-01-12}

\end{frame}

\begin{frame}
  \frametitle{Example market 2/3}

  \centering
  \includegraphics[width=11cm]{germany_generation-price-2015-03-15-2015-03-31}

\end{frame}

\begin{frame}
  \frametitle{Example market 3/3}

  \centering
  \includegraphics[width=11cm]{germany_generation-price-2015-04-07-2015-04-14}

\end{frame}


\begin{frame}
  \frametitle{Effect of varying renewables: fixed demand, no wind}

  \centering
  \includegraphics[width=10cm]{demand-supply-no_wind}

\end{frame}



\begin{frame}
  \frametitle{Effect of varying renewables: fixed demand, 35~GW wind}

  \centering
  \includegraphics[width=10cm]{demand-supply-with_wind}

\end{frame}


\begin{frame}
  \frametitle{Spot market price development}

  As a result of so much zero-marginal-cost renewable feed-in, spot
  market prices steadily decreased until 2016. This is called the
  \alert{Merit Order Effect}.  Since then prices have been rising due
  to rising gas and CO$_2$ prices.


  \centering
  \includegraphics[width=10cm]{strompreis-2019.png}

  \source{\hrefc{https://www.agora-energiewende.de/fileadmin2/Projekte/2019/Jahresauswertung_2019/171_A-EW_Jahresauswertung_2019_WEB.pdf}{Agora Energiewende Jahresauswertung 2019}}
\end{frame}




\begin{frame}
  \frametitle{Merit Order Effect}

  To summarise:
  \begin{itemize}
  \item Renewables have zero marginal cost
  \item As a result they enter at the bottom of the merit order, reducing the price at which the market clears
  \item This pushes non-CHP gas and hard coal out of the market
  \item This is unfortunate, because among the fossil fuels, gas is the most flexible and produces lower \co2
    per MWh\el~than e.g. lignite
  \item It also reduces the profits that nuclear and lignite make
  \item Will there be enough backup power plants for times with no wind/solar?
  \end{itemize}

  This has led to lots of political tension, but has been counteracted in recent years by the rising CO$_2$ price.

\end{frame}


\section{Optimisation Revision}

\begin{frame}
  \frametitle{Optimisation problem}


We have an \alert{objective function} $f: \R^k \to \R$
\begin{equation*}
  \max_{x} f(x)
\end{equation*}
[$x = (x_1, \dots x_k)$] subject to some \alert{constraints} within $\R^k$:
\begin{align*}
  g_i(x) & = c_i \hspace{1cm}\leftrightarrow\hspace{1cm} \l_i \hspace{1cm} i = 1,\dots n \\
  h_j(x) & \leq d_j \hspace{1cm}\leftrightarrow\hspace{1cm} \m_j \hspace{1cm} j = 1,\dots m
\end{align*}

$\l_i$ and $\m_j$ are the \alert{KKT multipliers} we introduce for
each constraint equation; they measure the change in the objective value of the optimal solution obtained by relaxing the constraints (for this reason they are also called \alert{shadow prices}).

\end{frame}



\begin{frame}
  \frametitle{KKT conditions}

The \alert{Karush-Kuhn-Tucker (KKT) conditions} are necessary conditions that an optimal solution $x^*,\m^*,\l^*$ always satisfies (up to some regularity conditions):
\begin{enumerate}
\item \alert{Stationarity}: For $l = 1,\dots k$
  \begin{equation*}
  \frac{\d \cL}{\d x_l} =   \frac{\d f}{\d x_l} - \sum_i \l_i^* \frac{\d g_i}{\d x_l}  - \sum_j \m_j^* \frac{\d h_j}{\d x_l} = 0
  \end{equation*}
    \item \alert{Primal feasibility}:
      \begin{align*}
        g_i(x^*) & = c_i \\
        h_j(x^*) &\leq d_j
      \end{align*}
    \item \alert{Dual feasibility}: $\m_j^* \geq 0$
    \item \alert{Complementary slackness}: $\m_j^* (h_j(x^*) - d_j) = 0$
\end{enumerate}

\end{frame}


\begin{frame}
  \frametitle{Interpretation of the KKT multipliers}

  If say $d_j \to d_j + \varepsilon$ then
  \begin{equation*}
     f(x^*) \to f(x^*) + \mu^*_j \varepsilon
  \end{equation*}
  and similarly for $c_i \to c_i + \varepsilon$ and $\l^*_i$.

  We will now sketch a proof of this (not in exam). The Lagrangian from last time was defined:
\begin{equation*}
   \cL(x,\l,\m) = f(x) - \sum_i \l_i \left[g_i(x) - c_i\right]  - \sum_j \m_j \left[h_j(x) - d_j\right]
\end{equation*}
Note that by primal feasibility and complementary slackness at the optimum point $x^*,\m^*,\l^*$:
\begin{equation*}
   \cL(x^*,\l^*,\m^*) = f(x^*)
\end{equation*}
Now consider the Lagrangian $\cL^\varepsilon$ for the perturbed problem $d_j \to d_j + \varepsilon$:
\begin{equation*}
  \cL^\varepsilon(x,\l,\m) = \cL(x,\l,\m) + \m_j\varepsilon
\end{equation*}


\end{frame}


\begin{frame}
  \frametitle{Interpretation of the KKT multipliers}

  At the optimum point of the perturbed problem $x^+,\m^+,\l^+$ we have:
  \begin{equation*}
    f(x^+)  =   \cL^\varepsilon(x^+,\l^+,\m^+) = \cL(x^+,\l^+,\m^+) + \m_j^+\varepsilon
  \end{equation*}
  Because everything is differentiable and we only have a small perturbation, we expect that $y^+ = (x^+,\m^+,\l^+)$ is close to $y^* = (x^*,\m^*,\l^*)$ and Taylor expand about this point:
  \begin{equation*}
    \cL(x^+,\l^+,\m^+)  \approx \cL(x^*,\l^*,\m^*) +  \sum_l (x^+_l - x^*_l) \frac{\d \cL }{\d x_l} \Big|_{y = y^*}+ \sum_i (\l^+_i - \l^*_i) \frac{\d \cL }{\d \l_i} \Big|_{y = y^*}+ \sum_j (\m^+_j - \m^*_j) \frac{\d \cL }{\d \m_j} \Big|_{y = y^*}
  \end{equation*}
  From stationarity for the original problem we know that $\frac{\d \cL }{\d x_l} \Big|_{y = y^*} = \frac{\d \cL }{\d \l_i} \Big|_{y = y^*} = 0$. $\frac{\d \cL }{\d \m_j} \Big|_{y = y^*} = 0$ for binding inequalities, and for non-binding inequalities $\m^*_j = \m^+_j = 0$. Thus
  \begin{equation*}
    f(x^+)  =   \cL(x^+,\l^+,\m^+) + \m_j^+\varepsilon \approx \cL(x^*,\l^*,\m^*) + \m_j^*\varepsilon = f(x^*) + \m_j^*\varepsilon
\end{equation*}

\end{frame}

\section{Electricity Markets from Perspective of Single Generators and Consumers}

\begin{frame}{Efficient Markets for the short-run}


  Assume investments already made in generators and and consumption assets (factories, machines, etc.) $\Rightarrow$ \alert{all capacities are fixed}.

  Assume all actors are \alert{price takers} (i.e. nobody can exercise market power) and we have \alert{perfect competition}. Conditions for this: many producers and consumers; all goods are homogeneous; transparent information; no entry/exit barriers.

  \vspace{.7cm}

  How do we allocate production and consumption of \alert{existing assets} in most efficient way?


  I.e. we are interested in the \alert{short-run ``static'' efficiency}.

  \vspace{.7cm}

  (In contrast to \alert{long-run ``dynamic'' efficiency} where we also consider optimal investment in assets.)
\end{frame}





\begin{frame}
  \frametitle{Single Generator: Cost Function}

  Consider now the market from the point of view of a single generator.

  A generator has a \alert{cost or supply function} $C(g)$ in \euro/h,
  which gives the total costs (fuel, operation and maintenance costs) for a given
  rate of electricity generation $g$~MW.

  Typically the generator has a higher cost for a higher rate of generation $g$,
  i.e. the first derivative is positive $C'(g) > 0$. For most generators the rate at which cost increases with rate of production itself increases as the rate of production increases, i.e. $C''(g) > 0$.

\end{frame}


\begin{frame}{Cost Function: Example}


  A gas generator has a cost function which depends on the
  rate of electricity generation $g$ [\euro/h] according to
  \begin{equation*}
    C(g) = 0.005~g^2  + 9.3~g + 120
  \end{equation*}


  \centering
  \includegraphics[width=6.3cm]{generator_cost_function}

  \raggedright
  Note that the slope is always positive and becomes more positive
  for increasing $g$. The curve does not start at the origin because of startup costs, no load costs, etc.
\end{frame}



\begin{frame}{Optimal generator behaviour}

  We assume that the generator is a \alert{price-taker},
  i.e. they cannot influence the price by changing the amount they
  generate.  Suppose the market price is $\lambda$ \euro/MWh. For a generation
  rate $g$, the \alert{revenue} from the market is $\l g$ and the generator should adjust their
generation rate $g$ to maximise their \alert{net generation surplus}, i.e. their \alert{short-term profit}:
  \begin{equation*}
    \max_g \left[ \l g - C(g) \right]
  \end{equation*}

  This optimisation problem is optimised for $g=g^*$ where by KKT stationarity we have
  \begin{equation*}
    0 = \frac{\d \cL}{\d g} = \frac{\d f}{\d g} = \l  -  \frac{dC}{dg} (g^*)
  \end{equation*}
  We'll write the derivative with a prime to get:
  \begin{equation*}
    C'(g^*) \equiv \frac{dC}{dg} (g^*) =  \l
  \end{equation*}

  I.e. the generator increases their output until they make a net loss for any increase of generation.
  [Check units: $\frac{dC}{dg}$ has units $\frac{\textrm{\euro/h}}{\textrm{MW}} = $ \euro/MWh.]

\end{frame}



\begin{frame}{Marginal cost function: Example}

  $C'(g)$ is known as the \alert{marginal cost function}, which shows,
  for each rate of generation $g$ what price $\l$ the generator should be
  willing to supply at.

  For our example the marginal cost function is given by
  \begin{equation*}
    C'(g) = 0.01~g + 9.3
  \end{equation*}

  \centering
  \includegraphics[width=7cm]{marginal_cost_function}

\end{frame}





\begin{frame}{Net generator surplus}

  The area under the curve is generator costs, which as the integral
  of a derivative, just gives the cost function $C(g)$ again, up to a
  constant.


  The \alert{net generator surplus} is the short-term profit the generator makes by
  having variable costs below the electricity price. It is also know as the \alert{contribution margin} towards paying the fixed costs of the generator.

  \centering
  \includegraphics[width=6cm]{generator_surplus}

\end{frame}



\begin{frame}{Limits to generation}


  Note that it is quite common for generators to be limited by
  e.g. their capacity $G$, which may become a \alert{binding constraint}, i.e. limiting factor before the price plays a role, e.g.
  \begin{equation*}
    h(g) = g \leq G  \leftrightarrow \m
  \end{equation*}

  This constraint alters our KKT stationarity constraint for $g$ to
    \begin{equation*}
    0 = \frac{\d \cL}{\d g} =  \frac{\d f}{\d g} - \m^* \frac{\d h}{\d g} =  \l  -  C'(g^*) - \m^*
  \end{equation*}

    Now the \alert{shadow price} of the constraint is given by
    \begin{equation*}
      \m^* = \l - C'(g^*)
    \end{equation*}

    If it is binding, it tells us the benefit to our objective function of an incremental increase in capacity $G$. It is called the \alert{inframarginal rent}, i.e. difference between the market price $\l$ and the marginal cost $C'(g^*)$.

\end{frame}



\begin{frame}{Limits to generation: Example}

  Consider the constraint
  \begin{equation*}
    g \leq G  \leftrightarrow \m
  \end{equation*}
  with capacity $G = $ 250~MW so that for our example it is binding
  $g^* = G = $ 250~MW. The inframarginal rent $\m^* = \l - C'(g^*)$ can be marked on the
  graph:

  \centering
    \begin{tikzpicture}
      \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=6.5cm]{generator_surplus-limited}};
      \node[] at (2.45,3.55) {$\l$};
      \node[] at (4.9,3.2) {$\}\m^* = \l - C'(g^*)$};
  \end{tikzpicture}



\end{frame}




\begin{frame}{Consumer behaviour: Theory}

  Suppose for some given period a consumer consumes electricity at a rate of
  $d$~MW.


  Their \alert{utility or value function} $U(d)$ in \euro/h is a
  measure of their benefit for a given consumption rate $d$.

  For a firm this could be the profit related to this electricity
  consumption from manufacturing goods.


  Typical the consumer has a higher utility for higher $d$, i.e. the
  first derivative is positive $U'(d) > 0$. By assumption, the rate of
  value increase with consumption decreases the higher the rate of
  consumption, i.e. $U''(d) < 0$.

\end{frame}


\begin{frame}{Utility: Example}


  A widget manufacturer has a utility function which depends on the
  rate of electricity consumption $d$ [\euro/h] as
  \begin{equation*}
    U(d) = 0.0667~d^3  - 8~d^2 + 300~d
  \end{equation*}


  \centering
  \includegraphics[width=6cm]{utility}

  \raggedright
  Note that the slope is always positive, but becomes less positive
  for increasing $d$.
\end{frame}


\begin{frame}{Optimal consumer behaviour}



  We assume that the consumer is a \alert{price-taker},
  i.e. they cannot influence the price by changing the amount they
  consume.

  Suppose the market price is $\lambda$ \euro/MWh. The consumer should
  adjust their consumption rate $d$ to maximise their \alert{net surplus}
  \begin{equation*}
    \max_d \left[U(d) - \l d \right]
  \end{equation*}

  This optimisation problem is optimised for $d=d^*$ where from KKT stationarity we now get
  \begin{equation*}
    U'(d^*) \equiv \frac{dU}{dd} (d^*) =  \l
  \end{equation*}

  [Check units: $\frac{dU}{dd}$ has units $\frac{\textrm{\euro/h}}{\textrm{MW}} = $ \euro/MWh.]

  I.e. the consumer increases their consumption until they make a net loss for any increase of consumption.

  $U'(d)$ is known as the \alert{inverse demand curve} or \alert{marginal utility curve}, which shows,
  for each rate of consumption $d$ what price $\l$ the consumer should be
  \alert{willing to pay}.


\end{frame}



\begin{frame}{Inverse demand function: Example}
  For our example the inverse demand function is given by
  \begin{equation*}
    U'(d) = 0.2~d^2 - 16~d + 300
  \end{equation*}

  \centering
  \includegraphics[width=6cm]{inverse_demand_function}

  \raggedright
  It's called the \emph{inverse} demand function, because the demand function is the function you get from reversing the axes.
\end{frame}


\begin{frame}{Inverse demand function: Example}


  The \alert{demand function} $D(\l)$ gives the demand $d$ as a function of the price $\l$. $D(U'(d)) = d$.

  For our example the demand function is given by
  \begin{equation*}
    D(\l) =  -((\l+20 )/0.2)^{0.5} +40
  \end{equation*}

  \centering
  \includegraphics[width=6cm]{demand_function}

\end{frame}



\begin{frame}{Gross consumer surplus}

  The area under the inverse demand curve is the \alert{gross consumer surplus},
  which as the integral of a derivative, just gives the utility
  function $U(d^*)$ again, up to a constant.

  \centering
  \includegraphics[width=6cm]{gross_consumer_surplus}

\end{frame}



\begin{frame}{Net consumer surplus}

  The more relevant \alert{net consumer surplus}, or just
  \alert{consumer surplus} is the net gain the consumer makes by
  having marginal utility above the electricity price, i.e. $U(d^*) - \l d^*$.

  \centering
  \includegraphics[width=6cm]{net_consumer_surplus}

\end{frame}


\begin{frame}{Limits to consumption}


  Note that it is quite common for consumption to be limited by other
  factors before the electricity price becomes too expensive, e.g. due
  to the size of electrical machinery. This gives an upper bound
  \begin{equation*}
    d \leq D  \leftrightarrow \m
  \end{equation*}
  The \alert{shadow price} $\m$ indicates the benefit of relaxing the constraint. From KKT $\m^* = U'(d^*) - \l$.
  In the following case the optimal consumption is at
  $d^* = D =$  10~MW.

    \centering
    \begin{tikzpicture}
      \node[anchor=south west,inner sep=0] (image) at (0,0) {  \includegraphics[width=6cm]{net_consumer_surplus-limited}};
      \node[] at (2.6,1.82) {$\l$};
      \node[] at (4.45,2) {$\Big\}\m^* = U'(d^*) - \l$};
  \end{tikzpicture}


\end{frame}



\begin{frame}
  \frametitle{Consumers can delay their consumption}

  Besides changing the amount of electricity consumption, consumers
  can also shift their consumption in time.

  For example electric storage heaters use cheap electricity at night
  to generate heat and then store it for daytime.

  The LHC particle accelerator does not run in the winter,
  when prices are higher (see
  \urlc{http://home.cern/about/engineering/powering-cern}).  Summer
  demand: 200~MW, corresponds to a third of Geneva, equal to peak
  demand of Rwanda (!); winter only 80~MW.


  \centering
  \includegraphics[width=5cm]{csm_1998_LHCUeberblick_CERN_02_ed178e98ea}


  \source{CERN}



\end{frame}


\begin{frame}
  \frametitle{Consumers can also move location}

  Aluminium smelting is an electricity-intensive process. Aluminium
  smelters will often move to locations with cheap and stable
  electricity supplies, such as countries with lots of hydroelectric
  power.  For example, 73\% of Iceland's total power consumption in
  2010 came from aluminium smelting.

  Aluminium sells on world markets for around US\$ 1500/ tonne. %http://www.lme.com/metals/non-ferrous/aluminium/

  Electricity consumption: 15 MWh/tonne.

  At Germany consumer price of electricity of \euro 300 / MWh, this is \euro 4500 / tonne. Industrial consumers pay less.

  If raw materials cost $\$$~600/tonne, then have $\$$~900/tonne available for buying electricity while still making profit $\Rightarrow$ willingness to pay of up to 900/15 \$/MWh = 60 \$/MWh.

  %https://arcticecon.wordpress.com/2012/02/15/aluminium-smelting-in-iceland-alcoa-rio-tinto-alcan-century-aluminum-corp/
  %15.7 kWh of electricity to produce 1 kg of aluminium.  Al203 (alumina) -> Al

  % The Hall-Héroult electrolysis process is the major production route for primary aluminium.

  %Due to the nature of the process, power outages have the potential
  %to cause damage to production cells as the molten liquids could
  %solidify in absence of adequate current.  For this reason,
  %production facilities need to be near secure and reliable sources
  %of energy.  step before smelting is bauxite -> alumina. Bauxite is
  %gibbsite Al(OH)3, boehmite γ-AlO(OH), and diaspore α-AlO(OH).


%What is notable is that the aluminium industry’s total power usage
  %amounted to roughly 73% of Iceland’s total power consumption in 2010.

  %https://en.wikipedia.org/wiki/Economy_of_Iceland#Aluminium

  %https://agmetalminer.com/2015/11/24/power-costs-the-production-primary-aluminum/

  %making domestic electricity costs some 44% of the sales price of
  %ingot and may explain why Chinese smelters combined with low
  %capacity utilization due to reduced demand are widely reported

  %http://www.crugroup.com/about-cru/cruinsight/Aluminium_Smelter_Power_Tariffs_Winners_and_Losers

%Power typically represents more than a third of an aluminium
%smelter's operating costs and is the single most important cost
%variant between smelting assets. As a result access to cheap power is
%one of the key sources of competitive advantage in primary aluminium
%smelting.

  % https://en.wikipedia.org/wiki/List_of_aluminium_smelters

  % THere are some in Germany

  \end{frame}


\begin{frame}{Summary: Consumers and Generators}

{\bf Generators:}  A generator has a \alert{cost} or \alert{supply function} $C(g)$ in \euro/h, which
  gives the costs (of fuel, etc.) for a given rate of electricity
  generation $g$~MW. If the market price is $\lambda$ \euro/MWh, the revenue is $\l g$ and the generator should adjust their
generation rate $g$ to maximise their \alert{net generation surplus}, i.e. their short-term profit:
  \begin{equation*}
    \max_g \left[ \l g - C(g) \right]
  \end{equation*}


{\bf Consumers:} Their \alert{utility} or \alert{value function} $U(d)$ in \euro/h is a
  measure of their benefit for a given consumption rate $d$. For a given price $\lambda$ they adjust their consumption rate $d$ such that their \alert{net surplus} is maximised:
    \begin{equation*}
    \max_d \left[U(d) - \l d \right]
  \end{equation*}

  \end{frame}

\section{Supply and Demand at a Single Node}


\begin{frame}{Setting the quantity and price}

  Now let's consider the case with \alert{many} consumers and generators.  We build \alert{aggregated} marginal cost and marginal utility
  curves from the individual curves.

  Then we maximise \alert{total welfare}, the sum of net consumer and generator surplus of all actors.

  If the price is also set from this point, then the individual
  optimal actions of each actor will achieve this result in a perfect
  decentralised market.

  \centering
  \includegraphics[width=7.5cm]{consumer_producer_surplus.pdf}




\end{frame}



\begin{frame}{The result of optimisation}

  This is the result of maximising the \alert{total economic welfare}, the sum of the consumer and the producer surplus for consumers $b$ with consumption $d_b$ and generators $s$ generating with rate $g_s$:
  \begin{align*}
    \max_{\{d_b\}, \{g_s\}}\left[ \sum_b U_b (d_b)  -  \sum_s C_s (g_s) \right]
  \end{align*}
  subject to the supply equalling the demand in the balance constraint:
  \begin{align*}
    \sum_b d_b -  \sum_s g_s  = 0 \hspace{1cm} \leftrightarrow \hspace{1cm} \l
  \end{align*}
  and any other constraints (e.g. limits on generator capacity, etc.).

  Market price $\l$ is the shadow price of the balance constraint,
  i.e. the cost of supply an extra increment 1~MW of demand.

\end{frame}


\begin{frame}{Why decentralised markets work (in theory)}

  We will now show our main result:

  \alert{Welfare-maximisation through decentralised markets}

        The welfare-maximising combination of production and consumption can be achieved by the decentralised profit-maximising decisions of producers and the utility-maximising decisions of consumers, provided that the conditions for \alert{perfect competition} are met:
        \begin{itemize}
        \item The market price is equal to the shadow price of the overall supply-balance constraint in the welfare maximisation problem
        \item There are many producers and consumers, so that none can influence the price, i.e. all actors are \alert{price takers}
        \item The goods are exactly the same, i.e.  \alert{homogeneous}
  \item All actors have perfect information
   \item There are no entry or exit barriers
        \end{itemize}

\end{frame}




\begin{frame}{KKT and Welfare Maximisation 1/2}

  Apply KKT now to maximisation of total economic welfare:
  \begin{align*}
    \max_{\{d_b\}, \{g_s\}} f(\{d_b\}, \{g_s\}) = \left[ \sum_b U_b (d_b)  -  \sum_s C_s (g_s) \right]
  \end{align*}
  subject to the balance constraint:
  \begin{align*}
    g(\{d_b\}, \{g_s\}) = \sum_b d_b -  \sum_s g_s  = 0 \hspace{1cm} \leftrightarrow \hspace{1cm} \l
  \end{align*}
  and any other constraints (e.g. limits on generator capacity, etc.).

  Our optimisation variables are $\{x\} = \{d_b\} \cup \{g_s\}$.

  We get from KKT stationarity at the optimal point:
  \begin{align*}
    0 & =   \frac{\d f}{\d d_b} -  \l^* \frac{\d g}{\d d_b} = U_b'(d_b^*) - \l^* = 0 \\
    0 & =   \frac{\d f}{\d g_s} -  \l^* \frac{\d g}{\d g_s} = -C_s'(g_s^*) + \l^* = 0
  \end{align*}


\end{frame}





\begin{frame}{KKT and Welfare Maximisation 2/2}

  So at the optimal point of maximal total economic welfare we get the
  same result as if everyone maximises their own welfare separately based on the price $\l^*$:
  \begin{align*}
 U_b'(d_b^*) =  \l^*  \\
 C_s'(g_s^*) = \l^*
  \end{align*}

  This is the CENTRAL result of microeconomics.

  If we have further inequality constraints that are binding (e.g. capacity constraints), then
  these equations will receive additions with $\m_i^* > 0$.


\end{frame}



\begin{frame}[fragile]
  \frametitle{Power Production Real Example}

  At \hrefc{https://energy-charts.de/power_de.htm}{energy-charts.de} you can see the forecast of load, wind, solar and conventional generation right now in Germany, here's an old version:


  \centering
    \includegraphics[width=11cm]{strom-170531-14.png}


\end{frame}

\begin{frame}[fragile]
  \frametitle{Supply-Demand Curve Real Example}

  At \hrefc{https://www.epexspot.com/en/market-data?market_area=AT&trading_date=2020-06-04&delivery_date=2020-06-05&underlying_year=&modality=Auction&sub_modality=DayAhead&product=60&data_mode=aggregated&period=}{epexspot.com} you can find the results of the day ahead auction for electricity with supply-demand bid curves for every hour. This only partially maps onto the merit order curve, since electricity is also sold on other markets (e.g. over-the-counter).

  \centering
    \includegraphics[width=9cm]{DEAT-170531-14}

\end{frame}


\end{document}
