LPOPF
LPOPF
1
The OPF has been a tool for many years in the power engineering
community, and has been effective in solving the following kinds
of problems (see Section 13.1 of W&W):
• Minimizing dispatch cost while meeting transmission
constraints (this is the “classical” OPF)
• Security-constrained OPF (corrective and preventative)
• Voltage-var optimization
• Maximum power transfer
• Loss minimization
2
Ci si3
$/hr si
si2
si1
Pi3
Pi1 Pi2
Pi,min Pi (MW) Æ
Fig. 0
Subject to:
P = B' θ 2
P B = ( D × A) × θ 3
− P B ,max ≤ P B ≤ P B ,max 4
where
Pk = Pgk − Pdk , k = 1,...N 6
1
k is index on the units.
2
These are DC power flow equations to represent the network. However, we must include all nodal
injections P1,…PN and all angles θ1 …θN in this set of equations.
3
These are equation to get line flows. Again, we need to include all angles θ1 …θN in this set of equations.
4
These are the limits on the line flows. Notice that there is only one circuit rating, but it must be enforced
as a limit if the flow is in one direction or in the other.
5
These are the limits on the linear cost curve variables.
6
This relates variables used in the cost curves (Pkj) to variables used in DC power flow equations (Pk).
3
Before we proceed with formulating this problem, we must make
one very important observation. In the DC power flow problem,
we found that if we included an equation for all buses in the
network, using all angles in the network, that there was a
dependency in our set of equations, and the matrix was not
invertable.
4
Special note on LP solver: The below formulation was developed
for use in Matlab. However, this formulation may also be
implemented in CPLEX. To do so, you need to realize that CPLEX
is quite flexible in handling input constraints. The below example
illustrates this flexibility:
Equality
constraints
Less-than
inequality
constraint
Greater-than
Less-than, inequality
greater-than constraint
inequality
constraints
⎡Pg ⎤
x = ⎢⎢ P B ⎥⎥
⎢⎣ θ ⎥⎦ (1)
5
where
Pg is the vector of generation increments [Pgk …]T for all bus k
that has generation.
PB is the vector of line flows [Pb1 Pb2…PbM]T, M is # of
branches.
θ is the vector of bus angles, in radians [θ1 θ2…θN], N is # of
buses.
There are two kinds of equality constraints: one due to line flows
P B = ( D × A) × θ (2)
and the other due to injections:
P = B' θ (3)
We rewrite these slightly modified to make them more convenient
to embed in a single matrix equation.
− P B + ( D × A) × θ = 0 (4)
− P + B 'θ = 0 (5)
The inequality constraints are straightforward given our definition
of the solution vector. The only issue here is what to use as
constraints on the angles? Clearly, all angles must reside between –
π radians and +π radians. Therefore, inequality constraints will be:
⎡ P g ,min ⎤ ⎡ P g ⎤ ⎡ P g ⎤
⎢− P ⎥ ≤ ⎢P ⎥ ≤ ⎢P ⎥
⎢ B ,max ⎥ ⎢ B ⎥ ⎢ B ,max ⎥
⎢⎣ − π ⎥⎦ ⎢⎣ θ ⎥⎦ ⎢⎣ π ⎥⎦ (6)
6
Example:
Pg2
Pg1
1 2
y12 =-j10
y14 =-j10
y13 =-j10 Pd2=1pu y23 =-j10
y34 =-j10
4 3
Pg4 Pd3=1.1787pu
The offers and corresponding min and max generation limits are as
follows:
K1 ( Pg1 ) = s1 Pg1 , 50 ≤ Pg1 ≤ 200
K 2 ( Pg 2 ) = s2 Pg 2 , 37.5 ≤ Pg 2 ≤ 150
K 4 ( Pg 4 ) = s4 Pg 4 , 45 ≤ Pg 4 ≤ 180
7
with
s1=13.07 $/MWhr
s2=12.11 $/MWhr
s4=12.54 $/MWhr
8
Now we see that the objective function is given by:
⎡ Pg 1 ⎤
⎢P ⎥
⎢ g2 ⎥
⎢ Pg 4 ⎥
⎢ ⎥
⎢ PB1 ⎥
⎢ PB 2 ⎥
⎢ ⎥
⎢P ⎥
Z ( x ) = [1307 1211 1254 0 0 0 0 0 0 0 0 0]⎢ B 3 ⎥
P
⎢ B4 ⎥
⎢ PB 5 ⎥
⎢θ ⎥
⎢ 1 ⎥
⎢ θ2 ⎥
⎢ ⎥
⎢ θ3 ⎥
⎢⎣ θ 4 ⎥⎦
Equality constraints: The equality constraints are given in eqs. (4)
and (5), repeated here for convenience:
− P B + ( D × A) × θ = 0 (4)
− P + B 'θ = 0 (5)
We will build all of these equality constraints into a matrix form of
Aeqx=beq. We begin by noting dimensions.
Columns: Since the solution vector x is 12×1, Aeq must have 12
columns in order to pre-multiply x.
Rows: Since there are 5 branches, eq. (4) will contribute 5 rows
to Aeq. Since there are 4 buses, eq. (5) will contribute 4 rows to
Aeq. So Aeq will have total of 9 rows.
We begin with the line flow equations, eq. (4). The D matrix is:
9
⎡10 0 0 0 0 ⎤
⎢ 0 10 0 0 0 ⎥
⎢ ⎥
D = ⎢ 0 0 10 0 0 ⎥
⎢ ⎥
⎢ 0 0 0 10 0 ⎥
⎢⎣ 0 0 0 0 10⎥⎦
The node-arc incidence matrix, A, is:
⎡1 0 0 - 1⎤
⎢1 - 1 0 0 ⎥
⎢ ⎥
A = ⎢0 1 − 1 0 ⎥
⎢ ⎥
⎢ 0 0 − 1 1 ⎥
⎢⎣1 0 − 1 0 ⎥⎦
The D×A product required by eq. (4) is then given by:
⎡10 0 0 0 0 ⎤ ⎡1 0 0 - 1⎤ ⎡10 0 0 − 10⎤
⎢ 0 10 0 0 0 ⎥ ⎢1 - 1 0 0 ⎥ ⎢10 − 10 0 0 ⎥
⎢ ⎥⎢ ⎥ ⎢ ⎥
D × A = ⎢ 0 0 10 0 0 ⎥ ⎢0 1 − 1 0 ⎥ = ⎢ 0 10 − 10 0 ⎥
⎢ ⎥⎢ ⎥ ⎢ ⎥
⎢ 0 0 0 10 0 ⎥⎢ 0 0 − 1 1 ⎥ ⎢ 0 0 − 10 10 ⎥
⎢⎣ 0 0 0 0 10⎥⎦ ⎢⎣1 0 − 1 0 ⎥⎦ ⎢⎣10 0 − 10 0 ⎥⎦
So based on eq. (4) and the solution vector, we can see that these
elements will occupy the upper right hand corner of Aeq. So that
will take care of the last 4 columns in the first 5 rows.
But what about the first 8 columns? These are the elements in the
line flow equations that multiply the variables Pg1, Pg2, Pg4,
PB1, PB2, PB3, PB4, PB5. Since we do not use the generation variables
within the line flow equations, the first 3 columns of these top 5
rows will be zeros. The next 5 columns in these top 5 rows
(columns 4-8) will also be zeros, except the one element in each of
10
these rows that multiplies the corresponding line flow variable, and
that element will be -1.
Finally, with respect to these top 5 equations, eq. (4) indicates that
the right-hand-side will be 0 for each of them.
Thus, we can now write down all elements in the first 5 rows of
our matrix, as follows:
⎡ Pg1 ⎤
⎢P ⎥
− 10⎤ ⎢ ⎥ ⎡ 0 ⎤
g2
⎡0 0 0 − 1 0 0 0 0 10 0 0
⎢0 ⎢ Pg 4 ⎥
⎢ 0 0 0 − 1 0 0 0 10 − 10 0 0 ⎥⎥ ⎢ ⎥ ⎢⎢ 0 ⎥⎥
PB1
⎢0 0 0 0 0 − 1 0 0 0 10 − 10 0 ⎥⎢ ⎥ ⎢0⎥
⎢ ⎥ ⎢ PB 2 ⎥ ⎢ ⎥
⎢0 0 0 0 0 0 −1 0 0 0 − 10 10 ⎥ ⎢ ⎥ ⎢ 0 ⎥
⎢ PB 3 ⎥
Aeq x = ⎢ 0 0 0 0 0 0 0 − 1 10 0 − 10 0 ⎥⎢ ⎥ = ⎢0⎥
⎢ ⎥ PB 4 ⎢ ⎥
⎢_ _ _ _ _ _ _ _ _ _ _ _ ⎥⎢ ⎥ ⎢_ ⎥
⎢_ ⎢ PB 5 ⎥
_ _ _ _ _ _ _ _ _ _ _ ⎥⎢ ⎥ ⎢_ ⎥
⎢ ⎥ θ1 ⎢ ⎥
⎢_ _ _ _ _ _ _ _ _ _ _ _ ⎥⎢ ⎥ ⎢_ ⎥
⎢_ ⎢ θ2 ⎥
⎣ _ _ _ _ _ _ _ _ _ _ _ ⎥⎦ ⎢ ⎥ ⎢⎣ _ ⎥⎦
⎢ θ3 ⎥
⎢⎣ θ 4 ⎥⎦
Now we need to write the last 4 equations. These are the DC power
flow equations corresponding to eq. (5).
11
⎡ 30 − 10 − 10 − 10⎤
⎢− 10 20 − 10 0 ⎥
B' = ⎢ ⎥
⎢− 10 − 10 30 − 10⎥
⎢ ⎥
⎣− 10 0 − 10 20 ⎦
So based on eq. (5) and the solution vector, we can see that this
matrix will occupy the lower right hand side of the Aeq matrix. So
that will take care of the last 4 columns in the bottom 4 rows. The
resulting matrix appears as:
⎡ Pg1 ⎤
⎢P ⎥
− 10⎤ ⎢ ⎥ ⎡ 0 ⎤
g2
⎡0 0 0 −1 0 0 0 0 10 0 0
⎢0 ⎢ Pg 4 ⎥
⎢ 0 0 0 −1 0 0 0 10 − 10 0 0 ⎥⎥ ⎢ ⎥ ⎢⎢ 0 ⎥⎥
PB1
⎢0 0 0 0 0 −1 0 0 0 10 − 10 0 ⎥⎢ ⎥ ⎢0⎥
⎢ ⎥ ⎢ PB 2 ⎥ ⎢ ⎥
⎢0 0 0 0 0 0 −1 0 0 0 − 10 10 ⎥ ⎢ ⎥ ⎢ 0 ⎥
⎢ PB 3 ⎥
Aeq x = ⎢ 0 0 0 0 0 0 0 −1 10 0 − 10 0 ⎥⎢ ⎥ = ⎢0⎥
⎢ ⎥ PB 4 ⎢ ⎥
⎢_ _ _ _ _ _ _ _ 30 − 10 − 10 − 10⎥ ⎢ ⎥ ⎢ _ ⎥
⎢_ ⎢ PB 5 ⎥
_ _ _ _ _ _ _ − 10 20 − 10 0 ⎥⎢ ⎥ ⎢_ ⎥
⎢ ⎥ θ1 ⎢ ⎥
⎢_ _ _ _ _ _ _ _ − 10 − 10 30 − 10⎥ ⎢ ⎥ ⎢ _ ⎥
⎢_ ⎢ θ2 ⎥
⎣ _ _ _ _ _ _ _ − 10 0 − 10 20 ⎥⎦ ⎢ ⎥ ⎢⎣ _ ⎥⎦
⎢ θ3 ⎥
⎢⎣ θ 4 ⎥⎦
12
⎡ Pg1 ⎤
⎢P ⎥
− 10⎤ ⎢ ⎥ ⎡ 0 ⎤
g2
⎡0 0 0 −1 0 0 0 0 10 0 0
⎢0 ⎢ Pg 4 ⎥
⎢ 0 0 0 −1 0 0 0 10 − 10 0 0 ⎥⎥ ⎢ ⎥ ⎢⎢ 0 ⎥⎥
PB1
⎢0 0 0 0 0 −1 0 0 0 10 − 10 0 ⎥⎢ ⎥ ⎢0⎥
⎢ ⎥ ⎢ PB 2 ⎥ ⎢ ⎥
⎢0 0 0 0 0 0 −1 0 0 0 − 10 10 ⎥ ⎢ ⎥ ⎢ 0 ⎥
⎢ PB 3 ⎥
Aeq x = ⎢ 0 0 0 0 0 0 0 −1 10 0 − 10 0 ⎥⎢ ⎥ = ⎢0⎥
⎢ ⎥ PB 4 ⎢ ⎥
⎢_ _ _ 0 0 0 0 0 30 − 10 − 10 − 10⎥ ⎢ ⎥ ⎢ _ ⎥
⎢_ ⎢ PB 5 ⎥
_ _ 0 0 0 0 0 − 10 20 − 10 0 ⎥⎢ ⎥ ⎢_⎥
⎢ ⎥ θ1 ⎢ ⎥
⎢_ _ _ 0 0 0 0 0 − 10 − 10 30 − 10⎥ ⎢ ⎥ ⎢ _ ⎥
⎢_ ⎢ θ2 ⎥
⎣ _ _ 0 0 0 0 0 − 10 0 − 10 20 ⎥⎦ ⎢ ⎥ ⎢⎣ _ ⎥⎦
⎢ θ3 ⎥
⎢⎣ θ 4 ⎥⎦
The first three columns multiply the generation variables Pg1, Pg2,
and Pg4. However, the DC power flow equations, eq. (5), require
the negative of the injections for all buses, and the injections are
the generation minus the load, i.e., Pgk-Pdk.
13
indicates that the injection, if modeled on the left-hand-side,
should be negative, i.e., on the left-hand side, Pgk-Pdk should be
negative. So we should see on the left-hand-side –Pgk+Pdk. But now
we will take the load term onto the right-hand-side by subtracting
it from both sides.
Thus, we see that the load term should show up on the right-hand-
side as a negative number. This same logic also shows us that the
elements multiplying the generation terms in the Aeq matrix should
be -1.
Inequality constraints:
14
⎡ 0.5 ⎤ ⎡ Pg1 ⎤ ⎡ 2 ⎤
⎢0.375⎥ ⎢ P ⎥ ⎢ 1.5 ⎥
⎢ ⎥ ⎢ g2 ⎥ ⎢ ⎥
⎢ 0.45 ⎥ ⎢ Pg 4 ⎥ ⎢ 1.8 ⎥
⎢ ⎥ ⎢ ⎥ ⎢ ⎥
⎢ − 500⎥ ⎢ PB1 ⎥ ⎢500⎥
⎢ − 500⎥ ⎢ PB 2 ⎥ ⎢500⎥
⎢ ⎥ ⎢ ⎥ ⎢ ⎥
⎢ − 500⎥ ≤ ⎢ PB 3 ⎥ ≤ ⎢500⎥
⎢ − 500⎥ ⎢ P ⎥ ⎢500⎥
⎢ ⎥ ⎢ B4 ⎥ ⎢ ⎥
⎢ − 500⎥ ⎢ PB 5 ⎥ ⎢500⎥
⎢ −π ⎥ ⎢ θ ⎥ ⎢ π ⎥
⎢ ⎥ ⎢ 1⎥ ⎢ ⎥
⎢ − π ⎥ ⎢ θ2 ⎥ ⎢ π ⎥
⎢ ⎥ ⎢ ⎥ ⎢ ⎥
⎢ − π ⎥ ⎢ θ3 ⎥ ⎢ π ⎥
⎢⎣ − π ⎥⎦ ⎢⎣ θ 4 ⎥⎦ ⎢⎣ π ⎥⎦
Solution by Matlab: The code for solving this linear program using
Matlab is given below:
15
%Load is system load plus losses
Load=2.1787;
16
The solution vector x is given by:
⎡ Pg1 ⎤ ⎡ 0.5 ⎤
⎢ P ⎥ ⎢ 1.2287 ⎥
⎢ g2 ⎥ ⎢ ⎥
⎢ Pg 4 ⎥ ⎢ 0.45 ⎥
⎢ ⎥ ⎢ ⎥
P
⎢ B1 ⎥ ⎢ − 0. 0152 ⎥
⎢ PB 2 ⎥ ⎢ 0.0955 ⎥
⎢ ⎥ ⎢ ⎥
⎢ ⎥ 0.3242 ⎥
x = ⎢ B 3 ⎥ = ⎢⎢
P
PB 4 0.4348 ⎥
⎢ ⎥ ⎢ ⎥
⎢ PB 5 ⎥ ⎢ 0.4197 ⎥
⎢ θ ⎥ ⎢ 0.0125 ⎥ , Z=2705.8
⎢ 1⎥ ⎢ ⎥
⎢ θ 2 ⎥ ⎢ 0.003 ⎥
⎢ ⎥ ⎢ ⎥
θ
⎢ ⎥ ⎢3 − 0 . 0295 ⎥
⎢⎣ θ 4 ⎥⎦ ⎢⎣ 0.0140 ⎥⎦
1 2
PB2=0.0955
PB3
PB1 = =0.3242
-0.0152 PB5=0.4197 Pd2=1pu
PB4 =
4 0.4348 3
Pg4=0.45pu Pd3=1.1787pu
17
One can easily check to see that the power is conserved at the
buses.
18
Should we expect the solutions to be the same, given the network
representation in the LOPF approach? The answer is NO, if the
flows are at the branch capacities.
But if the flows are all within the branch capacities (and we are not
representing losses), then the transmission system has no impact on
the dispatch, and in this case, the solution will be identical to the
solution that we obtained in the economic dispatch scenario.
The LPOPF solution is for the case where all flows are within their
branch capacities, since we have modeled all branch capacities to
be 500 pu. In per-unit, this is effectively infinite branch capacity.
BASE CASE:
Now we will investigate the Lagrange multipliers for this loading
level, assuming infinite capacity lines. These Lagrange multipliers,
which are the same as the dual variables, are given in Table 2.
19
Lagrange multipliers on the last four equality constraints are very
interesting to us, since they give the improvement in the objective
function if we increase the right-hand-side of the corresponding
equation by 1 unit. These are the so-called nodal prices, i.e., the
LMPs, given in $/per unit-hr. We see that the numbers are all
$1211/per unit-hr, and if we divide this by the power base of 100
MVA, we get $12.11/MW-hr.
We also see that all Lagrange multipliers on the lower bounds are
all zero, with the exception of the ones on Pg1 and Pg4, which are
96 and 43, respectively, with units of $/per unit-hr. Converting to
$/MW-hr, these values are 0.96 and 0.43, respectively, indicating
the amount of improvement we can expect if we increase the
corresponding right-hand-side of these inequalities by 1 unit. Since
these equations look like, for example, -Pg1<-0.5, an increase in the
right-hand-side corresponds to a decrease in the lower limit. Thus,
for Pg1, if we move the lower limit from 50 MW to 49 MW, we can
expect to improve the objective function by 96 cents per hour.
Lagrange multipliers for all other lower bounds, and for all upper
bounds, are zero, since none of the other inequality constraints are
binding.
20
objective function was Z=2705.8, an increase of 12.1 $/hr,
confirming our understanding of the meaning of the nodal prices.
1 2
PB2=0.0955
PB3
PB1 = =0.3242
-0.0152 PB5=0.4197 Pd2=1pu
PB4 =
4 0.4348 3
Pg4=0.45pu Pd3=1.1787pu
21
Pg2=1.1803pu
Pg1=0.5pu
1 2
PB2=0.1197
PB3 =0.3
PB1 =
-0.0393 PB5=0.4197 Pd2=1pu
PB4 =
4 0.4590 3
Pg4=0.4984pu Pd3=1.1787pu
22
Table 3: Lagrange multipliers for Pd2=1.0, Pd3=1.1787
and infinite transmission capacity except for and
0.3 capacity constraint on PB3 ($/per unit-hr)
Equality constraints Lower bounds Upper bounds
3
Equation Value*10 Variable value variable value
PB1 -0.0000 Pg1 63.7500 Pg1 0.0000
PB2 -0.0000 Pg2 0.0000 Pg2 0.0000
PB3 0.0860 Pg4 0.0000 Pg4 0.0000
PB4 0.0000 PB1 0.0000 PB1 0.0000
PB5 -0.0000 PB2 0.0000 PB2 0.0000
P1 1.2432 PB3 0.0000 PB3 86.0000
P2 1.2110 PB4 0.0000 PB4 0.0000
P3 1.2647 PB5 0.0000 PB5 0.0000
P4 1.2540 θ1 0.0000 θ1 0.0000
θ2 0.0000 θ2 0.0000
θ3 0.0000 θ3 0.0000
θ4 0.0000 θ4 0.0000
23
increasing the flow in this branch by 1 MW (from 0.30 per-unit
to 0.31 per-unit). It makes sense that the Lagrange multiplier on
the flow would be the same as the Lagrange multiplier on the
branch limit.
4. Nodal prices: The Lagrange multipliers on the equality
constraints corresponding to the 4 nodes are the nodal prices.
Without transmission constraints, these prices were all the same,
at 12.11 $/MW-hr, a price set entirely by the generator at bus 2
since it was the bus 2 generator that responded to any load
change. But now they are all different, with only bus 2 price at
12.11 $/MW-hr. This difference reflects that, because of the
transmission constraint, a load increase at one bus will incur a
different cost than a load increase at another bus.
1 2
PB2=0.1222
PB3 =0.3
PB1 =
-0.0443 PB5=0.4222 Pd2=1pu
PB4 =
4 0.4665 3
Pg4=0.5109pu Pd3=1.1887pu
24
Pg2=1.1803pu
Pg1=0.5pu
1 2
PB2=0.1197
PB3 =0.3
PB1 =
-0.0393 PB5=0.4197 Pd2=1pu
PB4 =
4 0.4590 3
Pg4=0.4984pu Pd3=1.1787pu
25