# Full Problem Specification¶

As input data for an OPF problem we have a power system (*power grid* for non-engineers) consisting of a network of buses (nodes) and branches (arcs).

Each branch is given as an ordered pair \(km\), where \(k\) is the *from* bus and \(m\) is the *to* bus.

For each branch \(km\) we have a complex \(2\times 2\) matrix \(Y_{km}\), the admittance-matrix. The following notation will be used below

\[\begin{split}Y _{km} = \left( \begin{array}{c c} G_{kk} +j B_{kk} & G_{km} +j B_{km}\\ G_{mk} +j B_{mk} & G_{mm} +j B_{mm} \end{array} \right).\end{split}\]We also have a value \(L_{km}\) defining the branch limit.

For every bus \(k\) we have two positive values, \(L_k \, \text{and} \, U_k\) with \(L_k \leq U_k\), defining the voltage limits.

For every bus \(k\) we have two values, \(P^{d}_k \, \text{and} \, Q^{d}_k\), the active and reactive loads (demands), respectively.

For every generator \(i\) we have the active and reactive generation limits, \(P^{\min}_i, \, P^{\max}_i, \, Q^{\min}_i, \, \text{and} \, Q^{\max}_i\) with \(P^{\min}_i, \leq P^{\max}_i, \, Q^{\min}_i, \leq Q^{\max}_i\), as well as a (convex) function \(F_i\) defining the generation cost.

At a bus \(k\) we have a set \(G(k)\) defining the set of generators located at bus \(k\).

For a bus \(k\), denote by \(\delta^+(k) \, \text{and} \, \delta^-(k)\) the set of branches outgoing and incoming branches of the form \(km \, \text{and} \, mk\), respectively.

There may be multiple parallel branches \(km\) but in this writeup, for the sake of simplicity, this is being ignored (the mathematical description is easily adapted). There may be multiple generators at a given bus (we account for this explicitly). The same bus may have generators and a nonzero load (demand). In this simple description we ignore bus shunts.

Associated with each branch \(km\) there are values \(\tau_{km} > 0\) (ratio) and \(\phi_{km}\) (angle). These are meaningful in the case of transformers; for a non-transformer branch we set \(\tau_{km} = 1\) and \(\phi_{km} = 0\).

In modern versions discussed in the Recommended Literature, network devices such as FACTS, phase-shifters, and impedance corrections are also incorporated into the model. We do not account for these in this mod.

## ACOPF¶

In the standard ACOPF problem we set a minimum-cost operating point (complex voltages at all buses, active and reactive power generation at each generator) for a power system so that the correct amount of active and reactive power is delivered to each bus and all branch limits are satisfied; both using the AC power flow laws. Under this model, cost is incurred at the generators. At each generator we are given a convex quadratic or piecewise-linear (convex) cost function associated with active power generation.

### AC Optimization Model¶

The following variables are used in the ACOPF problem.

For each bus \(k\) we have a complex voltage \(V_k = |V_k| e^{j \theta_k}\) (where \(j = \sqrt{-1}\)).

For each branch \(km\) we have the two complex variables \(S_{km} \, \text{and} \, S_{mk}\), the complex power injected into the branch at \(k \, \text{and at} \, m\), respectively. Recall that branches are given as ordered pairs.

For each generator \(i\) there is a (complex) generation \(P^{g}_i + j Q^{g}_i\).

There are five classes of constraints:

branch AC power definitions

flow balance

branch limits

generator limits

voltage bounds

The first set of constraints embody AC power flow laws. For each branch \(km\) we have

where * indicates the complex conjugate. These are the only nonconvex expressions in the entire model. We will also describe alternative representations of these constraints using different notation.

The next set of constraints represent flow balance. For each branch \(k\) we have

In this expression, the left-hand side is the net excess of generation over load at bus \(k\). The right-hand side is the total power injected into the grid at bus \(k\).

Next we have branch limits. For each branch \(km\),

Note: there are alternative versions of this particular constraint. In a power system under normal (non-stressed) operations this constraint is slack for all but a small number of branches.

4.-5. Finally we have generator limits and voltage bounds.

and

The objective to optimize is the following cost expression:

