Machine Learning For AC OPF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Machine Learning for AC Optimal Power Flow

Neel Guha 1 Zhecheng Wang 2 Matt Wytock 3 Arun Majumdar 2

Abstract convex relaxations, etc) either fail to converge within this


time frame or produce suboptimal solutions. In order to
arXiv:1910.08842v1 [cs.LG] 19 Oct 2019

We explore machine learning methods for AC


practically manage the grid, operators solve a linearized
Optimal Powerflow (ACOPF) - the task of opti-
version of ACOPF practice known as DC Optimal Power
mizing power generation in a transmission net-
Flow (DCOPF). However, DCOPF presents a number of
work according while respecting physical and en-
issues. True grid conditions can deviate from the lin-
gineering constraints. We present two formula-
ear assumptions imposed by DCOPF, increasing the like-
tions of ACOPF as a machine learning problem:
lihood of instability and grid failure (Frank & Rebennack,
1) an end-to-end prediction task where we di-
2016). Relying on DCOPF also has significant implica-
rectly predict the optimal generator settings, and
tions for climate change. A 2012 report from the Federal
2) a constraint prediction task where we predict
Energy Regulatory Commission estimated that the ineffi-
the set of active constraints in the optimal solu-
ciencies induced by approximate-solution techniques may
tion. We validate these approaches on two bench-
cost billions of dollars and release unnecessary emissions
mark grids.
(Cain et al., 2012). Determining an efficent solution for
ACOPF could also be adapted to combined economic emis-
sion dispatch (CEED) - a variant of OPF which incorpo-
1. Introduction rates a per-generator emissions cost into the classic objec-
The Optimal Power Flow problem (OPF) consists of deter- tive function (Venkatesh et al., 2003).
mining the optimal operating levels for different generators In this paper, we observe that it should be possible to learn a
within a transmission network in order to meet the demand model that can predict an accurate solution over a fixed grid
that is changing over space and time. An established area of topology/constraint set. Intuitively, we expect some mea-
research in both power systems and operations, OPF is ap- sure of consistency in the solution space - similar load dis-
plied every day in the management and regulation of power tributions should correspond to similar generator settings.
grids around the world. In this work, we hope to obtain This suggests an underlying structure to the ACOPF prob-
real-time approximate solutions to the OPF problem using lem, which a machine learning model can exploit.
machine learning.
Machine learning present several advantages. Neural net-
The classical formulation of ACOPF (presented in Sec- works have demonstrated the ability to model extremely
tion 3) is a challenging non-convex and NP-hard prob- complicated non-convex functions, making them highly at-
lem (Bienstock & Verma, 2015). In addition to minimiz- tractive for this setting. A model could be trained off-line
ing generator costs, solutions must adhere to physical laws on historic data and used in real-time to make predictions
governing power flow (i.e. Kirchhoff’s voltage law) and on an optimal power setting. In this work, we explore two
respect the engineering limits of the grid. As a result, applications of machine learning for OPF:
ACOPF is computationally intractable under the demands
of daily grid management. In order to account for rapid 1. End-to-end: Train a model to directly predict the
fluctuations in power demand and supply, grid operators optimal generator setting for a given load distribution. This
must solve ACOPF over the entire grid (comprising of tens is challenging, as the model’s output must be adherence
of thousands of nodes) every five minutes 1 (Cain et al., with physical laws/engineering limits.
2012). Most traditional approaches (genetic algorithms,
1
Carnegie Mellon University 2 Stanford University 3 Gridmatic, 2. Constraint prediction: Train a model to predict which
Inc.. Correspondence to: Neel Guha <[email protected]>. constraints are active (i.e at equality) in the optimal solu-
tion. Knowing this active set can be used to warm start ex-
Presented at the Climate Change Workshop at ICML 2019 isting approaches (i.e. interior point methods) and reduce
1
The addition of renewable sources of energy (wind, solar, etc) solution time.
adds more unpredictability and is a motivation for improved tech-
niques for ACOPF
Machine learning for AC Optimal Power Flow

2. Related Work 3.1. End-to-end Prediction


Prior work has explored different applications of ma- In this setting, we pose the AC OPF problem as a re-
chine learning on the grid. This includes work on es- gression task, where we predict the grid control vari-
timating active constraints for DCOPF (Ng et al., 2018; ables (PiG and ViG ) from the grid demand (PiL and
Misra et al., 2018), predicting grid failures (Rudin et al., QLi ). These fix a set of equations with equal number
2012), or choosing between traditional solvers (King et al., of unknowns, which can be solved to identify the re-
2015). Machine learning has also been applied to re- maining state values for the grid. Formally, given a
lated variants of the OPF problem, including automated dataset of n solved grids with load distributions X =
grid protection (Donnot et al., 2017), price proxy predic- {[P0L , .., PN
L
, QL L n
0 , ..., QN ]}i=1 and corresponding optimal
tion (Canyasse et al., 2016), or private information recov- generator settings Y = {[P0G , .., PG G
, V0G , ..., VGL ]}ni=1 ,
ery (Donti et al.). To the extent of our knowledge, there our goal is to learn fθ : X → Y which minimizes the mean-
has been limited work on direct applications of deep learn- squared error between the optimal generator settings Y and
ing towards ACOPF. the predicted generator settings Ỹ . Solving for the remain-
ing state variables can be posed as a power flow problem,
and reduces to finding ViL , QG i , and δi such that (1b)-(1g)
3. Method
are satisfied.
We now present the traditional ACOPF problem, and
The central challenge in this setting is ensuring that the neu-
describe how to formalize it as a machine learning
ral network’s solution respects physical laws and engineer-
task(Frank et al., 2012). For a fixed grid topology G, let N
ing limits. Though provable guarantees may be difficult to
denote the set of buses (nodes), L denote the set of branches
make, we experiment by incorporating soft penalties into
(edges), and G ⊆ N denote the set of controllable gener-
our loss function that encourage predictions to fall within
ators. For bus i, we enumerate PiG (real power injection),
legal limits. These correspond to linear penalties that acti-
QG L
i (reactive power injection), Pi (real power demand),
L vate when when (1d) and (1f) are violated. In future work
Qi (reactive power demand), Vi (voltage magnitude), and
we hope to explore more sophisticated (and robust) tech-
δi (voltage angle). the power demand at AC OPF can be
niques for enforcing legality.
framed as:
3.2. Optimal Constraint Prediction
X Given that neural networks may learn solutions that vi-
minimize Ci (PiG ) (1a) olate physical constraints, and are thus untrustworthy in
PiG i∈G
practical settings, we explore optimal constraint prediction
subject to as formulated by Misra et al. (2018). In this setting, our
Pi (V, δ) = PiG − PiL , , (1b) model is trained to predict the set of constraints that are ac-
tive in the optimal solution for some load distribution. A
Qi (V, δ) = QG L
i − Qi , ∀i ∈ N, (1c) constraint is active if the corresponding state/control vari-
PiG,min ≤ PiG ≤ PiG,max , ∀i ∈ G, (1d) able is at the maximum or minimum allowed value. As
Misra et al. (2018) describe, knowing the active set of con-
QG,min
i ≤ QG
i ≤ Qi
G,max
, ∀i ∈ G, (1e)
straints can be used to warm start a more traditional opti-
min max
Vi ≤ Vi ≤ Vi , ∀i ∈ N, (1f) mization method, and reduce time to convergence.
δi ≤ δi ≤ δimax ,
min
∀i ∈ N (1g) Formally, for each grid we define a constraint vector
y ∈ R2G+2N corresponding to an enumeration of con-
straints (1d)-(1e), where yi = 1 if the i-the constraint
Where (1a) typically represents a polynomial cost func-
is active in the optimal solution, and yi = 0 other-
tion, (1b)-(1c) corresponds to the power flow equations,
wise. We learn fθ which maps from the load distribution
and (1d)-(1g) represent operational limits on real/reactive
[P0L , .., PN
L
, QL L
0 , ..., QN ] to this constraint vector. This cor-
power injections, nodal voltage magnitude, and nodal volt-
responds to a multi-label classification problem.
age angles2 respectively. More recent settings of OPF - in-
cluding ours- also include limits on branch currents. These Optimal constraint prediction presents several advantages
are outlined in more detail by Frank et al. (2012). We now over end-to-end prediction.
present two formalizations of AC OPF as a machine learn-
ing problem. In our setting, we assume that PiL and QL i
(real and reactive demand) are known across all N buses. 1. Solver Speedup: From an optimization perspective,
knowing the set of active constraints equates to warm-
2
A single reference bus ("slack" bus) is fixed to Ṽ = 1.0∠0 starting, and can significantly speed-up more traditional
Machine learning for AC Optimal Power Flow

algorithms like interior point methods, active set meth- Roughly, this captures the reliability and optimality of a
ods, simplex methods, and others. Quantifying this particular model. We examine a range of different architec-
speedup is the focus of ongoing work. tures and training strategies. We performed a grid search
considering models with 1-2 hidden layers, 128/256/512
2. Reliability: This setting reduces the risk of a neural hidden neurons, ReLU/Tanh activations. We also exper-
network producing a solution which violates physical imented with vanilla MSE loss, and a variant with lin-
laws/engineering limits. Because the physical and en- ear penalties for constraint violations (described in Section
gineering constraints are enforced by the solver, an in- 3.1). Each model was trained with Adam (lr = 0.001) until
correct prediction will at worst increase solution time loss convergence, for a maximum of 2000 epochs.
or lead to a suboptimal solution. In the end-to-end set-
ting described in Section 3.1, incorrect predictions could Grid Legality Rate Avg. Cost Deviation
destabilize the grid.
case30 0.51 0.002
3. Task complexity: Classifying the set of active con- case118 0.70 0.002
straints is significantly easier than predicting a set of real
valued targets. Table 1. End-to-end prediction performance. Average cost devia-
tion is only reported for legal grids.

4. Results Table 1 reports the best performance for each grid type. For
We validated approaches for end-to-end prediction and con- case30, the optimal model was a two layer neural network
straint prediction on IEEE 30-bus 3 and 118-bus test cases4 . with tanh activations, and no loss penalty. For case118, the
These test cases include predetermined constraints. optimal model was a three layer network with 512 hidden
neurons, ReLU activations, and a constraint loss penalty.
4.1. Dataset Generation Interestingly, we observe better performance on case118
than case30. Though we would intuitively expect task dif-
The IEEE test cases include a pre-calculated load distri- ficulty to scale with grid size, this result suggests that other
bution (denoted as x∗ . In order to construct a dataset for factors could affect a model’s generalization ability. In par-
each case, we repeatedly sample candidate load distribu- ticular, smaller grids could be less stable, and thus more
tions x′ ∼ Uniform((1 − δ) · x∗ , (1 + δ) · x∗ ), for some likely to produce a wide range of (less predictable) behav-
fixed δ. We identify y ′ by solving the OPF problem for ior under varying demand distributions. We also observe
x′ via Matpower (Zimmerman et al., 2011). In some cases, that the cost of the optimal model predictions were within
the solver fails to converge, suggesting that the sampled x′ 1% of the optimal cost.
has no solution given the grid constraints. In this case, we
discard x′ . 4.3. Constraint Prediction
We generated 95000 solved grids for case118 and 812888 For constraint prediction, we evaluate performance in terms
solved grids for case30 with δ = 0.1 (a 10% perturba- of accuracy (i.e. the proportion of constraints classified
tion to the IEEE base demand). Interestingly, we observe successfully). We perform a similar hyperparameter grid
that while 100% of the samples generated for case118 were search and report the best results in Table 2.
successfully solved, only 81.2% of the samples for case30
were successfully solved. For all prediction tasks, we used Grid % Accuracy
a 90/10 train-test split and report results on the test set. case30 0.99
case118 0.81
4.2. End to end prediction
We evaluate task performance along two metrics: Table 2. Constraint prediction performance

• Legality Rate: The proportion of predicted grids which In general, we find neural networks to be highly successful
satisfy all engineering and physical constraints. at determining which the active constraint set.
• Avg. Cost Deviation: The average fractional difference
between the cost of the predicted grid, and the cost of the 5. Conclusion
1 Pn pred costi
true grid: |1 − | over legal grids.
In this work, we presented two approaches that leverage
n i true costi
machine learning for solving ACOPF. Preliminary experi-
3 ments present promising results in both settings. In next
https://electricgrids.engr.tamu.edu/electric-grid-test-cases/ieee-30-bus-system/
4
steps, we hope to evaluate our methods on more complex
https://electricgrids.engr.tamu.edu/electric-grid-test-cases/ieee-118-bus-system/
Machine learning for AC Optimal Power Flow

grid architectures, and explore different approaches for in- constraints. IEEE Transactions on Power systems, 18(2):
corporating grid constraints into our models. 688–697, 2003.

Zimmerman, R. D., Murillo-Sánchez, C. E., and Thomas,


References R. J. Matpower: Steady-state operations, planning, and
Bienstock, D. and Verma, A. Strong np-hardness analysis tools for power systems research and educa-
of ac power flows feasibility. arXiv preprint tion. IEEE Transactions on power systems, 26(1):12–19,
arXiv:1512.07315, 2015. 2011.

Cain, M. B., O’neill, R. P., and Castillo, A. History of


optimal power flow and formulations. Federal Energy
Regulatory Commission, pp. 1–36, 2012.

Canyasse, R., Dalal, G., and Mannor, S. Super-


vised learning for optimal power flow as a real-
time proxy. CoRR, abs/1612.06623, 2016. URL
http://arxiv.org/abs/1612.06623.

Donnot, B., Guyon, I., Schoenauer, M., Panciatici, P., and


Marot, A. Introducing machine learning for power sys-
tem operation support. arXiv preprint arXiv:1709.09527,
2017.

Donti, P. L., Azevedo, I. L., and Kolter, J. Z. Inverse op-


timal power flow: Assessing the vulnerability of power
grid data.

Frank, S. and Rebennack, S. An introduction to optimal


power flow: Theory, formulation, and examples. IIE
Transactions, 48(12):1172–1197, 2016.

Frank, S., Rebennack, S., et al. A primer on optimal power


flow: Theory, formulation, and practical examples. Col-
orado School of Mines, Tech. Rep, 2012.

King, J. E., Jupe, S. C., and Taylor, P. C. Network state-


based algorithm selection for power flow management
using machine learning. IEEE Transactions on Power
Systems, 30(5):2657–2664, 2015.

Misra, S., Roald, L., and Ng, Y. Learning for constrained


optimization: Identifying optimal active constraint sets.
arXiv preprint arXiv:1802.09639, 2018.

Ng, Y., Misra, S., Roald, L. A., and Backhaus, S. Statistical


learning for dc optimal power flow. In 2018 Power Sys-
tems Computation Conference (PSCC), pp. 1–7. IEEE,
2018.

Rudin, C., Waltz, D., Anderson, R. N., Boulanger, A.,


Salleb-Aouissi, A., Chow, M., Dutta, H., Gross, P. N.,
Huang, B., Ierome, S., et al. Machine learning for the
new york city power grid. IEEE transactions on pattern
analysis and machine intelligence, 34(2):328–345, 2012.

Venkatesh, P., Gnanadass, R., and Padhy, N. P. Comparison


and application of evolutionary programming techniques
to combined economic emission dispatch with line flow

You might also like