Adversarially Robust Learning for Security-Constrained Optimal Power Flow
Year: 2021

Abstract:
In recent years, the ML community has seen surges of interest in both adversarially robust learning and implicit layers, but connections between these two areas have seldom been explored. In this work, we combine innovations from these areas to tackle the problem of N-k security-constrained optimal power flow (SCOPF). N-k SCOPF is a core problem for the operation of electrical grids, and aims to schedule power generation in a manner that is robust to potentially k simultaneous equipment outages. Inspired by methods in adversarially robust training, we frame N-k SCOPF as a minimax optimization problem – viewing power generation settings as adjustable parameters and equipment outages as (adversarial) attacks – and solve this problem via gradient-based techniques. The loss function of this minimax problem involves resolving implicit equations representing grid physics and operational decisions, which we differentiate through via the implicit function theorem. We demonstrate the efficacy of our framework in solving N-3 SCOPF, which has traditionally been considered as prohibitively expensive to solve given that the problem size depends combinatorially on the number of potential outages.

heading: 1 Introduction
text: Robust optimization problems are pervasive across many applications and domains – such as electric power systems, supply chain management, and civil engineering – where the goal is to construct some solution that is robust under any allowable instantiation of uncertainty [1, 2]. While the aim is generally that these solutions be provably robust, there unfortunately remain many settings where it is either not easy or not possible to construct such solutions. This has often motivated the use of heuristic approaches. For instance, many approaches in adversarially robust deep learning formulate neural network training as a minimax game over neural network parameters and input perturbations, optimizing this problem via gradient-based techniques that do not yield provable robustness guarantees, but are nonetheless effective in practice [3].
In this work, we draw inspiration from adversarially robust training to address the problem of N-k security-constrained optimal power flow (SCOPF). N-k SCOPF is a fundamental problem to schedule power generation in a way that is robust to k potential equipment failures (e.g., generator or line outages). Unfortunately, N-k SCOPF is prohibitively expensive to solve at scale, leading grid operators to use rough approximations in practice. To address this challenge, we frame N-k SCOPF as a minimax attacker-defender problem, where the “defender” aims to schedule power generation, and the “attacker” aims to pick adversarial equipment failures. The loss function of this problem requires solving implicit equations representing the physics of the electric grid as well as additional operational decisions that are made after an attack has occurred. As such, we optimize this problem using gradient-based techniques, and employ insights from the literature on implicit differentiation and implicit layers to cheaply compute gradients through the loss function.
⇤These authors contributed equally.
35th Conference on Neural Information Processing Systems (NeurIPS 2021).
Our key contributions are:
• Formulation for minimax optimization with implicit variables. To streamline the presentation of concepts, we provide a generic formulation for gradient-based optimization of minimax problems with implicitly-defined variables. While our main focus in this paper is on N-k SCOPF, we believe this generic formulation may also be of broader interest for minimax settings with physics in the loop, as well as for tri-level optimization settings.
• Formulation for gradient-based optimization of N-k SCOPF. We rewrite N-k SCOPF as a continuous minimax optimization problem, and demonstrate how to efficiently compute gradients through relevant implicit components. We also utilize the underlying structure of our optimization solvers to further streamline the outer minimization procedure. Importantly, the per-iteration cost of this approach is agnostic to the number of simultaneous outages k, despite the combinatorial blowup in the number of associated “contingency scenarios.”
• Demonstration on N-1, N-2, and N-3 SCOPF. We demonstrate the efficacy of our method in addressing SCOPF settings that allow for one, two, or three simultaneous outages on a realistic 4622-node power system with over 38 billion potential N-3 outage scenarios. We find that our method incurs 3-4⇥ fewer N-3 feasibility violations than a baseline optimal power flow approach, and requires only 21 minutes to run on a standard laptop.

