EE 554 Largescale Electric Systems Analysis Homework Assigments
Homework 6
Due at 11:59pm on Dec 3. Submit to https://canvas.uw.edu/courses/1828831/assignments/10856279. Note, for the optimization problems, write out the formulation and provide the optimal value of the problem. You do not need to write out the optimal solutions unless instructed in a specific problem.
Problem 1
In power system operations the cost of generators are often given as piecewise linear functions. For example, let \(C_1(x_1)\) and \(C_2(x_2)\) be given as
\[C_1(x_1)= \begin{cases} x_1 & \mbox{ if } 0 \leq x_1 \leq 1 \\ 2 x_1-1 & \mbox{ if } x_1 > 1 \end{cases} \quad C_2(x_2)= \begin{cases} 0.5 x_2 & \mbox{ if } 0 \leq x_2 \leq 2 \\ 3 x_2-5 & \mbox{ if } x_2 > 2 \end{cases}\]We want to solve the following optimization problem
\[\begin{align} \min \; & C_1(x_1)+C_2(x_2) \\ \mbox{s.t. } & x_1 \geq 0 \\ & x_2 \geq 0 \\ & x_1+x_2 = L \end{align}\]Write this optimization problem as a linear program, that is, a problem with just affine cost functions and affine constraints.
Solution.
This is an example of the very useful fact that linear programs can encode some if/then statements. One can check that
\[C_1(x_1)= \begin{align} \min \; & u+2v \\ \mbox{s.t. } & 0 \leq u \leq 1 \\ & v \geq 0 \\ & u+v=x_1 \end{align}\]and
\[C_2(x_2)= \begin{align} \min \; & 0.5 y+3z \\ \mbox{s.t. } & 0 \leq y \leq 2 \\ & z \geq 0 \\ & y+z=x_2 \end{align}\]putting things together we can the optimization problem can be written as
\[\begin{align} \min \; & u+2v+0.5 y+3z \\ \mbox{s.t. } & 0 \leq u \leq 1 \\ & v \geq 0 \\ & 0 \leq y \leq 2 \\ & z \geq 0 \\ & u+v+y+z = L \end{align}\]Problem 2
We explore how to include energy storage in the optimization problem. A storage doesn’t generate net power, rather it has the ability to shift load around in time. A standard application of a storage is arbitrage, that is, buy low and sell high. The storage has some physical constraints. For example, the charge and discharge power must be limited by the rated power and the energy in the storage is bounded between 0 and some maximum state of charge (SoC).
Let’s consider 10 time slots. We assume perfect knowledge of the prices in these timeslots, and they are \(p=(1.3,2.8,4.1,3.6,1.9,5.0,2.2,3.4,4.8,1.7)\). Suppose the maximum SoC of the storage is 10 units, and the charge and discharge rate is 2 units of power at a time step. Assume the stoage starts with an SoC of 5 units.
a) Write an optimization problem that maximize the profit of the storage.
b) Let’s say we want the SoC to end a the same level at the end of the time period. Add that constraint and resolve the problem.
c) What is the marginal benefit of increasing the SoC (i.e., making the storage bigger)?
Solution.
a) We define some variables. Let \(s_t\) be the SoC of the storage at time \(t\), \(x_t\) be the net discharge of the storage at time \(t\), and \(p_t\) be the price at time \(t\). The profit maximization problem is
\[\begin{align} \max \; & \sum_{t=1}^{10} p_t x_t \\ \mbox{s.t. } & s_t=s_{t-1}-x_t, \quad t \geq 2 \\ & s_t = 5, \quad t =1 \\ & 0 \leq s_t \leq 10 \\ & -2 \leq x_t \leq 2 \end{align}\]Solving this gives us the optimal profit is 33.4.
b) We add the constraint \(s_{10}=5\) and resolve it. The optimal solution is 20.4
c) This comes from reading the dual variables associated with the \(s_t \leq 10\) constraint (there are 10 constraints, one for each \(t\)). In this specific case we never actually hit the SoC upper bound, so all the dual variables are 0.
Problem 3
We continue with the last problem and add in some more constraints.
a) Most storages are not 100% efficient. Suppose the storage has a charging efficiency of 90% (for every 1 unit of energy drawn from the grid, only 0.9 units gets to the SoC) and a discharging efficiency of 85% (for every 1 unit of energy out of the storage, only 0.85 units get to the grid). Add this to the optimization problem in 2b) and resolve.
b) There is some cost of using the storage, for example, batteries runs down faster if they are used more aggressively. In addition, the health of a battery storage degrades if it is either too full or too empty. Let’s say that every unit charged or discharged has a cost of \(1\), and if the storage incurs a flat cost of \(0.5\) per time unit if it is below 20% or above 80% SoC. Rewrite the optimization problem in part a) and resolve it.
Solution.
a) We do this by introducing a charging variable and discharging variable, denoted by \(c_t\) and \(d_t\), respectively. The main change is in the objective and the SoC equation. In the objective, we have \(p_t (0.85 d_t-\frac{1}{0.9} c_t)\). The SoC update becomes \(s_t=s_{t-1}-d_t+c_t\). The overall optimization problem can be written as
\[\begin{align} \max \; & \sum_{t=1}^{10} p_t (0.85 d_t-\frac{1}{0.9} c_t) \\ \mbox{s.t. } & s_t=s_{t-1}-d_t+c_t, \quad t \geq 2 \\ & s_t = 5, \quad t =1, 10 \\ & 0 \leq s_t \leq 10 \\ & 0 \leq d_t \leq 2 & 0 \leq c_t \leq 2 \end{align}\]Solving this gives an objective of 12.95.
You might have noticed that we allow both \(c_t\) and \(d_t\) to be nonzero. This should not happen in practice, since a storage shouldn’t charge and discharge at the same time. It turns out that if the efficiencies are not 1, only one of \(c_t\) and \(d_t\) would be nonzero since it is not optimal otherwise. Showing this formally is a good excercise.
b) We add some cost functions to the objective. The power degradation costs are \(1 \cdot \vert c_t \vert\) and \(1 \cdot \vert d_t \vert\). The SoC costs can be written as \(0.5 I(s_t \leq 0.2)+0.5 I(s_t \geq 0.8)\) where \(I\) is the indicator function. The absolute value functions can be made into linear programming problems using similar techniques as in problem 1. The indicator functions are not convex, so any attempt here would get full marks.
Problem 4
We continue with the previous problem. So far, we assumed that the price is known exactly. That is of course not the case in practice. Let’s say that there are two other possible prices, \((4.2,1.5,3.9,2.1,4.7,3.3,1.8,2.6,5.0,3.0)\) and \((2.4,4.9,1.1,3.7,2.0,4.4,1.6,3.2,2.9,4.0)\). Say the all three prices are equally likely to occur. Write and solve the optimization problem that takes this uncertainty into account.
Solution.
There are multiple ways to handle this problem. The simplest would be simply take an average of the prices and optimize against that, which would maximize the expected profit. Or one could optimize the worst possible profit (a robust formation of the problem). Any reasonable formulation is ok.
Problem 5
In this problem we formulate and solve a simple nonconvex loss minimization problem. A generator supplies a load through a transmission line modeled as a series admittance \(y := g - jb, \quad g > 0, \; b > 0\). The voltage at the generator (reference) bus is fixed at \(V_0 := 1 \angle 0\). The required load power is \(S = P + jQ = |S| e^{j\phi}\), with \(P > 0\) specified, i.e., \(-S\) is the power injection at the load bus. Let the load voltage be \(V := v e^{j\theta}.\)
a) Show that the loss can be written as
\[P_\text{loss} = r |I|^2 = g | 1 - v e^{j\theta} |^2.\]b) Fix \(v\) and \(P\). Formulate the optimal power flow (OPF) as a minimization over \((\theta, \phi)\) of the active line loss.
c) Reformulate the OPF as an unconstrained minimization \(\min_\phi f(\phi)\) over \(\phi\) only.
d) Find the unique minimize of \(f(\phi)\) over \(\phi \in [-\frac{\pi}{2},\frac{\pi}{2}]\).
Solution.
In class we defined the thermal loss to be \(P_1+P_2\). Writing out the equations, we have \(P_1+P_2=Re\{V_1 (y(V_1-V_2))^*+V_2(y(V_2-V_1))^*\}= g(\vert V_1 \vert^2-V_1 V_2^*-V_1^* V_2+\vert V_2 \vert^2)\). Dividing and multiplying by \(\vert y \vert\) gives loss is equal to \(r \vert I \vert ^2\). The optimization problem can be written as
\[\begin{align} \min_{\theta, \phi} & g | 1 - v e^{j\theta} |^2 \\ \mbox{s.t. } & S= ve^{j \theta}(y(1-e^{j \theta}))^* \\ & Re\{S\}=P \\ & \angle S=\phi \end{align}\]This optimization problem look quite complicated. We can simplify this considerably by noticing that \(|S|= | ve^{j \theta}(y(1-e^{j \theta}))^*| = |y| |v| | 1-v e^{j\theta}|\) so we can solve \(| 1 - v e^{j\theta} |^2\) in \(|S|, |y|, v\). The objective becomes \(\frac{g}{|y|^2 v^2} |S|^2\). So if we can represent \(|S|^2\) in terms of \(\phi\), we can convert the problem to just optimizing over \(\phi\). Note that \(\phi\) is simply the angle of the complex number \(P+jQ\) and we know \(P\). So we need to write \(Q\) in terms of \(\phi\). Since we know \(P>0\), \(\phi=\tan^{-1}(\frac{Q}{P})\) or \(Q=P\tan(\phi)\). The optimization problem becomes
\[\min_{\phi} \; \frac{g}{|y|^2 v^2} (P^2+P^2 \tan^2(\phi))\]which is actually just minimizing \(\tan^2(\phi)\). And it is minimized when \(\phi=0\). This shows that to minimize loss to satisfy load \(P\), we want \(Q\) to be \(0\) (that is, the line should not unnecessarily transmit reactive power).
Problem 6
This is a simplified example of voltage regulation in practice. Consider the system with the \(Y\)-bus matrix below.
\[Y = \begin{bmatrix} 0.83 - j1.47 & -0.83 + j1.47 & 0 & 0 & 0\\[4pt] -0.83 + j1.47 & 1.50 - j2.59 & -0.67 + j1.12 & 0 & 0\\[4pt] 0 & -0.67 + j1.12 & 2.20 - j4.35 & -0.95 + j1.89 & -0.58 + j1.34\\[4pt] 0 & 0 & -0.95 + j1.89 & 0.95 - j1.89 & 0\\[4pt] 0 & 0 & -0.58 + j1.34 & 0 & 0.58 - j1.34 \end{bmatrix}.\]Suppose we want to minimize the loss while keeping all voltages at 1 per unit, with \(P\) and \(Q\) satisfying the upper bounds given below (the feeder, bus 1, is unconstrained).
\[(\overline{P}_2,\overline{Q}_2)=(-0.05,0.3), (\overline{P}_3,\overline{Q}_3)=(-0.25,0.25), (\overline{P}_4,\overline{Q}_4)=(-0.2,0.06), (\overline{P}_5,\overline{Q}_5)=(-0.01,0.05)\]Write it as a semidefinite programming problem and solve it. Given the optimal solutions (the complex voltages) with the feeder as the slack bus.
Solution.
Following the derivation in class, we can write \(P_i=Tr(A_i W)\) and \(Q_i=Tr(B_i W)\) for appropriately defined \(A_i\) and \(B_i\) matrices. Solving the SDP gives a \(W\) that is rank 1, and factoring it gives the complex voltages: \(V_1=1 \angle 0, \; V_2=1 \angle -35.71^\circ, \; V_3= 1 \angle -55.8^\circ, \; V_4 =1 \angle -72.05^\circ, \; V_5= 1 \angle -66.23^\circ\)