Manual
Manual
Manual
Version 3.2
September 21, 2007
User’s Manual
Table of Contents
1 Introduction................................................................................................................................. 3
5 References.................................................................................................................................. 33
2
MATPOWER User’s Manual Version 3.2
1 Introduction
What is MATPOWER?
MATPOWER is a package of MATLAB M-files for solving power flow and optimal power flow prob-
lems. 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/
MATPOWER was developed by Ray D. Zimmerman, Carlos E. Murillo-Sánchez 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/).
3
MATPOWER User’s Manual Version 3.2
2 Getting Started
2.1 System Requirements
To use MATPOWER you will need:
• MATLAB version 6 or later1
• MATLAB Optimization Toolbox (required only for some OPF algorithms)
Both are available from The MathWorks (see http://www.mathworks.com/).
2.2 Installation
Step 1: Go to the MATPOWER home page (http://www.pserc.cornell.edu/matpower/) and follow the
download instructions.
Step 2: Unzip the downloaded file.
Step 3: Place the files in a location in your MATLAB path.
1
Although it is likely that most things work fine in MATLAB 5, this is not supported due to limited testing resources.
MATPOWER 3.0 required MATLAB 5 and MATPOWER 2.0 and earlier required only MATLAB 4.
4
MATPOWER User’s Manual Version 3.2
Runs an optimal power flow and optionally returns the solved values in
the data matrices, the objective function value, a flag which is true if
the algorithm was successful in finding a solution, and the elapsed time
in seconds. All input arguments are optional. If casename is provided it
specifies the name of the input data file or struct (see also 'help
caseformat' and 'help loadcase') containing the opf data. The default
value is 'case9'. If the mpopt is provided it overrides the default
MATPOWER options vector and can be used to specify the solution
algorithm and output options among other things (see 'help mpoption' for
details). If the 3rd argument is given the pretty printed output will be
appended to the file whose name is given in fname. If solvedcase is
specified the solved case will be written to a case file in MATPOWER
format with the specified name. If solvedcase ends with '.mat' it saves
the case as a MAT-file otherwise it saves it as an M-file.
MATPOWER also has many options which control the algorithms and the output. Type:
>> help mpoption
and see Section 3.6 for more information on MATPOWER's options.
5
MATPOWER User’s Manual Version 3.2
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 re-
turn 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 specifica-
tion of the MATPOWER case file can be found in the help for caseformat.m:
>> help caseformat
6
MATPOWER User’s Manual Version 3.2
7
MATPOWER User’s Manual Version 3.2
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.
3.2 Modeling
AC Formulation
Fixed loads are modeled as constant real and reactive power injections, Pd and Qd specified in col-
umns 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
! !
8
! !
MATPOWER User’s Manual Version 3.2
Gsh + jBsh
Ysh =
baseMVA
Each branch, whether transmission line, transformer or phase shifter, is modeled as a standard π-
model 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 admittance matrix Ybr as follows !
!
! ! ! ! "I %
f
"V f %
$ ' = Ybr $ ' (1)
# It & # Vt &
!
+" Bc % 1 1 .
-$Ys + j ' 2 )Ys 0
(e! 0 and Y = 1 .
j* shift
where Ybr = -# 2 &(
s
- )Ys 1 Ys + j
Bc 0 R + jX
) j*
, (e shift 2 /
The elements of the individual branch admittance matrices and the bus shunt admittances are com-
bined by MATPOWER to form a complex! bus admittance matrix Ybus , relating the vector of complex
! bus voltages Vbus with the vector of complex bus current injections Ibus
! ! I f = Yf Vbus
It = Yt V!bus
The vectors of complex bus power injections, and branch power injections can be expressed as
!
Sbus = diag(Vbus )I*bus
S f = diag(Vf )I*f
St = diag(Vt )I*t
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.
!
! !
9
MATPOWER User’s Manual Version 3.2
DC Formulation
For the DC formulation, the same parameters are used, with the exception that the following assump-
tions are made:
• Branch resistances R and charging capacitances Bc are negligible (i.e. branches are lossless).
• All bus voltage magnitudes are close to 1 p.u.
• Voltage angle differences are small enough that sin " ij # " ij .
!
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 %
$ ' = Bbr $ ' +!$ ' (2)
# Pt & #( t & # Pt,shift &
where
! 1 $ 1 #1'
Bbr = & ) (3)
X" %#1 1 (
The elements of the individual branch shift injections and Bbr matrices are combined by MATPOWER
to form a bus Bbus matrix and P!bus,shift shift injection vector, which can be used to compute bus real
power injections from bus voltage angles
Pbus = B!
bus " bus + Pbus,shift
! !
Similarly, MATPOWER builds the matrix B f and the vector P f,shift which can be used to compute the
vectors Pf and Pt of branch real!power injections
10
MATPOWER User’s Manual Version 3.2
11
MATPOWER User’s Manual Version 3.2
2
See http://www.pserc.cornell.edu/minopf/.
3
See http://www.pserc.cornell.edu/tspopf/.
12
MATPOWER User’s Manual Version 3.2
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 vari-
able is y, then the contribution of the generator’s cost to the total cost is exactly y. In the above case,
the two additional required constraints are
1) y " m1 (Pg # x0 ) + c0 (y must lie above the first segment)
2) y " m2 (Pg # x1 ) + c1 (y must lie above the second segment)
where m1 and m2 are the slopes of the two segments. Also needed, of course, are the box restrictions
! on Pg: Pmin ≤ Pg ≤ 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, with the exception of two that are part of the optional
TSPOPF package, namely the step-controlled primal/dual interior point method (SCPDIPM) and the
trust region based augmented Lagrangian method (TRALM), both of which use a cost smoothing tech-
nique instead.
The AC optimal power flow problem solved by MATPOWER is a “smooth” OPF with no discrete
variables or controls. The generalized AC OPF formulation, used by the current generation of
MATPOWER’s OPF solvers, offers a number of extra capabilities relative to the traditional formula-
tion of minimizing the cost of generation subject to voltage, flow and generator limits, used by the
first generation of MATPOWER OPF solvers:
• mixed polynomial and piecewise linear costs
• dispatchable loads
13
MATPOWER User’s Manual Version 3.2
subject to
!
gP (x) = P(" ,V ) # Pg + Pd = 0 (active power balance equations)
gQ (x) = Q(" ,V ) # Qg + Qd = 0 (reactive power balance equations)
gS f (x) = S f (" ,V ) # Smax $ 0 (apparent power flow limit of lines, from end)
!
! gSt (x) = St (" ,V ) # Smax $ 0 (apparent power flow limit of lines, to end)
# x&
! l " A% ( " u (general linear constraints)
$ z'
!
xmin " x " xmax (voltage and generation variable limits)
zmin " z " zmax (limits on user defined variables)
!
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.
!
The most significant additions to the traditional, simple OPF formulation appear in the generalized
cost terms containing w and in the general linear constraints involving the matrix A, described in the
next two sections. These two frameworks allow tremendous flexibility in customizing the problem
formulation, making MATPOWER even more useful as a research tool.
14
MATPOWER User’s Manual Version 3.2
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 ver-
sions of the Optimization Toolbox.
In addition to the standard non-linear equality constraints for nodal power balance and non-linear ine-
quality constraints for line flow limits, this formulation includes a framework for additional linear
constraints involving the full set of optimization variables.
# x&
l " A% ( " 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 that define generator P-Q capability curves
• rows for constant power factor constraints for dispatchable or price-sensitive loads
• rows for branch angle difference limits
• rows and columns for the helper variables from the CCV implementation of piecewise linear gen-
erator costs and their associated constraints
In addition to these automatically generated constraints, the user can provide a matrix Au and vectors lu
and uu to define further linear constraints. These user supplied constraints could be used, for example,
to restrict voltage angle differences between specific buses. The matrix Au must have at least nx col-
umns where nx is the number of x variables. If Au has more than nx columns, a corresponding z optimi-
zation 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 helper variables for piecewise linear generator costs. This should sim-
plify significantly
! the creation of the desired Au matrix.
The cost function consists of two parts. The first is the polynomial or piecewise linear cost of genera-
tion. A polynomial or piecewise linear cost is specified for each generator’s active output and, option-
ally, 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
variables. The general formulation allows generator costs of mixed type (polynomial and piecewise
linear) in the same problem.
The second 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.
15
MATPOWER User’s Manual Version 3.2
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 ), ri # rˆi < #hi
' i i i i i
wi = & 0, #hi $ ri # rˆi $ hi
'm " f r # rˆ # h , ri # rˆi > hi
( i i( i i i)
where the function fi is a predetermined function selected by the index in di. The current implementa-
tion includes linear and quadratic options.
! " t, di = 1
f i (t ) = # 2
$ t , di = 2
The linear case, where di = 1, is illustrated below, where wi is found by shifting ri by rˆi , applying a
“dead zone” defined by hi and then scaling by mi.
!
!
16
MATPOWER User’s Manual Version 3.2
wi
! mi
rˆi
!
! ri
hi
!
!
The traditional AC OPF formulation models the generator P-Q capability curves as simple box con-
straints defined by the PMIN, PMAX, QMIN and QMAX columns of the gen matrix. In MATPOWER 3.2,
version 2 of the case file format is introduced, which includes 6 new columns in the gen matrix for
specifying additional sloped upper and lower portions of the capability curves. The new columns are
PC1, PC2, QC1MIN, QC1MAX, QC2MIN, and QC2MAX. The feasible region for generator operation with this
more general capability curve is illustrated by the shaded region in the figure below.
17
MATPOWER User’s Manual Version 3.2
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 capa-
bility 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 dispatch-
able load. If a load has a demand curve like the following
18
MATPOWER User’s Manual Version 3.2
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 injec-
tion, 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 general-
ized formulation it is assumed that dispatchable loads maintain a constant power factor. The mecha-
nism 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 impor-
tant 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.
The difference between the voltage angle " f at the from end of branch k and the angle " t at the to end
can be limited by specifying values in the ANGMIN and ANGMAX columns of row k of the branch ma-
trix.
branch(k,
! ANGMIN) " # f $ # t " branch(k, ANGMAX)!
Values are specified in degrees and a value of zero or 360º (-360º) is considered to be unconstrained
for ANGMAX (ANGMIN). The Kuhn-Tucker multipliers on these constraints are returned in the MU_ANGMIN
and MU_ANGMAX columns. These branch! angle difference constraints can be ignored by setting the
OPF_IGNORE_ANG_LIM option to a true value using mpoption.
19
MATPOWER User’s Manual Version 3.2
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 transfor-
mations performed on the input data (bus, gen, branch, areas and gencost tables) before the prob-
lem 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 = find(gen(:,GEN_STATUS) > 0); % find online generators
onbranch = find(branch(:,BR_STATUS) ~= 0); % find online branches
gen = gen(comgen, :);
branch = branch(onbranch, :);
The second step is a renumbering of the bus numbers in the bus table so that the resulting table con-
tains consecutively-numbered buses starting from 1:
[i2e, bus, gen, branch, areas] = ext2int(bus, gen, branch, areas);
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 ta-
bles:
x = [ Theta ; % nb bus voltage angles
V ; % nb bus voltage magnitudes
Pg ; % ng active power injections (p.u.) (ascending bus order)
Qg ]; % ng reactive power injections (p.u.)(ascending bus order)
and the nonlinear constraints have the same order as in the bus, branch tables
g = [ gp; % nb real power flow mismatches (p.u.)
gq; % nb reactive power flow mismatches (p.u.)
gsf; % nl "from" end apparent power injection limits (p.u.)
gst ]; % nl "to" end apparent power injection limits (p.u.)
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 con-
straints (zero RHS) and the limits for gsf, gst are taken from the RATE_A column in the branch table.
20
MATPOWER User’s Manual Version 3.2
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 al-
ready 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 <= 5 degrees
We can set up the problem as follows:
A = sparse([1;1], [2;7], [1;-1], 1, 24);
l = -Inf;
u = 5 * pi/180;
mpopt = mpoption('OPF_ALG', 520); % use fmincon w/generalized formulation
opf('case9', A, l, u, mpopt)
which indeed restricts the angular separation to 5 degrees.
The DC optimal power flow problem solved by MATPOWER is similar to the traditional AC OPF for-
mulation described above, but using the DC model of the network, which only includes bus voltage
angles and real power injections and flows.
min # fi (Pgi )
" ,Pg
i
subject to
Bbus" = Pg # Pd # Pbus,shift # Gsh (active power balance equations)
!
B f " # P max $ Pf ,shift (real power flow limit of lines, from end)
"B f # $ P max + Pf ,shift (real power flow limit of lines, to end)
!
! Pgimin ! Pgi ! Pgimax (active power generation limits)
The voltage
! angle at the reference bus is also constrained to the specified value. Since all constraints
are linear, the problem 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.
21
MATPOWER User’s Manual Version 3.2
22
MATPOWER User’s Manual Version 3.2
• verbose level
• printing of results
opt = mpoption
returns the default options vector
23
MATPOWER User’s Manual Version 3.2
OPF options
11 - OPF_ALG, 0 algorithm to use for OPF
[ 0 - choose best default solver available in the ]
[ following order, 500, 520 then 100/200 ]
[ Otherwise the first digit specifies the problem ]
[ formulation and the second specifies the solver, ]
[ as follows, (see the User's Manual for more details) ]
[ 100 - standard formulation (old), constr ]
[ 120 - standard formulation (old), dense LP ]
[ 140 - standard formulation (old), sparse LP (relaxed) ]
[ 160 - standard formulation (old), sparse LP (full) ]
[ 200 - CCV formulation (old), constr ]
[ 220 - CCV formulation (old), dense LP ]
[ 240 - CCV formulation (old), sparse LP (relaxed) ]
[ 260 - CCV formulation (old), sparse LP (full) ]
[ 500 - generalized formulation, MINOS ]
[ 520 - generalized formulation, fmincon ]
[ 540 - generalized formulation, PDIPM ]
[ primal/dual interior point method ]
[ 545 - generalized formulation (except CCV), SCPDIPM ]
[ step-controlled primal/dual interior point method ]
[ 550 - generalized formulation, TRALM ]
[ trust region based augmented Langrangian method ]
[ See the User's Manual for details on the formulations. ]
12 - OPF_ALG_POLY, 100 default OPF algorithm for use with
polynomial cost functions
(used only if no solver available
for generalized formulation)
13 - OPF_ALG_PWL, 200 default OPF algorithm for use with
piece-wise linear cost functions
(used only if no solver available
for generalized formulation)
14 - OPF_POLY2PWL_PTS, 10 number of evaluation points to use
when converting from polynomial to
piece-wise linear costs
16 - OPF_VIOLATION, 5e-6 constraint violation tolerance
17 - CONSTR_TOL_X, 1e-4 termination tol on x for copf & fmincopf
18 - CONSTR_TOL_F, 1e-4 termination tol on F for copf & fmincopf
19 - CONSTR_MAX_IT, 0 max number of iterations for copf & fmincopf
[ 0 => 2*nb + 150 ]
20 - LPC_TOL_GRAD, 3e-3 termination tolerance on gradient for lpopf
21 - LPC_TOL_X, 1e-4 termination tolerance on x (min step size)
for lpopf
22 - LPC_MAX_IT, 400 maximum number of iterations for lpopf
23 - LPC_MAX_RESTART, 5 maximum number of restarts for lpopf
24 - OPF_FLOW_LIM, 0 qty to limit for branch flow constraints
[ 0 - apparent power flow (limit in MVA) ]
[ 1 - active power flow (limit in MW) ]
[ 2 - current magnitude (limit in MVA at 1 p.u. voltage ]
25 - OPF_IGNORE_ANG_LIM, 0 ignore angle difference limits for branches
even if specified [ 0 or 1 ]
24
MATPOWER User’s Manual Version 3.2
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 ]
25
MATPOWER User’s Manual Version 3.2
MINOPF options
61 - MNS_FEASTOL, 0 (1E-3) primal feasibility tolerance,
set to value of OPF_VIOLATION by default
62 - MNS_ROWTOL, 0 (1E-3) row tolerance
set to value of OPF_VIOLATION by default
63 - MNS_XTOL, 0 (1E-3) x tolerance
set to value of CONSTR_TOL_X by default
64 - MNS_MAJDAMP, 0 (0.5) major damping parameter
65 - MNS_MINDAMP, 0 (2.0) minor damping parameter
66 - MNS_PENALTY_PARM, 0 (1.0) penalty parameter
67 - MNS_MAJOR_IT, 0 (200) major iterations
68 - MNS_MINOR_IT, 0 (2500) minor iterations
69 - MNS_MAX_IT, 0 (2500) iterations limit
70 - MNS_VERBOSITY, -1
[ -1 - controlled by VERBOSE flag (0 or 1 below) ]
[ 0 - print nothing ]
[ 1 - print only termination status message ]
[ 2 - print termination status and screen progress ]
[ 3 - print screen progress, report file (usually fort.9) ]
71 - MNS_CORE, 1200 * nb + 2 * (nb + ng)^2
72 - MNS_SUPBASIC_LIM, 0 (2*nb + 2*ng) superbasics limit
73 - MNS_MULT_PRICE, 0 (30) multiple price
26
MATPOWER User’s Manual Version 3.2
27
MATPOWER User’s Manual Version 3.2
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
programs)
28
MATPOWER User’s Manual Version 3.2
29
MATPOWER User’s Manual Version 3.2
files used only for traditional OPF formulation (constr- and LP-based)
fg_names.m returns names of function and gradient evaluators for given algorithm
fun_ccv.m computes objective function and constraints for CCV formulation
fun_std.m computes objective function and constraints for standard formulation
grad_ccv.m computes gradients of obj fcn & constraints for CCV formulation
grad_std.m computes gradients of obj fcn & constraints for standard formulation
opfsoln.m updates data matrices with OPF solution
files used only for generalized OPF formulation (fmincon- and MINOS-based)
genform.m documentation for generalized OPF formulation
makeAy.m forms A matrix and b vector for generalized OPF formulation
30
MATPOWER User’s Manual Version 3.2
31
MATPOWER User’s Manual Version 3.2
32
MATPOWER User’s Manual Version 3.2
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 Jaco-
bian matrix. Our appreciation to Bruce Wollenberg for all of his suggestions for improvements to ver-
sion 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 to Roman Korab for data for the Polish system. Thanks also to many others who have
contributed code, bug reports and suggestions over the years. Last but not least, we would like to ac-
knowledge the input of Bob Thomas throughout the development of MATPOWER.
5 References
1. R. van Amerongen, “A General-Purpose Version of the Fast Decoupled Loadflow”, IEEE Trans-
actions 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. 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.
4. A. Grace, Optimization Toolbox, The MathWorks, Inc., Natick, MA, 1995.
5. 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.
6. C. Mészáros, “The efficient implementation of interior point methods for linear programming and
their applications”, Ph.D. Thesis, Eötvös Loránd University of Sciences, 1996.
7. B.A Murtagh and M.A. Saunders, “MINOS 5.5 User’s Guide”, Stanford University Systems Opti-
mization Laboratory Technical Report SOL83-20R.
8. B. Stott, “Review of Load-Flow Calculation Methods”, Proceedings of the IEEE, Vol. 62, No. 7,
July 1974, pp. 916-929.
9. B. Stott and O. Alsac, “Fast decoupled load flow”, IEEE Transactions on Power Apparatus and
Systems, Vol. PAS-93, June 1974, pp. 859-869.
10. W. F. Tinney and C. E. Hart, “Power Flow Solution by Newton’s Method”, IEEE Transactions on
Power Apparatus and Systems, Vol. PAS-86, No. 11, Nov. 1967, pp. 1449-1460.
11. H. Wang, C. E. Murillo-Sánchez, R. D. Zimmerman, R. J. Thomas, “On Computational Issues of
Market-Based Optimal Power Flow”, IEEE Transactions on Power Systems, Vol. 22, No. 3,
Aug. 2007, pp. 1185-1193.
12. A. J. Wood and B. F. Wollenberg, “Power Generation, Operation, and Control, 2nd Edition, John
Wiley & Sons, p. 108-111.
33
MATPOWER User’s Manual Version 3.2
34
MATPOWER User’s Manual Version 3.2
Offer blocks must be in non-decreasing order of price and the offer must correspond to a generator
with 0 ≤ PMIN < PMAX. A set of price limits can be specified via the lim struct, e.g. and offer price cap
on real energy would be stored in lim.P.max_offer. Capacity offered above this price is considered
to be withheld from the auction and is not included in the cost function produced. Bids must be in
non-increasing order of price and correspond to a generator with PMIN < PMAX ≤ 0 (see “Dispatchable
loads” on page 18). A lower limit can be set for bids in lim.P.min_bid. See help pricelimits for
more information.
The data specified by a MATPOWER case file, with the gen and gencost matrices modified according
to step 1, are then used to run an OPF. A decommitment mechanism is used to shut down generators if
doing so results in a smaller overall system cost (see Section 3.5 Unit Decommitment Algorithm).
In step 3 the OPF solution is used to determine for each offer/bid block, how much was cleared and at
what price. These values are returned in co and cb, which have the same structure as offers and
bids. The mkt parameter is a struct used to specify a number of things about the market, including the
type of auction to use, type of OPF (AC or DC) to use and the price limits.
There are two basic types of pricing options available through mkt.auction_type, discriminative
pricing and uniform pricing. The various uniform pricing options are best explained in the context of
an unconstrained lossless network. In this context, the allocation is identical to what one would get by
4
See http://www.pserc.cornell.edu/minopf/
5
See http://www.pserc.cornell.edu/powerweb/
35
MATPOWER User’s Manual Version 3.2
creating bid and offer stacks and finding the intersection point. The nodal prices ( "P ) computed by the
OPF and returned in bus(:,LAM_P) are all equal to the price of the marginal block. This is either the
last accepted offer (LAO) or the last accepted bid (LAB), depending which is the marginal block (i.e.
the one that is split by intersection of the offer and bid stacks). There is often a gap between the last
! is acceptable to all buyers
accepted bid and the last accepted offer. Since any price within this range
and sellers, we end up with a number of options for how to set the price, as listed in the table below.
Auction
Name Description
Type
The price of each cleared offer (bid) is equal to the offered (bid)
0 discriminative
price.
1 LAO Uniform price equal to the last accepted offer.
2 FRO Uniform price equal to the first rejected offer.
3 LAB Uniform price equal to the last accepted bid.
4 FRB Uniform price equal to the first rejected bid.
5 first price Uniform price equal to the offer/bid price of marginal unit.
Uniform price equal to min(FRO, LAB) if the marginal unit is an
6 second price
offer, or max(FRB, LAO) if it is a bid.
split-the-
7 Uniform price equal to the average of the LAO and LAB.
difference
8 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 loca-
tion 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 ap-
plied to the adjusted!offers and bids to get the appropriate uniform price at the reference bus. This uni-
form price is then adjusted for location by subtracting the locational adjustment. The appropriate loca-
!
tionally adjusted uniform 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 pro-
cedures can be less than the original offer price, such as when a generator is dispatched at its mini-
mum 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.
36
MATPOWER User’s Manual Version 3.2
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 dispatch-
able 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 dis-
patched, 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
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;
37
MATPOWER User’s Manual Version 3.2
offers.P.prc = [ ...
20 50 60;
20 40 70;
20 42 80;
20 44 90;
20 46 75;
20 48 60 ];
bids.P.qty = [ ...
10 10 10;
10 10 10;
10 10 10 ];
bids.P.prc = [ ...
100 70 60;
100 50 20;
100 60 50 ];
[mpc_out, co, cb, f, dispatch, success, et] = runmarket(mpc, offers, bids, mkt);
>> co.P.qty
ans =
12.0000 23.3156 0
12.0000 24.0000 0
12.0000 24.0000 0
12.0000 24.0000 0
12.0000 24.0000 0
12.0000 24.0000 0
>> co.P.prc
ans =
>> cb.P.qty
38
MATPOWER User’s Manual Version 3.2
ans =
>> cb.P.prc
ans =
39
MATPOWER User’s Manual Version 3.2
1 35.3 $50.00
2 36 $50.24
3 36 $50.34
4 36 $51.02
5 36 $52.17
6 36 $52.98
1 30.0 $51.82
2 10.0 $54.03
3 20.0 $55.62
40