heading: 2 Related work
text: Adversarial robustness in deep learning. There has been a growing body of work that aims to parameterize neural networks in a manner that is robust to particular perturbations of their inputs, usually by casting neural network training as an attacker-defender game [3, 4]. While there have been several promising approaches for certifiably robust neural network training [5–7], in general, these approaches do not yet scale to large-sized networks and only address a limited set of threat models. As a result, there has been a lot of research in this area that aims to train robust neural networks using approximate, gradient-based training methods [8, 9], an approach we adopt in the context of SCOPF. In addition, a key part of this literature has been on constructing strong but cheap-to-compute attacks that can strengthen the outcomes of adversarially robust training, e.g., the fast gradient sign method (FGSM) [8] and projected gradient descent (PGD) attacks [9]. In our experiments, we similarly show how a gradient-based adversarial robustness approach can be used to identify potential grid vulnerabilities, as an input to secure power system optimization.
Implicit layers. Implicit differentiation techniques [10, 11] have started to be used more widely within deep learning workflows, largely in the context of implicit layers, i.e., neural network layers that represent implicit functions [12]. These include differentiable optimization layers [13–19] and physics-based layers [20, 21], among others [22, 23]. Given the large number of parameters within any given deep network, a key aspect of this work has been in finding efficient ways to actually compute the relevant derivatives, e.g., by strategically ordering multiplicative operations and reusing the results of previous computations. We similarly employ these kinds of strategies when computing implicit derivatives for our SCOPF optimization approach. We also note that some of the work on implicit differentiation in deep learning and related areas has been in service of solving bi-level optimization problems, e.g., for decision-driven forecasting [24, 25], hyperparameter tuning [26–29], or system identification and control [30]. We similarly consider the use of implicit differentiation for multi-level optimization (in particular, tri-level optimization) in the context of SCOPF.
Security-constrained optimal power flow. In the electric power systems community, there has been a great deal of emphasis on optimizing power grid operations to be secure to sets of outages (contingencies) that may be particularly high risk. For instance, many grid operators in the United States require grids to be operated in a way that is N-1 secure (i.e., secure against any single outage), which has led to a focus in the literature on addressing N-1 SCOPF [31–34]. However, ensuring security against multiple simultaneous failures (i.e., solving N-k SCOPF for k > 1) is becoming increasingly critical, both as evidenced by recent major blackout events [35, 36] and as climate change drives weather extremes [37] that may lead to correlated outages [38]. That said, due to the computational complexity of addressing N-k SCOPF in the general case, there have been few attempts at developing methods geared towards this setting. In particular, the computational complexity of N-k SCOPF grows combinatorially with k and the size of the system. Some previous attempts to solve N-k SCOPF have employed exhaustive methods [39], Bender’s cuts to reduce the number of
contingencies analyzed [40], and bi-level optimization frameworks [40, 41]. In particular, [41] used bi-level optimization to develop a systematic attacker-defender approach to address N-3 contingency scenarios, but used a simplified, linear power grid model to attain convergence. We similarly adopt a bi-level framework, but solve a realistic non-linear model of the grid by introducing fast gradient calculation methods inspired by the implicit layers literature, which allows us to scale our approach to a 4622-node system.

heading: 3 Generic problem formulation
text: Before diving into the details of our SCOPF formulation, we first provide a more generic formulation for gradient-based minimax optimization over an implicit loss function, which we will later build upon in the context of SCOPF. In particular, we consider the setting of continuous minimax optimization problems over “defender” (minimizer) variables x 2 X and “attacker” (maximizer) variables y 2 Y; these are also referred to as first-stage and second-stage decision variables, respectively, in the bi-level optimization literature. In addition, we allow for “third-stage” decisions z 2 Z that are fully defined via a set of implicit constraints on x, y, and z.
Specifically, we consider problems of the form
minimize x2X max y2Y `(x, y, z)
s. t. g(x, y, z) = 0, z 2 Z, (1)
where X , Y , and Z are compact sets; ` : X ⇥ Y ⇥ Z ! R is a standard, continuously differentiable loss function (e.g., softmax or mean squared error loss); and g : X ⇥ Y ⇥ Z ! Rm is defined such that g(x, y, z) = 0 is an implicit function in z with some solution z 2 Z for all (x, y) 2 X ⇥ Y . We further restrict ourselves to those functions g that are continuously differentiable with non-singular Jacobians at their roots, i.e., those functions that are compatible with the implicit function theorem [3, 42]. We note that this formulation covers a wide range of settings, e.g., many minimax problems with non-linear physical constraints, or many tri-level optimization problems where z is a solution to a continuous optimization problem parameterized by x and y (both of which notions we will use in Section 4 for the setting of N-k SCOPF).
Inspired by the literature on adversarial robustness in deep learning, we propose to solve problem (1) via gradient-based search on both the inner maximization and outer minimization problems. In particular, this entails (a) obtaining some (approximately) optimal y for the inner maximization problem via gradient-based techniques, given some initial value of x, (b) updating x using the gradient at the optimum of the inner maximization problem, and (c) repeating these steps until convergence. We now describe steps (a) and (b) in additional detail.