Above we provided an expression defining the complex power flow \(S_{km}\) in terms of the admittance matrix \(Y\). In the following we derive a formulation independent of complex numbers. Denote

The real and imaginary components of \(S_{km}\) are

and

Likewise, in terms of \(S_{mk}\) we have

and

By introducing the auxiliary variables

and

the power flow quantities can be rewritten without the need of complex numbers as

and

respectively.

### Jabr Relaxation¶

We can obtain a Second-Order Cone (SOC) relaxation of the ACOPF formulation by introducing auxiliary variables \(v^{(2)}_k, \ c_{km} \ \text{and} \ s_{km}\), removing the nonconvex definitions of such variables (which involve cosines and sines) and adding the rotated cone constraints

The resulting relaxation can prove very tight, though, despite its convexity, challenging in large cases.

### QCQP¶

ACOPF can be reformulated as a Quadratically Constraints Quadratic Program (QCQP) by performing two reformulation steps.

For each bus \(k\), introduce the real variables \(e_k \, \text{and} \, f_k\) and set \(v^{(2)}_k \, = \, e_k^2 + f_k^2\).

For each branch \(km\), set \(c_{km} = e_k e_m + f_k f_m\) and \(s_{km} = -e_k f_m + f_k e_m\).

These constraints render an exact reformulation rendering the problem as a QCQP, i.e., one that removes the sines and cosines from the formulation. We remind the reader that, for example, we are writing the active power flow injected at bus \(k\) on branch \(km\) through the constraints

(and similarly with \(Q_{km}, \, P_{mk}, \,\text{and} \,Q_{mk}\)).

This is the so-called *cartesian* (or *rectangular*) formulation for ACOPF. This is the formulation that Gurobi currently solves in this mod.

## DCOPF¶

In the so-called DC approximation to the standard ACOPF problem it is assumed that all voltage magnitudes are equal to \(1.0\) and that across all branches the phase angle difference is very small. The active power flow equations are linearized, using these assumptions, and the reactive power flow constraints are ignored. The objective function is the same as for ACOPF. In summary we obtain a linear approximation (not a relaxation) to standard ACOPF which is very commonly used in energy markets.

The network data requirements are likewise limited. For each branch \(km\) the models require the branch reactance \(x_{km}\) as well as a ratio \(\tau_{km}\) and angle \(\phi_{km}\); the latter two are relevant only in the case of transformers. In the non-transformer case we assume \(\tau_{km} = 1\) and \(\phi_{km} = 0\).

### DC Optimization Model¶

The following variables are used in the DCOPF problem.

For each bus \(k\) we have a phase angle \(\theta_k\).

For each branch \(km\) we have the real power flow \(P_{km}\) from \(k\) to \(m\). As we shall see from the model, there is no need for a corresponding variable \(P_{mk}\).

For each generator \(i\) there is the (active) generation \(P^{g}_i\).

There are four classes of constraints:

branch power definitions

flow balance

branch limits

generator limits

The first set of constraints embodies DC power flow laws. For each branch \(km\) we have

It is (implicitly) assumed that \(P_{mk} = -P_{km}\).

The next set of constraints represents active flow balance at each bus \(k\).

In this expression, the left-hand side is the net excess of generation over load at bus \(k\). The right-hand side is the total power injected into the grid at bus \(k\).

Next we have branch limits. For each branch \(km\),

Note: there are alternative versions of this particular constraint. In a power system under normal (non-stressed) operations this constraint is slack for all but a small number of branches.

Finally we have generator limits.

The objective to optimize is the same (usually quadratic convex) cost expression as for ACOPF:

### Branch Switching¶

An important binary MILP extension of DCOPF is that where a binary variable \(z_{km}\) is used to decide if a branch \(km\) is “on” (\(z_{km} = 1\)) or not (\(z_{km} = 0\)). To achive this goal, we simply reformulate the power flow definition as

This constrained is linearized through standard methods.

Branch switching is most often used in DCOPF only due to its additional complexity. Still, it can be applied to an ACOPF model as well. Please note that introducing branch-switching greatly increases problem complexity and thus, obtaining feasible solution to branch-switching ACOPF models is very difficult.