Академический Документы
Профессиональный Документы
Культура Документы
Abstract—This paper describes the optimal power flow (OPF) Even beyond its initial release, while some unrelated new
architecture implemented in M ATPOWER, an open-source Mat- features were added, the ongoing development of M ATPOWER
lab power system simulation package. It utilizes an extensible continued to be driven primarily by the needs of the PowerWeb
architecture that allows the user to easily add new variables,
constraints and costs to the standard OPF problem formulation project. This at least partially explains the lack of a graphical
while preserving the structure needed to use pre-compiled solvers. user interface used by some related tools such as PSAT [4].
A software object is used to encapsulate the definition of the As new OPF solvers were evaluated for improving M AT-
problem formulation, manage the corresponding named sets of POWER’s OPF performance, it became clear that MEX-based
variables, constraints and costs, and handle all of the tedious
approaches, using Matlab extensions implemented in compiled
index maintenance tasks. The software design has the advantage
of minimizing the coupling between variables, constraints and languages such as C or Fortran, offered the potential for
costs, making it possible, for example, to add variables to significant performance advantages. On the other hand, the
an existing model without having to explicitly modify existing frequent need to run a variation of the OPF with modifications
constraints or costs to accommodate them. The example of adding and additions to the standard problem formulation would
joint co-optimization of reserves to the OPF, based on fixed
mean recompiling a new version of any MEX-based solver
zonal reserve requirements, is used to illustrate the capabilities
of M ATPOWER’s extensible OPF architecture. and modifying significant portions of Matlab code for each
variation. The result was an effort to develop a general OPF
Index Terms—Load flow analysis, Optimization methods,
architecture that allows modification of the formulation via
Power engineering, Power engineering education, Power gener-
ation dispatch, Power systems, Power system economics, Power optional input data instead of requiring extensive changes to
system simulation, Software packages, Software tools the existing code.
This paper highlights M ATPOWER’s extensible OPF archi-
tecture, designed to allow the user to easily add new variables,
I. I NTRODUCTION
constraints and costs to the standard OPF problem formulation
HIS paper describes the optimal power flow (OPF) archi-
T tecture implemented in M ATPOWER [1], an open-source
Matlab power system simulation package. It is used widely in
while retaining the ability to utilize pre-compiled solvers.
The next section describes the AC and DC versions of the
standard OPF formulation as implemented in M ATPOWER.
research and education for power flow and optimal power flow The extensions to this formulation that form the basis for the
simulation. It also includes tools for calculating power transfer extensible OPF architecture are detailed in Section III, with
and line outage distribution factors (PTDF’s and LODF’s) and examples of how these capabilities are used internally shown
for running OPF-based auction markets. in Section IV. Section V covers the currently available OPF
The initial motivation for the development of the Matlab- solvers, Section VI describes the software architecture and
based power flow and optimal power flow code that eventually Section VII illustrates the use of this extensible architecture
became M ATPOWER came from the computational require- to implement an OPF that jointly optimizes the allocation of
ments of the PowerWeb platform [2], [3]. PowerWeb is a energy and reserves.
web-based market simulation platform used to test electricity
markets. It requires a “smart market” auction clearing software
that uses an optimal power flow to compute the allocations II. S TANDARD O PTIMAL P OWER F LOW
and pricing. Having the clear potential to be useful to other
M ATPOWER includes code to solve both AC and DC
researchers and educators, the software was released via the
versions of the optimal power flow problem. The standard
Internet as an open-source power system simulation package.
version of each takes the following form.
This work was supported in part by the Consortium for Electric Reliability
Technology Solutions and the Office of Electricity Delivery and Energy min f (x) (1)
Reliability, Transmission Reliability Program of the U.S. Department of x
Energy under Contract No. DE-AC02-05CH11231.
R. D. Zimmerman and R. J. Thomas are with the School of Electrical and subject to
Computer Engineering, Cornell University, Ithaca, NY, 14853 USA (e-mail:
rz10@cornell.edu, rjt1@cornell.edu).
C. E. Murillo-Sánchez is with Universidad Autónoma de Manizales, and
g(x) = 0 (2)
with Universidad Nacional de Colombia, both in Manizales, Colombia (e-mail: h(x) ≤ 0 (3)
carlos murillo@ieee.org).
Manuscript received December 3, 2008; revised February 12, 2009. xmin ≤ x ≤ xmax (4)
2
A. Standard AC OPF and the overall problem reduces to the following form.
The AC version of the standard OPF problem is a general
ng
non-linear constrained optimization problem, with both non- min fPi (pi ) (16)
Θ,P
linear costs and constraints. In a system with nb buses, ng i=1
generators and nl branches, the optimization variable x is subject to
pmin
i ≤ pi ≤ pmax
i , i = 1 . . . ng (13) subject to
qimin ≤ qi ≤ max
qi , i = 1 . . . ng (14) g(x) = 0 (23)
Here iref denotes the index of the reference bus and θref is h(x) ≤ 0 (24)
the reference angle. xmin ≤ x ≤ xmax (25)
x
l≤A ≤u (26)
B. Standard DC OPF z
When using DC network modeling assumptions, the stan- zmin ≤ z ≤ zmax (27)
dard OPF problem above can be simplified to a quadratic
program, with linear constraints and a quadratic cost function.
A. User-defined Costs
In this case, the voltage magnitudes and reactive powers are
eliminated from the problem completely and real power flows The user-defined cost function fu is specified in terms of
are modeled as linear functions of the voltage angles. The parameters H, C, N , r̂, k, d and m. All of the parameters are
optimization variable is nw × 1 vectors except the symmetric nw × nw matrix H and
the nw × (nx + nz ) matrix N . The cost takes the form
Θ
x= (15) 1 T
P fu (x, z) = w Hw + C T w (28)
2
3
wi wi
mi
r̂i
r̂i
ri ri
ki ki ki ki
B. User-defined Constraints
The user-defined constraints (26) are general linear re-
Fig. 1. Relationship of wi to ri for di = 1 (linear option) strictions involving all of the optimization variables and are
specified via matrix A and lower and upper bound vectors
l and u. These parameters can be used to create equality
where w is defined in several steps as follows. First, a new constraints (li = ui ) or inequality constraints that are bounded
vector u is created by applying a linear transformation N and below (ui = ∞), bounded above (li = ∞) or bounded on both
shift r̂ to the full set of optimization variables sides.
x
r=N , (29)
z C. User-defined Variables
u = r − r̂, (30) The creation of additional user-defined z variables is done
implicitly based on the difference between the number of
then a scaled function with a “dead zone” is applied to each columns in A and the dimension of x. The optional vectors
element of u to produce the corresponding element of w. zmin and zmax are available to impose lower and upper bounds
⎧ on z, respectively.
⎨ mi fdi (ui + ki ),
⎪ ui < −ki
wi = 0, −ki ≤ ui ≤ ki (31)
⎪
⎩ IV. S TANDARD E XTENSIONS
mi fdi (ui − ki ), ui > ki
In addition to making this extensible OPF structure available
Here ki specifies the size of the “dead zone”, mi is a simple to end users, M ATPOWER also takes advantage of it internally
scale factor and fdi is a pre-defined scalar function selected to implement several additional capabilities.
by the value of di . Currently, M ATPOWER implements only
linear and quadratic options
A. Piecewise Linear Costs
α, if di = 1 The standard OPF formulation in (1)-(4) does not directly
fdi (α) = (32)
α2 , if di = 2 handle the non-smooth piecewise linear cost functions that
typically arise from discrete bids and offers in electricity
as illustrated in Fig. 1 and Fig. 2, respectively.
markets. When such cost functions are convex, however, they
This form for fu provides the flexibility to handle a wide
can be modeled using a constrained cost variable (CCV)
range of costs, from simple linear functions of the optimization
method. The piecewise linear cost function c(x) is replaced
variables to scaled quadratic penalties on quantities, such as
by a helper variable y and a set of linear constraints that form
voltages, lying outside a desired range, to functions of linear
a convex “basin” requiring the cost variable y to lie in the
combinations of variables, inspired by the requirements of
epigraph of the function c(x).
price coordination terms found in the decomposition of large
Fig. 3 illustrates a convex n-segment piecewise linear cost
loosely coupled problems encountered in our own research.
function
Some limitations are imposed on the parameters in the case ⎧
of the DC OPF since M ATPOWER uses a generic quadratic ⎪ m1 (x − x1 ) + c1 , x ≤ x1
⎪
⎪
programming (QP) solver for the optimization. In particular, ⎪
⎨ m2 (x − x2 ) + c2 , x1 < x ≤ x2
ki = 0 and di = 1 for all i, so the “dead zone” is not c(x) = .. .. (33)
⎪
⎪ . .
considered and only the linear option is available for fdi . As ⎪
⎪
⎩
a result, for the DC case (31) simplifies to wi = mi ui . mn (x − xn ) + cn , xn−1 < x
4
c $/MW
cn λ (marginal benefit)
λ1
y
p1
c2
λ2
c1 p2
c0
x
x0 x1 x2 xn MW
p (load)
Fig. 3. Constrained Cost Variable
TABLE I
VARIABLE S ETS
q
name description
q1max
Va bus voltage angles
Vm bus voltage magnitudesa
Pg generator real power injection
qmax Qg generator reactive power injectiona
y CCV helper variables for piecewise linear cost
a AC formulation only
q2max
The former is based on MINOS [11] and the latter includes
p the primal-dual interior point methods and a trust region based
augmented Lagrangian method described in [6].
q2min
VI. S OFTWARE A RCHITECTURE
Building up the matrices and vectors needed to add vari-
qmin ables, costs and constraints to the OPF problem can involve
a lot of messy indexing code with offsets that depend on
the dimensions of the various portions of the optimization
q1min vector, existing constraints, etc. In order to ease this process
p1 pmin pmax p2 as much as possible, M ATPOWER utilizes an objected-oriented
approach to set up and modify the problem formulation. An
“OPF-model” (OM) object is constructed to encapsulate the
Fig. 6. Generator P -Q Capability Curve data defining the problem. This object maintains all of the
relevant indexing information for named blocks of variables,
constraints and costs as they are added.
the maximum real output and the maximum (or minimum)
reactive output simultaneously. To approximate this tradeoff,
A. Variables
M ATPOWER includes the ability to add an upper and lower
sloped portion to the standard box constraints as illustrated Adding a block of elements to the optimization vector is
in Fig. 6, where the shaded portion represents the feasible done via the OM object’s add_vars method, providing a
operating region for the unit. name for the block, the number of elements and optional
The two sloped portions are constructed from the lines vectors of initial values and variable bounds. For example, the
passing through the two pairs of points defined by the six following code can be used to define a portion of the optimiza-
parameters p1 , q1min , q1max , p2 , q2min , and q2max . If these six tion vector to represent generator real power injections where
parameters are specified for a given generator, M ATPOWER ng is the number of generators and Pg, Pmin, and Pmax are
automatically constructs the corresponding additional linear vectors of initial values, lower and upper bounds, respectively.
inequality constraints on p and q for that unit. om = add_vars(om, ’Pg’, ng, Pg, Pmin, Pmax);
The name Pg can then be used for direct access to this portion
of the optimization variable or the corresponding shadow
D. Branch Angle Difference Limits
prices on variable bounds without having to keep track of the
The difference between the bus voltage angle θf at the from indexing explicitly.
end of a branch and the angle θt at the to end can be bounded M ATPOWER uses this method internally to set up the various
above and below to act as a proxy for a transient stability limit, components of the standard optimization vector x as well
for example. If these limits are provided, M ATPOWER creates as the portions of the additional variables z defined by the
the corresponding constraints on the voltage angle variables. standard extensions from Section IV. Specifically, this includes
the CCV helper variables y needed for any piecewise linear
V. S OLVERS generator costs. These blocks are summarized in TABLE I.
The default OPF solvers included with the M ATPOWER dis-
tribution, based on Matlab’s Optimization Toolbox [7], work B. Constraints
reasonably well for very small systems. For larger networks, Similarly, the constraints are constructed by adding named
there are a number of additional solvers available that are blocks to the OM object with the add_constraints method.
distributed separately as optional packages due to differences The standard non-linear constraints simply supply a name
in terms of use. and the number of constraints. Linear constraints additionally
For DC optimal power flow, there is a MEX build [8] of require the matrix A and lower and upper bound vectors l and
the high performance BPMPD solver [9] for LP/QP problems. u that define the constraint as in (26), along with an optional
For the AC OPF problem, the MINOPF [10] and TSPOPF [5] ordered list of names of the variable blocks covered by the
packages provide solvers suitable for much larger systems. columns of the A matrix.
6
relative to the dimension of x. This problem clearly fits the form of the extensible OPF
The second, and recommended, method involves using the formulation in (22)-(27). Consider the slightly simplified case
add_vars, add_constraints and add_costs methods to where all ng generators are available to provide reserves.
modify the problem. After M ATPOWER constructs the OM Using the variables described in TABLE III, the standard OPF
7
problem formulation can be modified to include fixed reserve [8] BPMPD MEX: [Online]. Available: http://www.pserc.cornell.edu/
requirements with a few simple lines of code in a callback bpmpd/
[9] C. Mészáros, “The efficient implementation of interior point methods for
function. linear programming and their applications,” Ph.D. dissertation, Eötvös
Ar = [I I]; Loránd University of Sciences, 1996.
om = add_vars(om, ’R’, ng, [], Rmin, Rmax); [10] MINOPF: [Online]. Available: http://www.pserc.cornell.edu/minopf/
om = add_constraints(om, ’Pg_plus_R’, ... [11] B. A. Murtagh and M. A. Saunders, MINOS 5.5 User’s Guide, Stanford
Ar, [], Pmax, {’Pg’, ’R’}); University Systems Optimization Laboratory Technical Report SOL83-
om = add_constraints(om, ’Rreq’, ... 20R.
[12] J. Chen, J. Thorp, and T. Mount, “Coordinated interchange scheduling
Az, Rreq, [], {’R’});
and opportunity cost payment: a market proposal to seams issues,”
om = add_costs(om, ’Rcost’, ... System Sciences, 2004. Proceedings of the 37th Annual Hawaii Inter-
struct(’N’,I,’Cw’,Rcost), {’R’}); national Conference on, Jan. 2004.
As an example of how to take advantage of its extensible [13] J. Chen, T. D. Mount, J. S. Thorp, and R. J. Thomas, “Location-based
scheduling and pricing for energy and reserves: a responsive reserve
OPF capabilities, M ATPOWER includes a more complete im- market proposal,” Decis. Support Syst., vol. 40, no. 3-4, pp. 563–577,
plementation of this problem that takes into account off-line 2005.
and non-reserve generators. Several more complex applica- [14] R. Thomas, C. Murillo-Sánchez, and R. Zimmerman, “An advanced
security constrained opf that produces correct market-based pricing,”
tions utilizing this extensibility can also be found in [12]–[14]. Power and Energy Society General Meeting - Conversion and Delivery
of Electrical Energy in the 21st Century, 2008 IEEE, pp. 1–6, July 2008.
VIII. C ONCLUSION
In power systems research and education, a flexible simula-
tion tool for power flow and optimal power flow is a valuable,
and often essential, tool. Especially in research, it is frequently Ray Daniel Zimmerman is a senior research asso-
necessary to explore modified versions of the standard problem ciate in electrical engineering and applied economics
and management at Cornell University. He is the
formulations. Unfortunately, such modifications often require lead developer of the PowerWeb electricity market
significant effort in custom coding. simulation platform and the M ATPOWER power sys-
M ATPOWER is an open-source package of Matlab tools tem simulation software. His current research inter-
ests center on the interactions between the economic
for electric power system simulation that attempts to address and engineering aspects of electric power system
this need by providing an extensible architecture for optimal operations and planning. Other interests include soft-
power flow problems, allowing the user to easily modify and ware tools for education and research.
augment the problem formulation with additional variables,
constraints and costs. Since this customization is done via
optional input parameters, it is still possible to take advan-
tage of the performance benefits of pre-compiled solvers.
Carlos Edmundo Murillo-Sánchez (Ph.D. elec-
The object-oriented software architecture facilitates a modular trical engr. Cornell ’99, M.Sc. electrical engr.
definition of the problem, allowing additions to be made at UW-Madison ’91, electronics engineering ITESM,
various stages, with the final constraint and cost parameters México, ’87) is Professor and Dean of Engineering
at Universidad Autónoma de Manizales, and Profes-
constructed automatically just before calling the solver. sor at Universidad Nacional de Colombia in Man-
An enhanced optimal power flow formulation that jointly izales, Colombia. He is a founding member of the
co-optimizes energy and reserves is used to illustrate the Colombian Automation Society (Asociación Colom-
biana de Automática). His interests include power
capabilities of M ATPOWER’s extensible architecture. It uses systems operation and control, control systems appli-
the standard OPF formulation with an additional fixed zonal cations, optimization, simulation and mechatronics.
reserve requirement.
R EFERENCES
[1] R. D. Zimmerman and C. Murillo-Sánchez. M ATPOWER User’s Manual, Robert John Thomas currently holds the position
[Online]. Available: http://www.pserc.cornell.edu/matpower/ of Professor of Electrical Engineering at Cornell
[2] R. D. Zimmerman, R. J. Thomas, D. Gan, and C. Murillo-Sánchez, University. He has held sabbatical positions with
“A web-based platform for experimental investigation of electric power the U.S. Department of Energy Office of Electric
auctions,” Decision Support Systems, vol. 24, no. 3-4, pp. 193–205, Energy Systems (EES) in Washington, D.C. and at
1999. the National Science Foundation as the first Pro-
[3] R. D. Zimmerman and R. J. Thomas, “PowerWeb: a tool for evaluating gram Director for the Power Systems Program in
economic and reliability impacts of electric power market designs,” the Engineering Directorate’s Division of Electrical
Power Systems Conference and Exposition, 2004. IEEE PES, pp. 1562– Systems Engineering. He has been a consultant to
1567 vol.3, October 10-13 2004. several entities on various electric utility system
[4] F. Milano, “An open source power system analysis toolbox,” Power related issues. He has authored over 90 technical
Systems, IEEE Transactions on, vol. 20, no. 3, pp. 1199–1206, Aug. papers. He has been a member of the IEEE United States Activity Board’s
2005. Energy Policy Committee since 1991. He is a member of the IEEE Technology
[5] TSPOPF: [Online]. Available: http://www.pserc.cornell.edu/tspopf/ Policy Council and has been a member of several university, government and
[6] H. Wang, C. E. Murillo-Sánchez, R. D. Zimmerman, and R. J. Thomas, industry advisory Boards or Panels. His current technical research interests
“On computational issues of market-based optimal power flow,” Power are broadly in the areas of analysis and control of nonlinear continuous and
Systems, IEEE Transactions on, vol. 22, no. 3, pp. 1185–1193, August discrete time systems with applications to large-scale electric power systems.
2007. He is a member of Tau Beta Pi, Eta Kappa Nu, Sigma Xi, ASEE and a Fellow
[7] Optimization Toolbox 4 Users’s Guide. The MathWorks, Inc., 2008. of the IEEE. He has been the Director of the National Science Foundation
[Online]. Available: http://www.mathworks.com/access/helpdesk/help/ Industry/University Cooperative Research Center, PSERC, a Center focused
pdf doc/optim/optim tb.pdf on problems of restructuring of the electric power industry.