heading: 3.1 Solving the inner maximization problem
text: Let x̄ denote some fixed value for x. The inner maximization problem is then given by
max y2Y `(x̄, y, z) s. t. g(x̄, y, z) = 0, z 2 Z. (2)
We optimize this problem via projected gradient descent. Specifically, let y = y0 denote our initial guess for the optimal attack, and let P denote the projection operator. Until convergence (or for some fixed number of iterations), we then
(i) Obtain z? such that g(x̄, y, z?) = 0, z? 2 Z . (ii) Update y PY (y + ry`(x̄, y, z?)) for step size .
Notably, step (ii) entails obtaining the gradient ry`(x̄, y, z?). By the chain rule, this involves the gradient through z?, which is the solution to a set of implicit equations. Specifically, using the notation d to denote total derivatives (e.g., gradients) and @ to denote partial derivatives, we have
d`(x̄, y, z?)
dy =
@`(x̄, y, z?)
@y +
@`(x̄, y, z?) @z? dz? dy . (3)
By the implicit function theorem, we can then obtain an expression for dz?/dy by noting that
dg(x̄, y, z?)
dy =
@g(x̄, y, z?) @y + @g(x̄, y, z?) @z? dz? dy = 0 =) dz ? dy = ⇣@g(x̄, y, z?) @z? ⌘ 1 @g(x̄, y, z?) @y ,
(4) which we can plug into Equation (3) to yield our full update.
We note that in practice, we seldom want to compute the Jacobian dz?/dy 2 Rdim(Z)⇥dim(Y) explicitly due to the potentially large time and space complexity of doing so; instead, it is often desirable to compute the left vector-matrix product (@ /̀@z?)(dz?/dy) 2 Rdim(Y) directly. We refer to this strategy as the “vector-Jacobian product trick.” The details of the relevant computations may vary based on the particular setting at hand, and we describe how we employ this trick for SCOPF in Section 4.3.

