1
Unsupervised Optimal Power Flow
Using Graph Neural Networks
Damian Owerko, Fernando Gama, and Alejandro Ribeiro
Abstract—Optimal power flow (OPF) is a critical optimization
problem that allocates power to the generators in order to satisfy
the demand at a minimum cost. Solving this problem exactly
is computationally infeasible in the general case. In this work,
we propose to leverage graph signal processing and machine
learning. More specifically, we use a graph neural network to
learn a nonlinear parametrization between the power demanded
and the corresponding allocation. We learn the solution in an
unsupervised manner, minimizing the cost directly. In order
to take into account the electrical constraints of the grid,
we propose a novel barrier method that is differentiable and
works on initially infeasible points. We show through simulations
that the use of GNNs in this unsupervised learning context
leads to solutions comparable to standard solvers while being
computationally efficient and avoiding constraint violations most
of the time.
Index Terms—optimal power flow, unsupervised learning,
graph neural networks, graph signal processing
I. INTRODUCTION
Optimal power flow (OPF) is a critical optimization problem
for the energy industry. It consists in allocating power to each
generator in the grid, so that the energy demand is satisfied
with minimum cost (optimally). OPF is used to allocate
electricity generation throughout the day, establish day-ahead
market prices, and plan for grid infrastructure [1].
The objective of the OPF problem is to minimize the cost of
generating electrical power, subject to the constraints imposed
by the grid infrastructure, the physical laws of electromag-
netism, and the demand patterns. This problem is nonconvex
due to the sinusoidal nature of the alternating current and volt-
age and the constraints imposed by electrical interconnections
of the grid. Therefore, solving the OPF problem exactly is
computationally infeasible in the general case [1], [2]. In fact,
it has been show to be NP-hard [3].
One of the most common ways used to address the non-
tractability of the OPF problem is to solve a linear surrogate
based on small-angle approximations. [4]. In practical cases,
however, power grids are typically highly loaded thus violating
the small-angle approximation [5]. A more accurate, but com-
putationally intensive solution, is to rely on solvers for interior
point methods [6]. The OPF problem can also be approximated
by nonlinear, convex optimization problems. Examples include
quadratic [7], [8], second order conic [9] and semi-definite
Supported by NSF CCF 1717120, ARO W911NF1710438, ARL DCIST
CRA W911NF-17-2-0181, ISTC-WAS and Intel DevCloud. D. Owerko and
A. Ribeiro are with the Dept. of Electrical and Systems Eng., Univ. of Pennsyl-
vania., F. Gama is with the Electrical and Computer Engineering Department,
Rice University, Houston, TX. Email: {owerko,aribeiro}@seas.upenn.edu,
and fgama@rice.edu.
programming (SDP) [10], [11] relaxations. There exists a
small class of topologies for which sufficient conditions exist
for convex relaxation optimality [12]. In particular, these
relaxations work well for radial networks, but often lead to
infeasible solutions or sub-optimal for meshed topologies [12].
Nevertheless, SDP relaxations were shown to perform well
on a variety of topologies [13], promting research into more
advanced relaxations with more general optimality guarantees
[14]. An alternative approach is to use successive linear
approximations that converge to the exact formulation [15].
This allows to balance trade-offs between accuracy and com-
putation time and integrates well into existing infrastructure
that relies on LP solvers. The implementation is slower than
interior point methods. However, unlike interior point methods,
successive linear approximations can be implemented on LP
solvers already used in industry.
Machine learning has arisen as a promising approach to
overcome computational tractability. Inference of machine
learning models is typically much faster than traditional
solvers and feasibility of the solution can be quickly verified
or used to hot-start a computationally expensive solver. Histor-
ically, there were many attempts to apply machine learning to
this problem, with the work in [16] providing a comprehensive
review until 2009. Many of these approaches such as genetic
algorithms and particle swarms, do scale well and therefore
have not between shown to be effective for networks with
more than 30 buses [17]–[20]. Early approaches used imitation
learning to learn to replicate solutions obtained using interior
point methods [21], [22], but often violated constraints and
could not perform that the method used to train them. Newer
approaches such as DeepOPF [23], use constrained learning
and are able to provide more robust solutions.
Graph signal processing (GSP) has emerged as a conve-
nient mathematical framework to describe problems involving
network data [24], [25]. By extending concepts of traditional
signal processing, such as filtering and frequency analysis, to
graph-based data, GSP provides novel tools for the analysis
and design of distributed solutions [26], [27]. Of particu-
lar interest are graph neural networks (GNNs) [28], which
have been shown to be successful in both signal processing
and machine learning problems involving graph data [29]–
[31]. GNNs are built as extensions of graph convolutional
filters, followed by (typically pointwise, typically nonlinear)
activation functions. This allows GNNs to learn nonlinear
behaviors while retaining a decentralized nature and exploiting
the underlying graph structure. Thus, GNNs are promising
candidates for learning optimal power flow allocations from
state measurements, while respecting the topology of the grid.
arXiv:2210.09277v1 [eess.SY] 17 Oct 2022