Manual
Manual
Version 3.1b1
August 1, 2006
Users Manual
Ray D. Zimmerman
[email protected]
Carlos E. Murillo-Snchez
[email protected]
Version 3.1b1
Table of Contents
Table of Contents...................................................................................................................................2
1
Introduction................................................................................................................................3
2
2.1
2.2
2.3
2.4
2.5
3
3.1
3.2
3.3
3.4
3.4.1
3.4.2
3.4.3
3.5
3.6
3.7
4
References..................................................................................................................................32
Version 3.1b1
1 Introduction
What is MATPOWER?
MATPOWER is a package of MATLAB M-files for solving power flow and optimal power flow problems.
It is intended as a simulation tool for researchers and educators that is easy to use and modify.
MATPOWER is designed to give the best performance possible while keeping the code simple to understand and modify. The MATPOWER home page can be found at:
http://www.pserc.cornell.edu/matpower/
Where did it come from?
MATPOWER was developed by Ray D. Zimmerman, Carlos E. Murillo-Snchez and Deqiang Gan of
PSERC at Cornell University (http://www.pserc.cornell.edu/) under the direction of Robert Thomas. The
initial need for MATLAB based power flow and optimal power flow code was born out of the computational requirements of the PowerWeb project (see http://www.pserc.cornell.edu/powerweb/).
Who can use it?
2 Getting Started
2.1 System Requirements
To use MATPOWER you will need:
MATLAB version 5 or later1
MATLAB Optimization Toolbox (required only for some OPF algorithms)
Both are available from The MathWorks (see http://www.mathworks.com/).
Version 3.1b1
2.2 Installation
Step 1:
Step 2:
Step 3:
To run an optimal power flow on the same system, but with the option for MATPOWER to shut down
(decommit) expensive generators, type:
>> runuopf('case30')
Version 3.1b1
MATPOWER also has many options which control the algorithms and the output. Type:
>> helpmpoption
3 Technical Reference
3.1 Data File Format
The data files used by MATPOWER are simply MATLAB M-files or MAT-files which define and return
the variables baseMVA, bus, branch, gen, areas, and gencost. The baseMVA variable is a scalar and the
rest are matrices. Each row in the matrix corresponds to a single bus, branch, or generator. The columns
are similar to the columns in the standard IEEE and PTI formats. The details of the specification of the
MATPOWER case file can be found in the help for caseformat.m:
>> help caseformat
CASEFORMAT
Defines the MATPOWER case file format.
A MATPOWER case file is an M-file or MAT-file which defines the variables
baseMVA, bus, gen, branch, areas, and gencost. With the exception of
baseMVA, a scalar, each data variable is a matrix, where a row corresponds
to a single bus, branch, gen, etc. The format of the data is similar to
the PTI format described in
http://www.ee.washington.edu/research/pstca/formats/pti.txt
except where noted. An item marked with (+) indicates that it is included
in this data but is not part of the PTI format. An item marked with (-) is
one that is in the PTI format but is not included here. Those marked with
(2) were added for version 2 of the case file format. The columns for
each data matrix are given below.
MATPOWER Case Version Information:
A version 1 case file defined the data matrices directly. The last two,
areas and gencost, were optional since they were not needed for running
a simple power flow. In version 2, each of the data matrices are stored
as fields in a struct. It is this struct, rather than the individual
matrices that is returned by a version 2 M-casefile. Likewise a version 2
MAT-casefile stores a struct named 'mpc' (for MATPOWER case). The struct
also contains a 'version' field so MATPOWER knows how to interpret the
data. Any case file which does not return a struct, or any struct which
does not have a 'version' field is considered to be in version 1 format.
See also IDX_BUS, IDX_BRCH, IDX_GEN, IDX_AREA and IDX_COST regarding
constants which can be used as named column indices for the data matrices.
Also described in the first three are additional columns that are added
to the bus, branch and gen matrices by the power flow and OPF solvers.
Version 3.1b1
Version 3.1b1
Some columns are added to the bus, branch and gen matrices by the solvers. See the help for idx_bus,
idx_brch, and idx_gen for more details.
Version 3.1b1
3.2 Modeling
AC Formulation
Fixed loads are modeled as constant real and reactive power injections, Pd and Qd specified in columns 3
and 4, respectively, of the bus matrix. The shunt admittance of any constant impedance shunt elements at
a bus are specified by Gsh and Bsh in columns 5 and 6, respectively, of the bus matrix
G + jBsh
Ysh = sh
baseMVA
transmission line, transformer or phase shifter, is modeled as a standard -model
Each branch,whether
transmission line, with series resistance R and reactance X and total line charging capacitance Bc , in series
with an ideal transformer and phase
shifter, at the from end, with tap ratio and phase shift angle shift .
The parameters R, X, Bc , and shift , are found in columns 3, 4, 5, 9 and 10 of the branch matrix, respectively. The branch voltages and currents at the from and to ends of the branch are related by the branch
If
Vf
(1)
= Ybr
It
Vt
Bc 1
Ys + j 2
2
where Ybr =
Ys 1
j
e shift
e and Y = 1 .
s
B
R + jX
Ys + j c
2
1
Ys
j shift
The elements of the individual branch admittance matrices and the bus shunt admittances are combined
by MATPOWER to form a complexbus admittance matrix Ybus , relating the vector of complex bus voltages Vbus with the vector of complex bus current injections Ibus
Ibus = Ybus Vbus
Similarly, admittance matrices Yf and Yt , are formed to compute the vector of complex current injections
at the from and to ends of each line, given
I f = Yf Vbus
It = Yt Vbus
The vectors of complex bus power injections, and branch power injections can be expressed as
Version 3.1b1
where Vf and Vt are vectors of the complex bus voltages at the from and to ends, respectively, of all
branches, and diag() converts a vector into a diagonal matrix with the specified vector on the diagonal.
DC Formulation
For the DC formulation, the same parameters are used, with the exception that the following assumptions
are made:
Branch resistances R and charging capacitances Bc are negligible (i.e. branches are lossless).
Combining these assumptions and equation (1) with the fact that S = VI * , the relationship between the
real power flows and voltage angles for an individual branch can be written as
Pf
f Pf ,shift
(2)
= Bbr +
Pt
t Pt,shift
where
1 1 1
X 1 1
(3)
Pf ,shift shift 1
=
.
Pt,shift X 1
(4)
Bbr =
The elements of the individual branch shift injections and Bbr matrices are combined by MATPOWER to
form a bus Bbus matrix and Pbus,shift
shift injection vector, which can be used to compute bus real power
injections from bus voltage angles
Pbus =Bbus bus + Pbus,shift
Similarly, MATPOWER builds the matrix B f and the vector P f,shift which can be used to compute the
vector s Pf and Pt of branch realpower injections
Pf = B f bus + Pf,shift
Pt = Pf
Version 3.1b1
The last method is a DC power flow [13], which is obtained by executing runpf with the PF_DC option
set to 1, or equivalently by executing rundcpf directly. The DC power flow is obtained by a direct, noniterative solution of the bus voltage angles from the specified bus real power injections, based on equations (2), (3) and (4).
For the AC power flow solvers, if the ENFORCE_Q_LIMS option is set to true (default is false), then if any
generator reactive power limit is violated after running the AC power flow, the corresponding bus is converted to a PQ bus, with the reactive output set to the limit, and the case is re-run. The voltage magnitude
at the bus will deviate from the specified value in order to satisfy the reactive power limit. If the generator
at the reference bus is reaches a reactive power limit and the bus is converted to a PQ bus, the first remaining PV bus will be used as the slack bus for the next iteration. This may result in the real power output at this generator being slightly off from the specified values.
Currently, none of MATPOWERs power flow solvers include any transformer tap changing or handling
of disconnected or de-energized sections of the network.
Performance of the power flow solvers, with the exception of Gauss-Seidel, should be excellent even on
very large-scale power systems, since the algorithms and implementation take advantage of MATLABs
built-in sparse matrix handling.
10
Version 3.1b1
In addition to the values listed for the power flow solvers, the OPF solution also includes the following
values:
bus(:, LAM_P)
bus(:, LAM_Q)
bus(:, MU_VMAX)
bus(:, MU_VMIN)
gen(:, MU_PMAX)
gen(:, MU_PMIN)
gen(:, MU_QMAX)
gen(:, MU_QMIN)
branch(:, MU_SF)
branch(:, MU_ST)
f
The (chronologically) first of the OPF solvers in MATPOWER is based on the constr function included
in earlier versions of MATLABs Optimization Toolbox, which uses a successive quadratic programming
technique with a quasi-Newton approximation for the Hessian matrix. The second approach is based on
linear programming. It can use the LP solver in the Optimization Toolbox or other MATLAB LP solvers
available from third parties. Version 3 of MATPOWER has a new generalized OPF formulation that allows general linear constraints on the optimization variables, but requires fmincon.m found in MATLABs
Optimization Toolbox 2.0 or later, or the MINOS [14] based MEX file available separately as part of the
optional MINOPF package (see http://www.pserc.cornell.edu/minopf/). MINOPF is distributed separately because it has a more restrictive license than MATPOWER.
The performance of MATPOWERs OPF solvers depends on several factors. First, the constr function
uses an algorithm which does not exploit or preserve sparsity, so it is inherently limited to small power
systems. The same is still true for the combination of parameters required to be able to employ the newer
fmincon function. The LP-based algorithm, on the other hand, does preserve sparsity. However, the LPsolver included in the older Optimization Toolbox does not exploit this sparsity. In fact, the LP-based
method with the old LP solver performs worse than the constr-based method, even on small systems.
Fortunately, there are LP-solvers available from third parties which do exploit sparsity. In general, these
yield much higher performance. One in particular, called BPMPD [8] (actually a QP-solver), has proven
to be robust and efficient. Even the constr or fmincon-based methods, when tricked into calling
BPMPD with full matrix data instead of the older qp.m, become much faster.
It should be noted, however, that even with a good LP-solver, MATPOWERs LP-based OPF solver, unlike its power flow solver, is not suitable for very-large scale problems. Substantial improvements in performance may still be possible, though they may require significantly more complicated coding and possibly a custom LP-solver. However, when speed is of the essence, the preferred choice is the MINOSbased MEX file solver; assuming that its licensing requirements can be met. It is coded in FORTRAN
and evaluates the required Jacobians using an optimized structure that follows the order of evaluation imposed by the compressed-column sparse format which is employed by MINOS. In fact, the new generalized OPF formulation included in MATPOWER 3.0 and later is inspired by the data format used by
MINOS.
11
Version 3.1b1
MATPOWERs OPF implementation is not currently able to handle unconnected or de-energized sections of the network.
Piecewise linear costs using constrained cost variables (CCV)
The OPF formulations in MATPOWER allow for the specification of convex piecewise linear cost functions for active or reactive generator output. An example of such a cost curve is shown below.
This non-differentiable cost is modeled using an extra helper cost variable for each such cost curve and
additional constraints on this variable and Pg, one for each segment of the curve. The constraints build a
convex basin equivalent to requiring the cost variable to lie in the epigraph of the cost curve. When the
cost is minimized, the cost variable will be pushed against this basin. If the helper cost variable is y, then
the contribution of the generators cost to the total cost is exactly y. In the above case, the two additional
required constraints are
1) y m1 (Pg x0 ) + c0
2) y m2 (Pg x1 ) + c1
where m1 and m2 are the slopes of the two segments. Also needed, of course, are the box restrictions on
Pg :PminPg Pmax. The additive part of the cost contributed by this generator is y.
This constrained cost variable (CCV) formulation is used by all of the MATPOWER OPF solvers for
handling piecewise linear cost functions.
3.4.1 Traditional AC OPF Formulation
The AC optimal power flow problem solved by MATPOWER is a smooth OPF with no discrete variables or controls. The objective function is the total cost of real and/or reactive generation. These costs
may be defined as polynomials or as piecewise-linear functions of generator output. The problem is formulated as follows:
12
min
,V ,Pg ,Qg
1i
Version 3.1b1
subject to
Pi ( ,V ) Pgi + Pdi = 0
Qi ( ,V ) Qgi + Qdi = 0
Sijf ( ,V ) Sijmax
Sijt ( ,V ) Sijmax
Vi min Vi Vi max
Here f1i and f2i are the costs of active and reactive power generation, respectively, for generator i at a given
dispatch point. Both f1i and f2i are assumed to be polynomial or piecewise-linear functions. By defining
the variable x as
V
x =
Pg
Qg
the problem can be expressed compactly as follows:
min f (x)
x
subject to
g1 (x) = 0
g2 (x) 0
xmin x xmax
(variable limits)
Optimization Toolbox
Based OPF Solver (constr)
two original OPF solvers in MATPOWER is based on the constr non-linear constrained
The first of the
optimization function in MATLABs Optimization Toolbox. The constr function and the algorithms it
uses are covered in the older Optimization Toolbox manual [6]. MATPOWER provides constr with two
M-files which it uses during for the optimization. One computes the objective function, f, and the constraint violations, g, at a given point, x, and the other computes their gradients f x and g x .
MATPOWER has two versions of these M-files. One set is used to solve systems with polynomial cost
functions. In this formulation, the cost functions are included in a straightforward way into the objective
function. The other set is used to solve systems with piecewise-linear costs. Piecewise-linear cost functions are handled by introducing a cost variable for each piecewise-linear cost function. The objective
function is simply the sum of these cost variables which are then constrained to lie above each of the linear functions which make up the piecewise-linear cost function. Clearly, this method works only for con13
Version 3.1b1
vex cost functions. In the MATPOWER documentation this will be referred to as a constrained cost variable (CCV) formulation.
The algorithm codes 100 and 200, respectively, are used to identify the constr-based solver for polynomial and piecewise-linear cost functions. If algorithm 200 is chosen for a system with polynomial cost
function, the cost function will be approximated by a piecewise-linear function by evaluating the polynomial at a fixed number of points determined by the options vector (see Section3.6 for more details on the
MATPOWER options).
It should be noted that the constr-based method can also benefit from a superior QP-solver such as
bpmpd. See Appendix A for more information on LP and QP-solvers.
LP-Based OPF Solver (LPconstr)
Linear programming based OPF methods are in wide use today in the industry. However, the LP-based
algorithm included in MATPOWER is much simpler than the algorithms used in production-grade software.
The LP-based methods in MATPOWER use the same problem formulation as the constr-based methods, including the CCV formulation for the case of piecewise-linear costs. The compact form of the OPF
problem can be rewritten to partition g into equality and inequality constraints, and to partition the variable x as follows:
min f (x 2 )
x
subject to
g1 (x 1 ,x 2 ) = 0
g2 (x 1 , x2 ) 0
(equality constraints)
(inequality constraints)
where x1 contains the system voltage magnitudes and angles, and x2 contains the generator real and reactive power outputs (and corresponding cost variables for the CCV formulation). This is a general nonlinear programming problem, with the additional assumption that the equality constraints can be used to
solve for x1 , given a value for x2 .
The LP-based OPF solver is implemented with a function LPconstr, which is similar to constr in that it
uses the same M-files for computing the objective function, constraints, and their respective gradients. In
addition, a third M-file (lpeqslvr.m) is needed to solve for x1 from the equality constraints, given a value
for x2 . This architecture makes it relatively simple to modify the formulation of the problem and still be
able to use both the constr-based and LP-based solvers.
The algorithm proceeds as follows, where the superscripts denote iteration number:
Step 0:
Set iteration counter k 0 and choose an appropriate initial value, call it x20 , for x2 .
Step 1:
Solve the equality constraint (power flow) equations g1 (x1k , x k2 ) = 0 for x1k .
14
Version 3.1b1
min
x
x x
x=xk
subject to
g
x g( x k )
x x = x k
x
15
Version 3.1b1
16
Version 3.1b1
gS f (x) = S f ( ,V ) Smax 0
gSt (x) = St ( ,V ) Smax 0
x
l A y u
z
xmin x xmax
The most significant additions to the traditional, simple OPF formulation appear in the generalized cost
terms containingw and in the general linear constraints involving the matrix A, described in the next two
sections. These
allow tremendous flexibility in customizing the problem formulation,
two frameworks
making MATPOWER
even more useful as a research tool.
Note: In Optimization Toolbox versions 3.0 and earlier, fmincon seems to be providing inaccurate
shadow prices on the constraints. This did not happen with constr and it may be a bug in these versions of the Optimization Toolbox.
General Linear Constraints
In addition to the standard non-linear equality constraints for nodal power balance and non-linear inequality constraints for line flow limits, this formulation includes a framework for additional linear constraints involving the full set of optimization variables.
x
l A y u
(general linear constraints)
z
Some portions of these linear constraints are supplied directly by the user, while others are generated
automatically based on the case data. Automatically generated portions include:
rows for constraints
17
Version 3.1b1
where nx is the number of x variables. If Au has more than nx columns, a corresponding z optimization
variable is created for each additional column. These z variables also enter into the generalized cost terms
described below, so Au and N must have the same number of columns.
x
lu Au u u
(user supplied linear constraints)
z
Change from MATPOWER 3.0: The Au matrix supplied by the user no longer includes the (all zero) columns corresponding to the y variables for piecewise linear generator costs. This should simplify significantly the creation
of the desired Au matrix.
Generalized Cost Function
The cost function consists of 3 parts. The first two are the polynomial and piecewise linear costs, respectively, of generation. A polynomial or piecewise linear cost is specified for each generators active output
and, optionally, reactive output in the appropriate row(s) of the gencost matrix. Any piecewise linear
costs are implemented using the CCV formulation described above which introduces corresponding
helper y variables. The general formulation allows generator costs of mixed type (polynomial and piecewise linear) in the same problem.
The third part of the cost function provides a general framework for imposing additional costs on the optimization variables, enabling things such as using penalty functions as soft limits on voltages, additional
costs on variables involved in constraints handled by Langrangian relaxation, etc.
This general cost term is specified through a set of parameters H, Cw, N and fparm, described below. It
consists of a general quadratic function of an nw 1 vector w of transformed optimization variables.
1 T
w Hw + C wT w
2
H is the nw nw symmetric, sparse matrix of quadratic coefficients and Cw is the nw 1 vector of linear
coefficients. The sparse N matrix is nw n xz , where the number of columns must match that of any user
supplied Au matrix. And fparm is nw
4 , where the 4 columns are labeled as
f parm = [d
r h m] .
The vector w is created from the x and z optimization variables by first applying a general linear trans
formation
x
r = N ,
z
followed by a scaled function with a shifted dead zone, defined by the remaining elements of fparm.
Each element of r is transformed into the corresponding element of w as follows:
m
f (r r + h ),
i i i i i
wi =
0,
m f r r h ,
i i( i i i)
ri ri < hi
hi ri ri hi
ri ri > hi
where the function fi is a predetermined function selected by the index in di. The current implementation
includes linear and quadratic options.
t,
f i (t ) = 2
t ,
18
di = 1
di = 2
Version 3.1b1
The linear case, where di = 1, is illustrated below, where wi is found by shifting ri by ri , applying a dead
zone defined by hi and then scaling by mi.
wi
mi
ri
ri
hi
19
Version 3.1b1
Qg
QC1MAX
QMAX
QC2MAX
Pg
QC2MIN
QMIN
QC1MIN
PC1 PMIN
PMAX
PC2
The particular values of PC1 and PC2 are not important and may be set equal to PMIN and PMAX for convenience. The important point is to set the corresponding QCnMAX (QCnMIN) limits such that the two resulting points define the desired line corresponding to the upper (lower) sloped portion of the capability
curve.
Dispatchable loads
In general, dispatchable or price-sensitive loads can be modeled as negative real power injections with
associated costs. The current test is that if PMIN < PMAX = 0 for a generator, then it is really a dispatchable
load. If a load has a demand curve like the following
20
Version 3.1b1
so that it will consume zero if the price is higher than price2, P1 if the price is less than price2 but higher
than price1, and P2 if the price is equal or lower than price1. Considered as a negative injection, the desired dispatch is zero if the price is greater than price2, -P1 if the price is higher than price1 but lower
than price2, and -P2 if the price is equal to or lower than price1. This suggests the following piecewise
linear cost curve:
Note that this assumes that the demand blocks can be partially dispatched or split; if the price trigger
is reached half-way through the block, the load must accept the partial block. Otherwise, accepting or rejecting whole blocks really poses a mixed-integer problem, which is outside the scope of the current
MATPOWER implementation.
When there are dispatchable loads, the issue of reactive dispatch arises. If the QMIN/QMAX generation limits for the negative generator in question are not set to zero, then the algorithm will dispatch the reactive injection to the most convenient value. Since this is not normal load behavior, in the generalized formulation it is assumed that dispatchable loads maintain a constant power factor. The mechanism for
posing additional general linear constraints is employed to automatically include restrictions for these
injections to keep the ratio of Pg and Qg constant. This ratio is inferred from the values of PMIN and either
QMIN (for inductive loads) or QMAX (for capacitive loads) in the gen table. It is important to set these appropriately, keeping in mind that PG is negative and that for normal inductive loads QG should also be
negative (a positive reactive load is a negative reactive injection). The initial values of the PG and QG columns of the gen matrix must be consistent with the ratio defined by PMIN and the appropriate Q limit.
Problem Data Transformation
Defining a user supplied A matrix to add additional linear constraints requires knowledge of the order of
the optimization variables in the x vector. This requires an understanding of the standard transformations
performed on the input data (bus, gen, branch, areas and gencost tables) before the problem is solved.
All of these transformations are reversed after solving the problem so the output data is correctly placed
in the tables.
The first step filters out inactive generators and branches; original tables are saved for data output.
comgen
onbranch
gen
branch
=
=
=
=
The second step is a renumbering of the bus numbers in the bus table so that the resulting table contains
consecutively-numbered buses starting from 1:
21
Version 3.1b1
where i2e is saved for inverse reordering at the end. Finally, generators are further reordered by bus
number:
ng = size(gen,1);
% number of generators or injections
[tmp, igen] = sort(gen(:, GEN_BUS));
[tmp, inv_gen_ord] = sort(igen); % save for inverse reordering at the end
gen = gen(igen, :);
if ng == size(gencost,1)
% This is because gencost might have
gencost = gencost(igen, :);
% twice as many rows as gen if there
else
% are reactive injection costs.
gencost = gencost( [igen; igen+ng], :);
end
Having done this, the variables inside the x vector now have the same ordering as in the bus, gen tables:
x = [
Theta ;
V
;
Pg ;
Qg ];
%
%
%
%
nb
nb
ng
ng
and the nonlinear constraints have the same order as in the bus, branch tables
g = [
gp;
gq;
gsf;
gst ];
%
%
%
%
nb
nb
nl
nl
With this setup, box bounds on the variables are applied as follows: the reference angle is bounded above
and below with the value specified for it in the original bus table. The V section of x is bounded above
and below with the corresponding values for VMAX and VMIN in the bus table. The Pg and Qg sections of
x are bounded above and below with the corresponding values for PMAX, PMIN, QMAX and QMIN in the gen
table. The nonlinear constraints are similarly setup so that gp and gq are equality constraints (zero RHS)
and the limits for gsf, gst are taken from the RATE_A column in the branch table.
Example of Additional Linear Constraint
The following example illustrates how an additional general linear constraint can be added to the problem
formulation. In the standard solution to case9.m, the voltage angle for bus 7 lags the voltage angle in bus
2 by 6.09 degrees. Suppose we want to limit that lag to 5 degrees at the most. A linear restriction of the
form
Theta(2) Theta(7) <= 5 degrees
would do the trick. We have nb = 9 buses, ng = 3 generators and nl = 9 branches. Therefore the first 9
elements of x are bus voltage angles, elements 10-18 are bus voltage magnitudes, elements 19-21 are active injections corresponding to the generators in buses 1, 2 and 3 (in that order) and elements 22-24 are
the corresponding reactive injections. Note that in this case the generators in the original data already appear in ascending bus order, so no permutation with respect to the original data is necessary. Going back
to the angle restriction, we see that it can be cast as
[ 0 1 0 0 0 0 -1 0 0 zeros(1,nb+ng+ng) ] * x
22
<= 5 degrees
Version 3.1b1
u = 5 * pi/180;
mpopt = mpoption('OPF_ALG', 520); % use fmincon w/generalized formulation
opf('case9', A, l, u, mpopt)
min fi (Pgi )
,Pg
subject to
Bbus = Pg Pd Pbus,shift Gsh
B f P max Pf ,shift
B f P max + Pf ,shift
The voltage
angle at the reference bus is also constrained to the specified value. Since all constraints are
problem
linear, the
is a simple LP or QP problem depending on the form of the cost function.
The current implementation of the DC OPF does not allow additional user-supplied linear constraints
and costs as in the generalized AC OPF formulation described above.
MATPOWER uses an algorithm similar to dynamic programming to handle the decommitment. It proceeds through a sequence of stages, where stage N has N generators shut down, starting with N = 0.
The algorithm proceeds as follows:
Step 1: Begin at stage zero (N = 0), assuming all generators are on-line with all limits in place.
Step 2: Solve a normal OPF. Save the solution as the current best.
Step 3: Go to the next stage, N = N + 1. Using the best solution from the previous stage as the base
case for this stage, form a candidate list of generators with minimum generation limits binding.
If there are no candidates, skip to step 5.
Step 4: For each generator on the candidate list, solve an OPF to find the total system cost with this
generator shut down. Replace the current best solution with this one if it has a lower cost.
If any of the candidate solutions produced an improvement, return to step 3.
Step 5: Return the current best solution as the final solution.
23
Version 3.1b1
is another way to run the OPF solver with the all of the default options.
The MATPOWER options vector controls the following:
power flow algorithm
power flow termination criterion
OPF algorithm
OPF default algorithms for different cost models
OPF cost conversion parameters
OPF termination criterion
verbose level
printing of results
The details are given below:
>> help mpoption
MPOPTION Used to set and retrieve a MATPOWER options vector.
opt = mpoption
returns the default options vector
opt = mpoption(name1, value1, name2, value2, ...)
returns the default options vector with new values for up to 7
options, name# is the name of an option, and value# is the new
value. Example: options = mpoption('PF_ALG', 2, 'PF_TOL', 1e-4)
opt = mpoption(opt, name1, value1, name2, value2, ...)
same as above except it uses the options vector opt as a base
instead of the default options vector.
The currently defined options are as follows:
idx - NAME, default
description [options]
--------------------------------------------------power flow options
1 - PF_ALG, 1
power flow algorithm
[
1 - Newton's method
]
[
2 - Fast-Decoupled (XB version)
]
[
3 - Fast-Decoupled (BX version)
]
[
4 - Gauss Seidel
]
2 - PF_TOL, 1e-8
termination tolerance on per unit
P & Q mismatch
3 - PF_MAX_IT, 10
maximum number of iterations for
Newton's method
24
Version 3.1b1
- PF_MAX_IT_FD, 30
25
Version 3.1b1
output options
31 - VERBOSE, 1
amount of progress info printed
[
0 - print no progress info
]
[
1 - print a little progress info
]
[
2 - print a lot of progress info
]
[
3 - print all progress info
]
32 - OUT_ALL, -1
controls printing of results
[ -1 - individual flags control what prints
]
[
0 - don't print anything
]
[
(overrides individual flags, except OUT_RAW)
]
[
1 - print everything
]
[
(overrides individual flags, except OUT_RAW)
]
33 - OUT_SYS_SUM, 1
print system summary
[
0 or 1 ]
34 - OUT_AREA_SUM, 0
print area summaries
[
0 or 1 ]
35 - OUT_BUS, 1
print bus detail
[
0 or 1 ]
36 - OUT_BRANCH, 1
print branch detail
[
0 or 1 ]
37 - OUT_GEN, 0
print generator detail [
0 or 1 ]
(OUT_BUS also includes gen info)
38 - OUT_ALL_LIM, -1
control constraint info output
[ -1 - individual flags control what constraint info prints]
[
0 - no constraint info (overrides individual flags)
]
[
1 - binding constraint info (overrides individual flags)]
[
2 - all constraint info (overrides individual flags)
]
39 - OUT_V_LIM, 1
control output of voltage limit info
[
0 - don't print
]
[
1 - print binding constraints only
]
[
2 - print all constraints
]
[
(same options for OUT_LINE_LIM, OUT_PG_LIM, OUT_QG_LIM) ]
40 - OUT_LINE_LIM, 1
control output of line limit info
41 - OUT_PG_LIM, 1
control output of gen P limit info
42 - OUT_QG_LIM, 1
control output of gen Q limit info
43 - OUT_RAW, 0
print raw data for Perl database
interface code
[
0 or 1 ]
other options
51 - SPARSE_QP, 1
pass sparse matrices to QP and LP
solvers if possible
[
0 or 1 ]
26
Version 3.1b1
MINOPF options
61 - MNS_FEASTOL, 0 (1E-3)
62
63
64
65
66
67
68
69
70
71
72
73
27
Version 3.1b1
Top-level programs:
cdf2matp.m
converts data from IEEE CDF to MATPOWER format
runcomp.m
runs 2 OPFs and compares results
rundcopf.m
runs a DC optimal power flow
rundcpf.m
runs a DC power flow
runduopf.m
runs a DC OPF with unit decommitment
runopf.m
runs an optimal power flow
runpf.m
runs a power flow
runuopf.m
runs an OPF with unit decommitment
(see also opf.m, copf.m, fmincopf.m, lpopf.m below which can also be used as top-level pro-
grams)
Input data files:
caseformat.m
case_ieee30.m
case118.m
case14.m
case30.m
case300.m
case30pwl.m
case30Q.m
case39.m
case4gs.m
case57.m
case6ww.m
case9.m
case9Q.m
28
Version 3.1b1
29
Version 3.1b1
30
Version 3.1b1
31
Version 3.1b1
4 Acknowledgments
The authors would like to acknowledge contributions from several people. Thanks to Chris DeMarco,
one of our PSERC associates at the University of Wisconsin, for the technique for building the Jacobian
matrix. Our appreciation to Bruce Wollenberg for all of his suggestions for improvements to version 1.
The enhanced output functionality in version 2.0 are primarily due to his input. Thanks also to Andrew
Ward for code which helped us verify and test the ability of the OPF to optimize reactive power costs.
Thanks to Alberto Borghetti for contributing code for the Gauss-Seidel power flow solver. Thanks also
to many others who have contributed code, bug reports and suggestions over the years. Last but not least,
we would like to acknowledge the input of Bob Thomas throughout the development of MATPOWER
here at PSERC Cornell.
5 References
1. R. van Amerongen, A General-Purpose Version of the Fast Decoupled Loadflow, IEEE Transactions on Power Systems, Vol. 4, No. 2, May 1989, pp. 760-770.
2. O. Alsac, J. Bright, M. Prais, B. Stott, Further Developments in LP-based Optimal Power Flow,
IEEE Transactions on Power Systems, Vol. 5, No. 3, Aug. 1990, pp. 697-711.
3. R. Fletcher, Practical Methods of Optimization, 2n d Edition, John Wiley & Sons, p. 96.
4. P. E. Gill, W. Murry, M. H. Wright, Practical Optimization, Academic Press, London, 1981.
5. A. F. Glimm and G. W. Stagg, Automatic calculation of load flows, AIEE Transactions (Power
Apparatus and Systems), vol. 76, pp. 817-828, Oct. 1957.
6. A. Grace, Optimization Toolbox, The MathWorks, Inc., Natick, MA, 1995.
7. C. Li, R. B. Johnson, A. J. Svoboda, A New Unit Commitment Method, IEEE Transactions on
Power Systems, Vol. 12, No. 1, Feb. 1997, pp. 113-119.
8. C. Mszros, The efficient implementation of interior point methods for linear programming and
their applications, Ph.D. Thesis, Etvs Lornd University of Sciences, 1996.
9. B. Stott, Review of Load-Flow Calculation Methods, Proceedings of the IEEE, Vol.62, No.7,
July 1974, pp. 916-929.
10. B. Stott and O. Alsac, Fast decoupled load flow, IEEE Transactions on Power Apparatus and
Systems, Vol. PAS-93, June 1974, pp. 859-869.
11. B. Stott, J. L. Marino, O. Alsac, Review of Linear Programming Applied to Power System Rescheduling, 1979 PICA, pp. 142-154.
12. W. F. Tinney and C. E. Hart, Power Flow Solution by Newtons Method, IEEE Transactions on
Power Apparatus and Systems, Vol. PAS-86, No. 11, Nov. 1967, pp. 1449-1460.
13. A. J. Wood and B. F. Wollenberg, Power Generation, Operation, and Control, 2n d Edition, John
Wiley & Sons, p. 108-111.
14. B.A Murtagh andM.A. Saunders, MINOS 5.5 Users Guide, Stanford University Systems Optimization Laboratory Technical Report SOL83-20R.
32
Version 3.1b1
Some versions of MATLAB 5 were slow at selecting rows of a large sparse matrix, but much faster at
transposing and selecting columns.
fmincon.m seems to compute inaccurate shadow prices for Optimization Toolbox 3.0 and earlier.
33
Version 3.1b1
See http://www.pserc.cornell.edu/minopf/
3
See http://www.pserc.cornell.edu/powerweb/
34
Version 3.1b1
split by intersection of the offer and bid stacks). There is often a gap between the last accepted bid and
the last accepted offer. Since any price within this range is acceptable to all buyers and sellers, we end up
with a number of options for how to set the price, as listed in the table below.
Auction
Type
Name
discriminative
LAO
FRO
LAB
FRB
first price
second price
7
8
Description
The price of each cleared offer (bid) is equal to the offered (bid) price.
split-the-difference Uniform price equal to the average of the LAO and LAB.
dual LAOB
Uniform price for sellers equal to LAO, for buyers equal to LAB.
Generalizing to a network with possible losses and congestion results in nodal prices P which vary according to location. These P values can be used to normalize all bids and offers to a reference location
by adding a locational adjustment. For bids and offers at bus i, the adjustment is P,ref P,i , where P,ref
is the nodal price at the reference bus. The desired uniform pricing rule can then be applied to the ad This uniform price is then
justed offers and bids to get the appropriate uniform price at the reference bus.
by subtracting the locational adjustment. The appropriate locationally adjusted uniadjusted for location
form price is then used for all cleared bids and offers.
There are certain circumstances under which the price of a cleared offer determined by the above procedures can be less than the original offer price, such as when a generator is dispatched at its minimum
generation limit, or greater than the price cap lim.P.max_cleared_offer. For this reason all cleared
offer prices are clipped to be greater than or equal to the offer price but less than or equal to
lim.P.max_cleared_offer. Likewise, cleared bid prices are less than or equal to the bid price but
greater than or equal to lim.P.min_cleared_bid.
Handling Supply Shortfall
In single sided markets, in order to handle situations where the offered capacity is insufficient to meet the
demand under all of the other constraints, resulting in an infeasible OPF, we introduce the concept of
emergency imports. We model an import as a fixed injection together with an equal sized dispatchable
load which is bid in at a high price. Under normal circumstances, the two cancel each other and have no
effect on the solution. Under supply shortage situations, the dispatchable load is not fully dispatched, resulting in a net injection at the bus, mimicking an import. When used in conjunction with the LAO pricing rule, the marginal load bid will not set the price if all offered capacity can be used.
Example
Six generators with three blocks of capacity each, offering as follows:
35
Version 3.1b1
Generator
Block 1
Block 2
Block 3
MW @ $/MWh MW @ $/MWh
MW @ $/MWh
12 @ $20
24 @ $50
24 @ $60
12 @ $20
24 @ $40
24 @ $70
12 @ $20
24 @ $42
24 @ $80
12 @ $20
24 @ $44
24 @ $90
12 @ $20
24 @ $46
24 @ $75
12 @ $20
24 @ $48
24 @ $60
Block 2
Block 3
MW @ $/MWh
MW @ $/MWh
MW @ $/MWh
10 @ $100
10 @ $70
10 @ $60
10 @ $100
10 @ $50
10 @ $20
10 @ $100
10 @ $60
10 @ $50
Load
The case file t/t_auction_case.m, used for this example, is a modified version of the 30-bus system
that has 9 generators, where the last three have negative PMIN to model the dispatchable loads.
To solve this case using an AC optimal power flow and a last accepted offer (LAO) pricing rule, we use
mkt.OPF = 'AC';
mkt.auction_type = 1;
36
Version 3.1b1
bids.P.qty = [ ...
10 10 10;
10 10 10;
10 10 10 ];
bids.P.prc =
100 70
100 50
100 60
[ ...
60;
20;
50 ];
[mpc_out, co, cb, f, dispatch, success, et] = runmarket(mpc, offers, bids, mkt);
23.3156
24.0000
24.0000
24.0000
24.0000
24.0000
0
0
0
0
0
0
50.0000
50.2406
50.3368
51.0242
52.1697
52.9832
50.0000
50.2406
50.3368
51.0242
52.1697
52.9832
10.0000
0
10.0000
10.0000
0
0
51.8207
54.0312
55.6208
51.8207
54.0312
55.6208
>> co.P.prc
ans =
50.0000
50.2406
50.3368
51.0242
52.1697
52.9832
>> cb.P.qty
ans =
10.0000
10.0000
10.0000
>> cb.P.prc
ans =
51.8207
54.0312
55.6208
37
Version 3.1b1
$/MWh
35.3
$50.00
36
$50.24
36
$50.34
36
$51.02
36
$52.17
36
$52.98
$/MWh
30.0
$51.82
10.0
$54.03
20.0
$55.62
38