heading: 3.2 Taking a gradient step in the minimization problem
text: Given some (approximately) optimal y? and associated z? from the inner optimization under the current value of x = x̄, the outer optimization problem then becomes
min x2X
`(x, y?, z?) s. t. g(x, y?, z?) = 0. (5)
One option is to then update x via a projected gradient step x PX (x rx`(x, y?, z?)) for step size . To calculate the gradientrx`(x, y?, z?), we note that by Danskin’s theorem, we can disregard the dependence of y? on x [3] (though we cannot ignore the dependence of z?). As such, we can employ a similar process as in Equations (3) and (4), where we treat y? as constant when computing gradients with respect to x.2 We note that while this is one potential process for updating x, we actually employ a more efficient, domain-specific process for our SCOPF procedure (see Section 4.4).

heading: 4 Addressing N-k SCOPF via adversarially robust optimization
text: Having presented this generic formulation, we now introduce our approach, CAN@Y, for addressing SCOPF.3 In particular, we consider the problem of N-k SCOPF, where power generation must be scheduled so as to be feasible and low-cost both in the absence of equipment outages (“base case”) as well as to be robust to any k simultaneous outages of power generators or lines that may occur (“contingency cases”). We note that the set of contingencies – i.e., allowable combinations of outages – is combinatorial in the number of potential outages, making the SCOPF problem extremely computationally expensive. For instance, a realistic 4622 node system with 6133 potential single outages has ~38.5 billion contingency scenarios to consider under the N-3 setting.
In the rest of this section, we first more formally define the N-k SCOPF problem. We then show how we rewrite N-k SCOPF as a minimax problem of the form (1), in particular by forming a compact outer approximation to the contingency space. Finally, we describe how we solve this problem using a combination of gradient-based techniques and domain-specific enhancements, as summarized in Algorithm 1.

heading: 4.1 Defining N-k SCOPF
text: Let x denote the dispatch – i.e., setpoints of real power4 and voltage magnitude – at all power generators on the electricity system, and let X represent generator-wise box constraints on the dispatch. Let C denote the set of potential contingencies, i.e., all sets of exactly k potential outages.
2Technically, Danskin’s theorem only holds when y? is a unique optimum of the inner maximization problem. However, in the adversarially robust training literature, the conditions of Danskin’s theorem do not necessarily hold – in particular, the inner maximization problem often does not have a unique optimum, and many implementations tend to generate approximate (rather than exact) optima [8, 9] – but this method of computing gradients is used in practice regardless [3].
3CAN@Y stands for “CMU Adversarial Networks with Differentiable contingencY.” This name is inspired by that of SUGAR [43], whose power flow solver we differentiate through in this work.
4Modern electric power systems are generally alternating current (AC) systems, in which all electrical quantities – e.g., powers and voltages – are considered to be complex-valued. In particular, the terms real power and reactive power refer to the real and imaginary components, respectively, of complex power.
Algorithm 1 CAN@Y 1: procedure MAIN(sys) // input: power system description 2: init dispatch x // e.g., via base case optimal power flow 3: while not converged do 4: y? = ATTACK(sys, x) // worst-case attack for current dispatch 5: update x via partial solve of Equation (12) using Gauss-Siedel 6: end while 7: end procedure 8: 9: procedure ATTACK(sys, x) 10: init attack y 11: while not converged or for fixed number of steps do 12: compute z?, s? via Equation (8c) // third-stage variables 13: compute ry`(x, y, z?, s?) via Equation (11) // gradient of attack objective 14: update y PY (y + ry`(x, y, z?, s?)) // for attack set Y , step size 15: end while 16: return y 17: end procedure
Finally, let z(i) 2 Zi(x, c(i)) represent slightly adjusted settings of real power and voltage magnitude that the power system operator can create after scheduling x and then observing some contingency c(i) 2 C, where the Zi represent box constraints. Then, the N-k SCOPF problem can be expressed as
minimize x2X
fbase(x) + X
(z(i), c(i))
fcont(z (i), c(i))
subject to gflow,base(x,wbase) = 0, wbase 2Wbase
z(i) 2 argminz(i)2Zi(x,c(i)) fcont(z
(i), c(i))
s. t. gflow,cont(z(i), w(i), x) = 0, w(i) 2Wi(x, c(i)) 8c(i) 2 C,
(6)
where fbase : X ! R represents base case power production costs; gflow,base : X ⇥Wbase ! Rnbus represents the non-linear power flow equations in the base case, with nbus being the number of power system nodes; wbase represents electrical quantities that result from solving the base case power flow equations (e.g., reactive powers and voltage angles), with box constraints (device limits) represented by Wbase; and fcont : Zi ⇥ C ! R, gflow,cont : Zi ⇥Wi ⇥X ! Rn, and w(i) 2Wi(x, c(i)) represent their respective contingency-case counterparts. (See Appendix A for a more explicit formulation.)

heading: 4.2 Rewriting N-k SCOPF as a minimax problem
text: We reformulate the SCOPF problem (6) as an attacker-defender game, where the defender must choose a dispatch that is robust to potential “worst-case” contingencies chosen by an attacker. In particular, since the contingency set C is discrete, we create a continuous outer approximation to this set in order to enable the use of gradient-based techniques. Specifically, let no be the number of generators or power lines that can potentially experience an outage. Then, for any y 2 [0, 1]no , we define the jth entry as follows:
yj =
8 <
: 1 iff outage j is fully active, 0 iff outage j is not active, ↵j 2 (0, 1) iff outage j is partially active with fraction ↵j .
(7)
The first two notions presented in Equation (7) are standard in power systems: the generator or line pertinent to outage j is either fully operational or out of service. We newly define the notion of a partial outage with fraction ↵j as one in which the power flowing through the outage device during normal operation has been reduced by a factor of ↵j . For instance, we model a partial contingency on a transmission line or transformer device as reducing its admittance (i.e., ability to conduct current) by a factor of ↵j . Similarly, we restrict the power produced by a generator undergoing a partial contingency by multiplying its power output by ↵j .
Given these notions, we define our “threat model” for the N-k SCOPF setting to contain all vectors y with an L1-norm of at most k, i.e., Y := {y : y 2 [0, 1]no , kyk1  k}. Notably, the original contingency set C is fully represented within Y , and in fact, all scenarios with up to k simultaneous potential outages are also represented. As such, Y represents a much broader set of potential contingencies than specified in the original problem. (Relevantly for projected gradient descent, this is also a convex set.) Using this set, we can then write our reformulation of the SCOPF problem as
minimize x2X max y2Y
fbase(x) + fcont(z, y) + 1
2 ksk22 (8a)
subject to gflow,base(x,wbase) = 0, wbase 2Wbase (8b)
z, s 2 argminz2Z(x,y), s2Rnbus fcont(z, y) +
1 2ksk 2 2
s. t. gflow,cont(z, wcont, x) + s = 0, wcont 2Wcont(x, y), (8c)
where s 2 S := R2nbus are slack variables representing potential infeasibilities in the third-stage optimization problem, as necessitated by the expanded contingency set. In particular, the goal of the attacker is to now to find a set of partial outages that not only increase the cost of power generation, but also create instabilities in the grid, as captured by s. As we hinted at in Section 3, this is a minimax optimization problem with implicit constraints over the third-stage variables z, wbase, wcont, and s, incorporating both non-linear equality constraints (8b) as well as an optimization-based constraint (8c).

