6.1 Standard AC OPF

The optimization vector x  for the standard AC OPF problem consists of the nb × 1  vectors of voltage angles Θ  and magnitudes Vm  and the ng × 1  vectors of generator real and reactive power injections Pg  and Qg  .

    ⌊     ⌋
    |  Vm |
x = |⌈  P  |⌉

The objective function f(x )  in (6.1) is simply a summation of individual polynomial cost functions  i
fP  and  i
fQ  of real and reactive power injections, respectively, for each generator:

            ∑ g  i  i     i  i
f(Pg, Qg) =     fP(pg) + fQ(qg).

The equality constraints in (6.2) are simply the full set of 2 ⋅ n
     b  nonlinear real and reactive power balance equations from (4.2) and (4.3).


The inequality constraints (6.3) consist of two sets of nl  branch flow limits as nonlinear functions of the bus voltage angles and magnitudes, one for the from end and one for the to end of each branch:


The flows are typically apparent power flows expressed in MVA, but can be real power flows (in MW) or currents,31 yielding the following three possible forms for the flow constraints:

             |{ Sf (Θ,Vm ),  apparent power
F  (Θ,V  ) =   P  (Θ,V  ),  real power
  f     m    |(   f     m
                If(Θ,Vm ),  current

where If  is defined in (3.9), Sf  in (3.15), Pf  = ℜ {Sf} and the vector of flow limits Fmax   has the appropriate units for the type of constraint. It is likewise for Ft (Θ, Vm )  . The values used by Matpower’s OPF for the flow limits Fmax   are specified in the RATE_A column (6) of the branch matrix,32 and the selection of flow constraint type in (6.11) is determined by the opf.flow_lim option.

The variable limits (6.4) include an equality constraint on any reference bus angle and upper and lower limits on all bus voltage magnitudes and real and reactive generator injections:

    ref         ref
   𝜃i  ≤ 𝜃i ≤ 𝜃i ,      i ∈ ℐref                     (6.12)
vim,min ≤ vim  ≤ vim,max,    i = 1...nb                  (6.13)
  i,min    i    i,max
 pg   ≤  pg ≤ pg   ,    i = 1...ng                  (6.14)
 qi,gmin≤  qig ≤ qi,gmax,    i = 1...ng.                 (6.15)
The voltage reference angle  ref
𝜃i  and voltage magnitude bounds  i,max
vm  and  i,min
vm  are specified in columns VA (9), VMAX (12) and VMIN (13), respectively, of row i  of the bus matrix. Similarly, the generator bounds qgi,max  , qi,gmin  , pig,max  and pig,min  are specfied in columns QMAX (4), QMIN (5), PMAX (9) and PMIN (10), respectively, of row i  of the gen matrix.
6.1.1 Cartesian vs. Polar Coordinates for Voltage

Another variation of the standard AC OPF problem represents the bus voltages in cartesian, rather than polar, coordinates. That is, instead of Θ  and Vm  , the optimization vector x  includes the real and imaginary parts of the complex voltage, denoted respectively by U  and W  , where V  = U + jW  .

    ⌊     ⌋
    ||  W  ||
x = ⌈  Pg ⌉

The objective function remains unchanged, but the nodal power balance constraints (6.7) and (6.8) and branch flow constraints (6.9) and (6.10) are implemented as functions of U  and W  .


In this formulation, the voltage angle reference constraint (6.12) and voltage magnitude limits (6.13) cannot be simply applied as bounds on optimization variables. These constrained quantities also become functions of U  and W  .

   𝜃reif≤  𝜃i(ui,wi ) ≤ 𝜃reif,      i ∈ ℐref                (6.21)
vi,min ≤ vi (u ,w ) ≤ vi,max,    i = 1...n               (6.22)
 m       m   i  i     m                 b

In Matpower setting the opf.v_cartesian option to 1 (0 by default) selects the cartesian representation for voltages when running an AC OPF.33

6.1.2 Current vs. Power for Nodal Balance Constraints

Another variation of the standard AC OPF problem uses current balance constraints in place of the power balance constraints (6.7)–(6.8) or (6.17)–(6.18). If we let M  and N  represent the real and imaginary parts, respectively, of the current, we can express the current balance functions for the polar form as


and for the cartesian form as


where Sd = Pd + jQd  , Sg = Pg + jQg  and [V ∗]−1   is a diagonal matrix whose i  -th diagonal entry is     ∗
1∕v i  , that is 1--j𝜃i
vime   or 1∕ (ui − jwi)  .

In this formulation, which can be selected by setting the opf.current_balance option to 1,34 the objective function and other constraints are not affected. This option can be used in conjunction with either the polar or cartesian representation of bus voltages.