MATPOWER - A MATLAB Power System Simulation Package
MATPOWER - A MATLAB Power System Simulation Package
Version 3.0.0
February 14, 2005
Users Manual
Table of Contents
Table of Contents...................................................................................................................................2
1 Introduction................................................................................................................................3
5 References..................................................................................................................................29
2
MATPOWER Users Manual Version 3.0.0
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 under-
stand 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-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 computa-
tional requirements of the PowerWeb project (see http://www.pserc.cornell.edu/powerweb/).
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/).
1
MATPOWER 2.0 and earlier required only version 4 of Matlab.
3
MATPOWER Users Manual Version 3.0.0
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.
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.
4
MATPOWER Users Manual Version 3.0.0
MATPOWER also has many options which control the algorithms and the output. Type:
>> helpmpoption
and see Section 3.6 for more information on MATPOWER's options.
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:
5
MATPOWER Users Manual Version 3.0.0
6
MATPOWER Users Manual Version 3.0.0
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
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, respec-
tively. 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
e and Y = 1 .
j shift
where Ybr = 2
s
Ys 1 B
Ys + j c
R + jX
j
e shift 2
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 volt-
ages Vbus with the vector of complex bus current injections Ibus
Ibus = Ybus Vbus
7
MATPOWER Users Manual Version 3.0.0
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 the bus voltages Vbus .
I f = Yf Vbus
It = Yt Vbus
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.
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).
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
Pf ,shift shift 1
= . (4)
Pt,shift X 1
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
8
MATPOWER Users Manual Version 3.0.0
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
9
MATPOWER Users Manual Version 3.0.0
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
MATPOWER Users Manual Version 3.0.0
based 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 im-
posed by the compressed-column sparse format which is employed by MINOS. In fact, the new general-
ized formulation introduced in this version of MATPOWER is inspired by the data format used by
MINOS.
MATPOWERs OPF implementation is not able to handle de-energized sections of the network.
The AC optimal power flow problem solved by MATPOWER is a smooth OPF with no discrete vari-
ables 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 for-
mulated as follows:
min
,V ,Pg ,Qg
f 1i (Pgi ) + f2i (Qgi )
i
subject to
Pi ( ,V ) Pgi + Pdi = 0 (active power balance equations)
Qi ( ,V ) Qgi + Qdi = 0 (reactive power balance equations)
The first of the two original OPF solvers in MATPOWER is based on the constr non-linear constrained
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 con-
straint 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 func-
tions 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 lin-
ear functions which make up the piecewise-linear cost function. Clearly, this method works only for con-
vex cost functions. In the MATPOWER documentation this will be referred to as a constrained cost vari-
able (CCV) formulation.
The algorithm codes 100 and 200, respectively, are used to identify the constr-based solver for polyno-
mial 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 polyno-
mial 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.
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 soft-
ware.
The LP-based methods in MATPOWER use the same problem formulation as the constr-based meth-
ods, 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 vari-
able x as follows:
min f (x 2 )
x
subject to
g1 (x 1 ,x 2 ) = 0 (equality constraints)
g2 (x 1 , x2 ) 0 (inequality constraints)
where x1 contains the system voltage magnitudes and angles, and x2 contains the generator real and reac-
tive power outputs (and corresponding cost variables for the CCV formulation). This is a general non-
linear 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.
12
MATPOWER Users Manual Version 3.0.0
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 .
Step 2: Linearize the problem around xk, solve the resulting LP for x.
f
min x
x x
x=xk
subject to
g k
x g( x )
x x = x
k
x
Step 3: Set k k + 1, update current solution x k = x k 1 + x .
Step 4: If xk meets termination criteria, stop, otherwise go to step 5.
Step 5: Adjust step size limit based on the trust region algorithm in [3], go to step 1.
The termination criteria is outlined below:
L f g
= + T tolerance1
x x x
g(x) tolerance2
x tolerance3
Here is the vector of Lagrange multipliers of the LP problem. The first condition pertains to the size of
the gradient, the second to the violation of constraints, and the third to the step size. More detail can be
found in [4].
Quite frequently, the value of xk given by step 1 is infeasible and could result in an infeasible LP problem.
In such cases, a slack variable is added for each violated constraint. These slack variables must be zero at
the optimal solution.
The LPconstr function implements the following three methods:
sparse formulation with full set of inequality constraints
sparse formulation with relaxed constraints (ICS, Iterative Constraint Search)
dense formulation with relaxed constraints (ICS) [11]
These three methods are specified using algorithm codes 160, 140, and 120, respectively, for systems
with polynomial costs, and 260, 240, and 220, respectively, for systems with piecewise-linear costs. As
with the constr-based method, selecting one of the 2xx algorithms for a system with polynomial cost will
cause the cost to be replaced by a piecewise-linear approximation.
In the dense formulation, some of the variables x1 and the equality constraints g1 are eliminated from the
problem before posing the LP sub-problem. This procedure is outlined below. Suppose the LP sub-
problem is given by:
13
MATPOWER Users Manual Version 3.0.0
min c T x
subject to
A x b
x
If this is rewritten as:
subject to
A11 x1 + A12 x 2 = b1
A21 A111 (b1 A12 x2 ) + A22 x 2 b2
1 A111 (b1 A12x2 ) 1
2 x2 2
This new LP problem is smaller than the original, but it is no longer sparse.
As mentioned above, to realize the full potential of the LP-based OPF solvers, it will be necessary to ob-
tain a good LP-solver, such as bpmpd. See Appendix A for more details.
14
MATPOWER Users Manual Version 3.0.0
The generalized AC OPF formulation used by the fmincon and MINOPF solvers can be written as fol-
lows:
x
min ( f1i (Pgi ) + f2i (Qgi )) + c y
x,y,z
i
z
subject to
To add general linear constraints of ones own, it is necessary to understand the standard transformations
performed on the input data (bus, gen, branch, areas and gencost tables) before the problem is solved
in order to know where the optimization variables end up in the x vector. All of these transformations are
reversed after solving the problem so that output data is in the right place in the tables.
15
MATPOWER Users Manual Version 3.0.0
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 contains
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 tables:
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 constraints (zero RHS)
and the limits for gsf, gst are taken from the RATE_A column in the branch table.
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 ac-
tive 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 ap-
16
MATPOWER Users Manual Version 3.0.0
pear 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 with generalized formulation
opf('case9', A, l, u, mpopt)
which indeed restricts the angular separation to 5 degrees. NOTE: In this example, the total number of
variables is 24, but if there are any piecewise linear cost functions, there may be additional helper vari-
ables used by the solver and in that case the number of columns in A may need to be larger. The next
section describes how this is done. If all costs are polynomial, however, no extra variables are needed.
The generalized formulation allows for an easy way to model any piecewise linear costs. Such a cost
curve looks like
This non-differentiable cost can be modeled using one helper cost variable for each such cost curve and
additional restrictions on this variable and Pg, one restriction for each segment of the curve. The restric-
tions build a convex basin and they are equivalent to saying that the cost variable must lie in the epi-
graph 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, and
in the above case the two restrictions needed 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 :PminPg Pmax. The additive part of the cost contributed by this generator is y.
In the generalized OPF formulation, the capability to accept general linear constraints is used to introduce
new y variables (one for each piecewise linear cost in the problem) and constraints (one for each cost
segment in the problem). The function that builds the coefficient matrix for the restrictions is makeAy.
17
MATPOWER Users Manual Version 3.0.0
Because a linear cost on the y variables is also required, the last row of the matrix that is passed to the
solver is expected to contain not some linear restriction coefficients but a linear cost vector on [x;y]. In
normal use this is done automatically inside fmincopf (or mopf when using MINOPF) and the user need
not worry about this. To incorporate additional linear constraints, however, it is necessary to know in ad-
vance how many y variables there are so that the coefficient matrix for the users constraints have a
matching number of columns to multiply [x;y]. The number of y variables is equal to the number of
piecewise linear cost curves (both active and reactive) there are for the generators that are online.
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
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 de-
sired 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 re-
18
MATPOWER Users Manual Version 3.0.0
jecting 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 lim-
its for the negative generator in question are not set to zero, then the algorithm will dispatch the reac-
tive injection to the most convenient value. Since this is not normal load behavior, in the generalized for-
mulation 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 ap-
propriately, 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 col-
umns of the gen matrix must be consistent with the ratio defined by PMIN and the appropriate Q limit.
The advanced user may want to incorporate additional linear constraints and/or linear costs to the prob-
lem. Sometimes new state variables may need to be defined (in addition to x and y discussed above). And,
sometimes the user may also want to include additional linear costs on some or all of the variables, but in
most cases fmincopf (or mopf) hide these steps from the user and create certain costs and restrictions
automatically. This creates a conflict between ease of use and generality of the software. In this section
we explain the behavior adopted by fmincopf and mopf when the following factors interact:
a) existence of y variables because of piecewise linear costs
b) user-provided linear restrictions
b1) on whatever the existing variables [x;y] are;
b2) with A having more columns than there are elements in [x;y], thus creating extra variables z
and an overall optimization vector [x;y;z].
If the user does not provide any additional linear restrictions via the A, l, u parameters, then internally
there are only x and y-type variables; if there are y-type variables for modeling piecewise linear costs, then
some additional constraints will be constructed to model the cost segments. If there are dispatchable
loads (with either polynomial or piecewise linear costs) then additional constraints will be included to
maintain a constant power factor.
If a user does provide A, l, u parameters to add general linear constraints, then
a) if the number of columns in A is the same as the number of variables in [x;y], then any linear cost
vector needed for modeling of the piecewise linear costs is constructed automatically and the user
is not expected to provide a cost row in A.
b) if the number of columns in A is greater than the number of elements in [x;y], then the user is re-
sponsible to provide
b1) the appropriate linear restrictions on y and the Pg , Qg sections of the x vector to model each
of the segments of the piecewise linear costs as described previously; this includes both the
coefficient matrix and the left and right hand sides of the restrictions. The function makeAy
can be used for this, but keep in mind that it will return a coefficient matrix that has only as
many columns as elements in [x;y]. It must be padded with enough sparse zero columns on
the right to make it conformable with [x;y;z] if there are any z variables.
b2) the appropriate linear cost in the last row of A and this includes any necessary cost coeffi-
cients on the y section of the cost vector. Note that l and u must still have the same num-
ber of elements as A has rows but the last elements in l and u are meaningless; set them to
(large, +large).
19
MATPOWER Users Manual Version 3.0.0
Note that this implies that in order to add linear costs on just the [x;y] variables, at least one dummy z
variable must be created for the interface to provide the user with the opportunity to specify the linear cost
vector.
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 an-
gles 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)
20
MATPOWER Users Manual Version 3.0.0
opt = mpoption
returns the default options vector
21
MATPOWER Users Manual Version 3.0.0
22
MATPOWER Users Manual Version 3.0.0
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 ]
23
MATPOWER Users Manual Version 3.0.0
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 + 5000
72 - MNS_SUPBASIC_LIM, 0 (2*ng) superbasics limit
73 - MNS_MULT_PRICE, 0 (30) multiple price
24
MATPOWER Users Manual Version 3.0.0
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)
25
MATPOWER Users Manual Version 3.0.0
26
MATPOWER Users Manual Version 3.0.0
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
27
MATPOWER Users Manual Version 3.0.0
28
MATPOWER Users Manual Version 3.0.0
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 Transac-
tions 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 Re-
scheduling, 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 Opti-
mization Laboratory Technical Report SOL83-20R.
29
MATPOWER Users Manual Version 3.0.0
30
MATPOWER Users Manual Version 3.0.0
2
See http://www.pserc.cornell.edu/minopf/
3
See http://www.pserc.cornell.edu/powerweb/
31
MATPOWER Users Manual Version 3.0.0
Generalizing to a network with possible losses and congestion results in nodal prices P which vary ac-
cording 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.
adjusted for location by subtracting the locational adjustment. The appropriate locationally adjusted uni-
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 proce-
dures 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 max_p. 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 max_p. Likewise, cleared bid prices are
less than or equal to both the bid price and max_p.
Initial implementations of the auction software did not include dispatchable or price-sensitive loads, so it
only handled single-sided auctions. In an attempt to handle situations where the offered capacity was in-
sufficient to meet the demand under all of the other constraints, resulting in an infeasible OPF, imports
were introduced. These were simply generators with GEN_STATUS set to 1. If the auction software failed
to find an OPF solution, it would turn on these generators with costs set to $5/MWh above the highest
offer and retry.
This feature still exists but we no longer use it. Instead, for single-sided markets we model an import as a
fixed injection together with an equal sized dispatchable load which is bid in at a high price. Under nor-
mal 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.
32
MATPOWER Users Manual Version 3.0.0
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 a
market code of 1110 and set up the problem as follows:
q = [ 12 24 24;
12 24 24;
12 24 24;
12 24 24;
12 24 24;
12 24 24;
10 10 10;
10 10 10;
10 10 10 ];
33
MATPOWER Users Manual Version 3.0.0
p = [ 20 50 60;
20 40 70;
20 42 80;
20 44 90;
20 46 75;
20 48 60;
100 70 60;
100 50 20;
100 60 50 ];
mpopt = mpoption;
[baseMVA, cq, cp, bus, gen, gencost, branch, f, dispatch, success, et] = ...
runmkt('my_case', q, p, 1110, [], [], [], mpopt);
>> cq
cq =
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
10.0000 10.0000 10.0000
10.0000 0 0
10.0000 10.0000 0
>> cp
cp =
34
MATPOWER Users Manual Version 3.0.0
35