heading: 4.3 Obtaining attack gradients
text: As described in Section 3.1, we aim to find the worst-case attack via projected gradient descent. In particular, we must compute the gradient of the minimax loss with respect to y, which is given by
d` dy =
@fcont(z?, y)
@y +
@fcont(z?, y) @z? dz? dy + ds? dy . (9)
(As the base case power production cost and the base case power flow constraint (8b) have no dependence on y, we do not need to consider these terms during the inner maximization.)
To calculate the terms dz?/dy and ds?/dy, we implicitly differentiate through the third-stage optimization problem (8c). In order to do so inexpensively, we reuse the results of computations that were executed when originally obtaining z? and s?. More specifically, in order to obtain z? and s?, we solve the non-linear KKT conditions of optimization problem (8c) using a Newton solver (see Appendix B), which entails linearizing these equations at each iteration. At convergence, we then implicitly differentiate through the linear fixed-point equation obtained at the last iteration:
J
✓ z?
s?
◆ = b =) dJ
dy
✓ z?
s?
◆ + J dz?
dy ds? dy
! = db
dy =)
dz? dy ds? dy
! = J 1 ✓ dJ dy ✓ z? s? ◆ + db dy ◆ ,
(10) where J 2 Rd⇥d is the Jacobian of the non-linear KKT system and b 2 Rd is the corresponding right hand side vector, for d = dim(Z) + dim(S). We note that since the system Jacobian J is in practice extremely sparse, the inverse term J 1 can be computed extremely efficiently using sparse LU factorization; similarly, the higher-order derivative dJ/dy is extremely sparse and can be computed efficiently. We refer the reader to [44] for more details.
Substituting this result into Equation (9), the overall gradient of the loss is then given by
d` dy =
@fcont(z?, y)
@y +
@fcont(z ?,y) @z?
1
!T J 1 ✓ dJ dy ✓ z? s? ◆ + db dy ◆ . (11)
As hinted earlier, we employ the “vector-Jacobian product trick” in order to efficiently compute these gradients (see, e.g., [11]). In particular, rather than computing the terms dz?/dy and ds?/dy explicitly via Equation (10), we directly compute their left vector-matrix product with the relevant partial derivatives of the loss – i.e., the blue term in Equation (11), with multiplications evaluated from left to right to ensure we are always taking matrix-vector (rather than matrix-matrix) products. Inspired by [13], we also reuse the LU factor from the last Newton solve we computed when obtaining z?
and s? in order to avoid explicitly (re-)computing the matrix inverse J 1. Finally, we note that for this specific problem, while the last term dJdy ⇣ z?
s?
⌘ + dbdy nominally involves tensor products, the
relevant terms are vastly sparse due to the structure of the underlying physics – with no more than 20 nonzero entries per potential outage – making these products relatively cheap to compute in practice.

heading: 4.4 Solving the defense minimization
text: After obtaining a worst-case attack y?, our next step is to adjust our dispatch x 2 X in response. As described in Section 3.2 for the generic setting, one option to do this involves taking a projected gradient step in x. However, we adopt a different approach for N-k SCOPF, due to the practical requirements of this setting. In particular, a general system requirement is that the base case power flow equations gflow,base(·) = 0 must remain feasible under the dispatch x 2 X , as the most likely scenario is that no contingency will occur. However, projecting onto this (non-linear, non-convex) set of constraints can be expensive.
As a result, we instead note that we can rewrite the N-k SCOPF minimax problem (8) as a single minimization problem:
minimize x2X , z2Z(x,y?), s2Rnbus
fbase(x) + fcont(z, y ?) +
1 2 ksk22
subject to gflow,base(x,wbase) = 0, wbase 2Wbase
gflow,cont(z, wcont, x) + s = 0, wcont 2Wcont(x, y?).
(12)
To determine our next iterate of x, our strategy is then to partially solve this optimization problem by running one step of a non-linear Gauss-Seidel method, and then keep the value of x obtained from that step. This allows us to incrementally update x in a direction that is more robust to the worst-case attack y?, while still maintaining the feasibility of the base case power flow equations.
Importantly, we are able to run this procedure efficiently, as we can reuse the results of existing computations that were executed when obtaining the optimal attack y?. In particular, as we describe in more detail in Appendix C, we can split the KKT conditions of the problem (12) into two groups:
✓ dL/dx
dL/d base
◆ ⌘ Fbase(x,wbase, base) + (@gflow,cont(z,wcont,x)/@x)T cont
0
! = 0 (13a)
0 @ dL/dz dL/ds
dL/d cont
1
A ⌘ Fcont(z, wcont, cont) +
0 @ 0
0
gflow,cont(z, wcont, x)
1
A = 0, (13b)
where L denotes the Lagrangian of problem (12), and base and cont are the dual variables on the base case and contingency power flow constraints, respectively. We note that the two terms Fbase and Fcont are independent in terms of their inputs, but are weakly coupled via the additional terms (which represent a sparse set of ramping constraints and voltage setpoints that tie together the base and contingency cases). This is an ideal setup for decoupling through non-linear Gauss-Seidel solution methods. In addition, the contingency-related KKT conditions (13b) are actually identical to the KKT conditions of the problem (8c) that we solved during the last iteration of the inner maximization problem; as a result, we can reuse the result of this previous computation when executing our Gauss-Seidel step. Together, this allows us to inexpensively identify an update direction for x that nonetheless remains feasible with respect to the base case power flow constraints.

heading: 5 Experiments
text: We demonstrate the efficacy of our approach on the settings of N-1, N-2 and N-3 SCOPF. In particular, noting that quality of adversarial attacks is likely to have a large effect on the success of our overall procedure, we first visualize the attacks found by our inner maximization process (Sections 3.1, 4.4) on a small power system test case. We then demonstrate the performance of our overall approach on a realistic 4622-node power system with approximately 6 thousand potential N-1 contingencies, almost 19 million N-2 contingencies, and over 38 billion N-3 contingencies. We show that CAN@Y
Partial outage value
(a) Visualization of the worst-case contingency found, with the degree of the associated partial outage on each line indicated in blue. (Plot generated via PowerWorld.)
=
(b) Training curve for finding a worst-case contingency. The process converges within 5 iterations, and increases the loss by 3%.
Figure 1: Illustrative example of finding a worst-case N-2 contingency on a 14-node test system.
is able to efficiently find solutions that are competitive with other leading approaches in the N-1 case, while reducing violations in the N-2 and N-3 scenarios compared to a base case optimal power flow.
All experiments are run on a single core of a Macbook Pro with a 2.6 GHz Core i7 CPU. We implement our approach in Python, using a custom optimal power flow solver called SUGAR [45] to compute optimization (8c), and CVXPY [46] to compute convex projections for projected gradient descent. We evaluate all dispatch solutions using PowerWorld, a commercial power flow tool.

heading: 5.1 Illustrative adversarial attack
text: Finding worst-case contingencies is often beneficial to power systems engineers, who try to identify fragile areas of their grid for future development. Traditionally, engineers use linear approximations of the grid physics [47–49] to identify single outages that pose a significant risk to system stability. However, given that the underlying physics are fundamentally non-linear, such linear approximations quickly become inaccurate when trying to identify the risks associated with multiple simultaneous outages. Our implicit differentiation approach, on the other hand, employs accurate gradient information from the physics of the network to quickly identify contingencies that maximally increase our loss function (or an alternative loss function of choice that also captures system infeasibilities).
For ease of visualization, we demonstrate this attack-identification approach on the IEEE 14-node test system. In particular, we identify an adversarial N-2 contingency on this system in just 5 iterations (approximately one minute), increasing the value of the loss function by 3% over the base case scenario, as shown in Figure 1b. This worst-case contingency represents a combination of multiple partial outages on different lines, and (perhaps surprisingly) does not include any generator outages, as shown in Figure 1a. This is likely to present a stronger attack than those obtained via the “standard” linear approximation approach, serving as a potential benefit to power system planners who are trying to reinforce their grid, as well as to “adversarially robust training” procedures like ours.

heading: 5.2 Validating N-1 security
text: Today, most grid operators in the United States require that their dispatch be N-1 secure, i.e., secure against any single outage, prompting the development of associated methods. In particular, the recent Grid Optimization (GO) Competition [34], hosted by ARPA-E, focused on finding algorithms to solve N-1 SCOPF. Each participating team used a variety of methods to produce a dispatch that was evaluated on the basis of power cost and feasibility in both the base and contingency cases. In order to validate that our method works well in the N-1 setting, we solve a particular case from the competition – namely, the 4622-node test case with a sub-selection of 3071 N-1 potential contingencies, provided as part of the Challenge 1 stage – by constructing our relaxed contingency set Y with k = 1.
We find that our score is comparable against the top approaches submitted to the GO Competition, as shown in Table 1. We note that these score comparisons are not exact, as our power flow solver uses a more realistic model for coupling between the base and contingency cases than was posed in Challenge 1, which affects the way that the evaluation metric is computed (see Appendix D). Nonetheless, at a high level, these results demonstrate that our method performs competitively with respect to the top-performing methods for solving N-1 SCOPF.

heading: 5.3 Improving N-3 SCOPF
text: We now describe the performance of our method on our main setting of interest: N-3 SCOPF. While other competitive methods exist for solving N-1 SCOPF, previous work has struggled to approach settings allowing for larger numbers of simultaneous outages (e.g., N-k SCOPF for k = 2 or 3) due to the associated combinatorial explosion in problem size. Our method, however, scales gracefully with respect to the number of allowable simultaneous outages, as we need only tweak the value of k used within our attack set Y := {y : y 2 [0, 1]no , kyk1  k}. More specifically, each iteration of the attack maximization and each defense step calculation take approximately the same amount of time regardless of the value of k, given that the costs of the gradient computations, projections, and (optimal) power flow solves are independent of k. (The total number of iterations it takes for our method to converge may vary between settings, though we do not notice a substantive difference in this respect between the N-1, N-2, and N-3 versions of our approach during our experiments.)
We use our method to attempt to solve N-3 SCOPF (i.e., set k = 3) on a 4622-node test case over all 6133 potential outages (i.e., over 38 billion N-3 contingency scenarios); the associated training curve is shown in Figure 2. In total, our approach takes only 21 minutes to converge.
We evaluate the strength of our obtained dispatch in maintaining feasibility against a combination of N-1, N-2, and N-3 contingency scenarios, which are all technically contained within the threat model represented by our choice of Y . We note that while full security against all these contingencies
is likely impossible with a single dispatch – e.g., we can very often construct an N-3 contingency that isolates, or islands, some non-self-sustaining part of the electrical grid – we aim to demonstrate that our method can improve upon existing methods in terms of providing robustness against a wide variety of scenarios. As there remain a lack of available N-2 or N-3 SCOPF methods against which we can readily compare, we compare our performance against that of a base case optimal power flow (OPF) solver, as well as the open-source PowerModels N-1 SCOPF algorithm [50]. Due to the intractability of evaluating these dispatches on all possible contingency scenarios, we randomly sub-select the set of N-1, N-2, and N-3 scenarios on which we evaluate, and run these evaluations in PowerWorld over the course of several days.
The results of our evaluation are shown in Table 2. Overall, we see that CAN@Y significantly reduces the number of total contingency violations as compared to the OPF solution by a factor of 3-4⇥. While the PowerModels baseline and our approach perform comparably with respect to N-1 and N-2 contingency violations, our approach incurs nearly 5⇥ fewer N-3 violations as compared to PowerModels. Analyzing the N-3 contingencies in more detail, we find that of the 4086 specific violations incurred by OPF, 931 of those were also incurred by CAN@Y (while the remaining 191 violations incurred by our method were disjoint). Overall, these results indicate that our method is much more effective than OPF and a benchmark N-1 SCOPF solver at guarding against N-2 and N-3 contingencies, though the actual distribution of specific contingencies that are guarded against may differ between these methods.

heading: 6 Conclusion
text: In this paper, we have described our approach, CAN@Y, for N-k security-constrained optimal power flow. Specifically, we formulate N-k SCOPF as a minimax problem over power system dispatches and potential outages by forming a continuous outer approximation to the contingency space. This enables us to compute “worst-case” contingencies via projected gradient descent (using tricks from the implicit layers literature) and then employ these contingencies to update our proposed dispatch. Notably, our formulation scales gracefully in the number of contingencies – requiring only a minor tweak to the projection set during the attack step – even as the underlying problem scales combinatorially. In particular, our approach takes only 21 minutes to converge on a standard laptop for a realistic 4622-node test case with over 38 billion potential N-3 contingencies. We show that our approach reduces N-3 feasibility violations by a factor of 3-4⇥ compared to a baseline optimal power flow method and by almost 5⇥ compared to a baseline N-1 SCOPF solver. Overall, we believe this demonstrates the promise of our approach in enabling scalable N-k security-constrained optimization on realistic-scale power grids.
We note that the success of our minimax optimization approach is likely highly reliant on the strength of the adversarial attacks that we generate, just as in the adversarially robust training literature [3, 4]. As such, a fruitful direction for future work may involve developing improved procedures for obtaining adversarial attacks in the context of SCOPF. In addition, given the large scale of the power networks we consider, it is generally impossible to evaluate proposed dispatches against the full suite of potential contingencies in order to check whether they are indeed N-k secure. Given that, another fruitful direction may entail developing better evaluation metrics or verification procedures to inexpensively evaluate whether a proposed SCOPF dispatch is (likely) robust, perhaps again drawing inspiration from the literature on verification methods for adversarially robust deep learning [51].

heading: 7 Broader impacts
text: To address climate and sustainability goals, many power grids are starting to integrate larger amounts of time-varying renewable energy, such as solar and wind. As described in [52], this means power systems optimization problems must generally be solved both more quickly and at larger scales. In addition, weather extremes driven by climate change [37] yield a significant need for resilient power system optimization. We believe our work makes an important contribution to this area by providing a scalable and efficient method to address N-k SCOPF. One potential concern, however, is that our method relies on identifying “worst-case” power system attacks, and our associated approach could theoretically be exploited by adversarial actors; that said, we believe it unlikely that our method in particular would be used for this purpose, as it employs a continuous “partial outage” approximation that is useful for the purposes of our algorithm, but does not map neatly to actual real-world attacks.
Acknowledgments and Disclosure of Funding
This work was supported by the U.S. Department of Energy Computational Science Graduate Fellowship (DE-FG02-97ER25308), the Center for Climate and Energy Decision Making through a cooperative agreement between the National Science Foundation and Carnegie Mellon University (SES-00949710), the National Science Foundation (ECCS-1800812), the Computational Sustainability Network, and the Bosch Center for AI.
We thank Eric Wong, George Haff, Marko Jereminov, Amritanshu Pandey, and anonymous reviewers for their input on this work.

Review summaries:
The authors develop a new method for solving the N-k SCOPF problem, an optimal power flow problem robust to any $k$ outages. Specifically, they relax the problem to allow for any convex combination of outages that has total 1-norm less than $k$. They then leverage recently popularized implicit differentiation techniques to solve the resulting minimax problem. Their formulation works for generic minimax problems, although one can exploit problem-specific structure when solving the N-k SCOPF problem. Finally, they test their method on a reasonably large test case for $k = 1, 2, 3$, and show that it finds a solution in a reasonable amount of time that improves upon standard OPF (in terms of the number of violations).

In this paper, N-k SCOPF is formulated and solved through the lens of adversarial learning and the implicit function theory. Thus, problem formulation and the development of a multi-level optimization algorithm are two key contributions. Meanwhile, the paper is mostly well written and easy to follow.