Interior Point Methods for Optimal Power Flow: Linear Algebra Goodies and Contingency Generation Andreas Grothey (joint work with Nai Yuan Chiang, Argonne National Lab) School of Mathematics, University of Edinburgh IMA Numerical Analysis 2014, 3-5 September, Birmingham I VER S E R G O F H Y TH IT E UN DI N B U Andreas Grothey OPF contingency generation USA August 2003 before 4.05pm after 4.10pm 50 million people disconnected within 5 min Andreas Grothey OPF contingency generation US-Canada Power System Outage Task Force: “Interim Report: Causes of the August 14th Blackout in the United States and Canada”, November 2003 Andreas Grothey OPF contingency generation US-Canada Power System Outage Task Force: “Interim Report: Causes of the August 14th Blackout in the United States and Canada”, November 2003 Andreas Grothey OPF contingency generation Challenges for the Energy Industry Power Systems operation faces new challenges Competition/increasingly guided by market principles Increasing integration of renewables (uncertainty) Expansion of distributed generation/smart grid Transmission capacity does not keep up, expansion is politically contentious. ⇒ Secure operation of networks becomes increasingly important! Andreas Grothey OPF contingency generation Challenges for the Energy Industry Power Systems operation faces new challenges Competition/increasingly guided by market principles Increasing integration of renewables (uncertainty) Expansion of distributed generation/smart grid Transmission capacity does not keep up, expansion is politically contentious. ⇒ Secure operation of networks becomes increasingly important! Power System operation needs to be designed robustly Traditionally achieved by use of safety margins Increasing need to take network contingencies into account explicitly ⇒ Security constrained Optimal Power Flow Andreas Grothey OPF contingency generation Challenges for the Energy Industry Power Systems operation faces new challenges Competition/increasingly guided by market principles Increasing integration of renewables (uncertainty) Expansion of distributed generation/smart grid Transmission capacity does not keep up, expansion is politically contentious. ⇒ Secure operation of networks becomes increasingly important! Security Constrained Optimal Power Flow (SCOPF) Important both in its own right and as a subproblem for Unit Commitment Transmission switching etc Andreas Grothey OPF contingency generation Overview The Problem Power systems 101 Optimal Power Flow & Security constraints AC OPF vs DC OPF Linear Algebra Goodies Interior Point Methods Compact factorization Iterative methods & preconditioners Contingency Generation Motivation IPM, warmstarting & theory Results Andreas Grothey OPF contingency generation Optimal Power Flow Andreas Grothey OPF contingency generation Security Constrained Optimal Power Flow Optimal Power Flow (OPF) Optimal Power Flow is the problem of deciding on (cost) optimal electricity generator outputs to meet demand without overloading the transmission network Solved at a given time for known demand Andreas Grothey OPF contingency generation Security Constrained Optimal Power Flow Optimal Power Flow (OPF) Optimal Power Flow is the problem of deciding on (cost) optimal electricity generator outputs to meet demand without overloading the transmission network Solved at a given time for known demand Need to model all lines in the network Power flows are AC: represented by complex flows (or real and reactive components) ⇒ nonlinear network constraints Andreas Grothey OPF contingency generation Security Constrained Optimal Power Flow Optimal Power Flow (OPF) Optimal Power Flow is the problem of deciding on (cost) optimal electricity generator outputs to meet demand without overloading the transmission network Solved at a given time for known demand Need to model all lines in the network Power flows are AC: represented by complex flows (or real and reactive components) ⇒ nonlinear network constraints Unlike other transportation networks, operator has no control over routing. Routing is determined by physics! ⇒ Kirchhoffs Laws. Andreas Grothey OPF contingency generation Power Systems Operation 101 Andreas Grothey OPF contingency generation Power System Operation Network b ∈ B Buses l = (bb ′ ) ∈ L Lines g ∈ G Generators (at bus og ) Power flows are AC. Described by real and reactive flows over lines, voltage and phase angle at buses Variables vb δb pbb′ , qbb′ pgG , qgG Voltage level at bus b Phase angle at bus b Real and reactive power flow on line l = (bb ′ ) Real and reactive power output at generator g Andreas Grothey OPF contingency generation Power System Operation Network b ∈ B Buses l = (bb ′ ) ∈ L Lines g ∈ G Generators (at bus og ) Parameters of the model are: line/bus characteristics, real/reactive demands, limits on power flow and voltages Parameters Gbb′ , Bbb′ conductance and susceptance of line l Cb PbD , QbD bus susceptance real and reactive power demand at bus b (reciprocals of resistance and reactance) Andreas Grothey OPF contingency generation Power System Operation Operator decides on real generation level and voltages at generators. Power flows and reactive generation arrange themselves so as to satisfy power flow equations (Kirchhoff Laws) Constraints Kirchhoff Voltage Law (KVL) L pbb ′ = vb [Gbb ′ (vb − vb ′ cos(δi − δj )) + Bbb ′ vb ′ sin(δb − δb ′ )] L qbb ′ = vb [−Gbb ′ vb ′ sin(δi − δj ) + Bbb ′ (vb ′ cos(δb − δb ′ ) − vb )] Kirchhoff X Current Law (KCL)X pgG − PbD = pbb′ , (b,b′ )∈L g |og =b X g |og =b qgG − QbD = X ∀b ∈ B, qbb′ + Cb vb 2 , (b,b′ )∈L Andreas Grothey OPF contingency generation ∀b ∈ B Power System Operation Operator decides on real generation level and voltages at generators. Power flows and reactive generation arrange themselves so as to satisfy power flow equations (Kirchhoff Laws) Constraints Kirchhoff Voltage Law (KVL) L pbb ′ = vb [Gbb ′ (vb − vb ′ cos(δi − δj )) + Bbb ′ vb ′ sin(δb − δb ′ )] L qbb ′ = vb [−Gbb ′ vb ′ sin(δi − δj ) + Bbb ′ (vb ′ cos(δb − δb ′ ) − vb )] Kirchhoff X Current Law (KCL)X pgG − PbD = pbb′ , (b,b′ )∈L g |og =b X g |og =b qgG − QbD = X ∀b ∈ B, qbb′ + Cb vb 2 , (b,b′ )∈L ∀b ∈ B L 6= p L , q L 6= q L due to line losses! Note: pbb ′ b′ b b′ b bb′ Andreas Grothey OPF contingency generation Power System Operation Line flows and generator reactive output should satisfy Operational Limits Line Flow Limits at both ends of each line 2 2 (pb′ b )2 + (qb′ b )2 ≤ fl (pbb′ )2 + (qbb′ )2 ≤ fl , Voltage limits at buses V min ≤ vb ≤ V max reactive generation limits at generators Qgmin ≤ qgG ≤ Qgmax Andreas Grothey OPF contingency generation Power System Operation The variables of the OPF model can be divided into control and state variables Control u (set by the system operator) pgG real power output at generators vg voltage levels at generation buses State x (determined by Kirchhoff’s laws) vb voltage levels at non-generating buses G qg reactive power output at generators δb phase angles ′ ′ pbb , qbb real and reactive power flows over lines OPF model minu∈U s.t. f (u) KL(u, x) = 0 g (x) ≤ 0 Andreas Grothey (Kirchhoff’s laws) (Operational limits) OPF contingency generation Power System Operation The variables of the OPF model can be divided into control and state variables Control u (set by the system operator) pgG real power output at generators vg voltage levels at generation buses State x (determined by Kirchhoff’s laws) vb voltage levels at non-generating buses G qg reactive power output at generators δb phase angles ′ ′ pbb , qbb real and reactive power flows over lines OPF model minu∈U s.t. f (u) KL(u, x) = 0 g (x) ≤ 0 (Kirchhoff’s laws) (Operational limits) Nonlinear! nonconvex! May have local solutions! Andreas Grothey OPF contingency generation Security Constrained Optimal Power Flow Robustification of OPF Things go wrong: Lines do fail ⇒ Security-constrained OPF (SCOPF) Find a (cost optimal) generation schedule that is feasible with respect to network limits (line flows, bus voltages) even if any one line should fail (while meeting given demand) Andreas Grothey OPF contingency generation Security Constrained Optimal Power Flow Robustification of OPF Things go wrong: Lines do fail ⇒ Security-constrained OPF (SCOPF) Find a (cost optimal) generation schedule that is feasible with respect to network limits (line flows, bus voltages) even if any one line should fail (while meeting given demand) Contingency Scenarios Typically consider all (single) line and bus (node) failures ⇒ (n − 1) secure operation Many operators require (n − 2). Becomes computationally very expensive! Andreas Grothey OPF contingency generation Security Constrained Optimal Power Flow Robustification of OPF Things go wrong: Lines do fail ⇒ Security-constrained OPF (SCOPF) Find a (cost optimal) generation schedule that is feasible with respect to network limits (line flows, bus voltages) even if any one line should fail (while meeting given demand) Two-Stage Setup (like Stochastic Programming) First stage decides on generation levels for all generators Second stage corresponds to contingency scenarios (evaluate consequences of line/bus failures) Andreas Grothey OPF contingency generation Security Constrained Optimal Power Flow Robustification of OPF Things go wrong: Lines do fail ⇒ Security-constrained OPF (SCOPF) Find a (cost optimal) generation schedule that is feasible with respect to network limits (line flows, bus voltages) even if any one line should fail (while meeting given demand) Two-Stage Setup (like Stochastic Programming) First stage decides on generation levels for all generators Second stage corresponds to contingency scenarios (evaluate consequences of line/bus failures) Scenarios only evaluate feasibility of first stage decisions. No objective contribution! No recourse action! Andreas Grothey OPF contingency generation Security Constrained Optimal Power Flow Robustification of OPF Things go wrong: Lines do fail ⇒ Security-constrained OPF (SCOPF) Find a (cost optimal) generation schedule that is feasible with respect to network limits (line flows, bus voltages) even if any one line should fail (while meeting given demand) Two-Stage Setup (like Stochastic Programming) First stage decides on generation levels for all generators Second stage corresponds to contingency scenarios (evaluate consequences of line/bus failures) Scenarios only evaluate feasibility of first stage decisions. No objective contribution! No recourse action! Observation Only a few contingency scenarios are needed/active to determine the solution. How to find them? Andreas Grothey OPF contingency generation (n-1) secure OPF In case of equipment (line/bus) failure, power flows will rearrange themselves according to the power flow equations Control variables u = (pgG , vg ) same for all contingencies, Each contingency has its own set of state variables G , δb,c , pbb′ ,c , qbb′ ,c ) xc = (vb,c , qb,c determined by Kirchhoff’s laws for the reduced network (KLc ) ⇒ Seek a setting of control variables that does not lead to violation of operational limits in any contingency SCOPF model minu∈U s.t. f (u) KLc (u, xc ) = 0 gc (xc ) ≤ 0 Andreas Grothey ∀c ∈ C ∀c ∈ C OPF contingency generation Structure of SCOPF problem SCOPF model minu∈U s.t. f (u) KLc (u, xc ) = 0 gc (xc ) ≤ 0 Structure of Jacobian ∂KL1 ∂x1 ∂g1 ∂x1 ∀c ∈ C ∀c ∈ C ∂KLc ∂u .. 0 .. . . ∂KL|C| ∂x|C| ∂g|C| ∂x|C| Andreas Grothey ∂KL|C| ∂u 0 OPF contingency generation Structure of SCOPF problem SCOPF model minu∈U s.t. f (u) KLc (u, xc ) = 0 gc (xc ) ≤ 0 Structure of Jacobian ∂KL1 ∂x1 ∂g1 ∂x1 ∀c ∈ C ∀c ∈ C ∂KLc ∂u W1 T01 .. .. . . ∂KL|C| ∂x|C| ∂g|C| ∂x|C| ∂KL|C| ∂u W|C| T0|C| Bordered block-diagonal matrix. Andreas Grothey OPF contingency generation The DC OPF problem The OPF model can simplified under the following assumptions: Voltage level at all buses is the same: vb = 1, ∀b ∈ B. The resistance of each line is small compared to reactance: ⇒ |Bbb′ | ≫ |Gbb′ | ⇒ assume Gbb′ = 0. Phase angle difference across each line is small L = 0. ⇒ sin(δ1 − δ2 ) ≈ δ1 − δ2 , cos(δ1 − δ2 ) ≈ 1, ⇒ qbb ′ “DC”-OPF model Kirchhoff Voltage Law L pbb ′ = −Bbb ′ (δb − δb ′ ), ∀(bb ′ ) ∈ L Kirchhoff Current Law X X G L D pg = p(b,b ′ ) + Pb , g |og =b (b,b′ )∈L Line Flow Limits: −fl ≤ plL ≤ fl , Andreas Grothey ∀b ∈ B ∀l ∈ L OPF contingency generation The DC OPF problem The OPF model can simplified under the following assumptions: Voltage level at all buses is the same: vb = 1, ∀b ∈ B. The resistance of each line is small compared to reactance: ⇒ |Bbb′ | ≫ |Gbb′ | ⇒ assume Gbb′ = 0. Phase angle difference across each line is small L = 0. ⇒ sin(δ1 − δ2 ) ≈ δ1 − δ2 , cos(δ1 − δ2 ) ≈ 1, ⇒ qbb ′ “DC”-OPF model Kirchhoff Voltage Law L pbb ′ = −Bbb ′ (δb − δb ′ ), ∀(bb ′ ) ∈ L Kirchhoff Current Law X X G L D pg = p(b,b ′ ) + Pb , g |og =b (b,b′ )∈L Line Flow Limits: −fl ≤ plL ≤ fl , ∀b ∈ B ∀l ∈ L ⇒ DC OPF is a linear programming problem Andreas Grothey OPF contingency generation Structure of DC OPF problem the DC-OPF problem can be written as DC-OPF min c ⊤ p G s.t. R · p L +A⊤ · δ −J · p G A · pL =0 = −P D where bus/generator incidence matrix J ∈ IR |B|×|G| node/arc incidence matrix A ∈ IR |B|×|L| R = diag(1/B1 , . . . , 1/B|L| ) Andreas Grothey OPF contingency generation Structure of DC OPF problem the DC-OPF problem can be written as DC-OPF min c ⊤ p G s.t. R · p L +A⊤ · δ −J · p G A · pL =0 = −P D where bus/generator incidence matrix J ∈ IR |B|×|G| node/arc incidence matrix A ∈ IR |B|×|L| R = diag(1/B1 , . . . , 1/B|L| ) Augmented system like structure! Andreas Grothey OPF contingency generation Structure of (n-1) secure DC OPF SCOPF (DC version) c ⊤pG min p G ,p L ,δ s.t. Rp1L +A⊤ 1 δ1 L A1 p1 .. −Jp G =0 = PD . = .. G Rp|C| +A⊤ |C| δ|C| G A|C| p|C| −Jp G =0 = PD .. . . Andreas Grothey OPF contingency generation Structure of (n-1) secure DC OPF SCOPF (DC version) c ⊤pG min p G ,p L ,δ s.t. Rp1L +A⊤ 1 δ1 L 1 A1 p1 W T −Jp1 G .. .. . . =0 = PD . = .. G Rp|C| +A⊤ =0 |C| δ|C| G G |C| |C| A|C| p|C| −Jp = PD W Bordered block-diagonal matrix. Andreas Grothey OPF contingency generation T whistle stop tour of Interior Point Methods Andreas Grothey OPF contingency generation Interior Point Methods (for LP) Linear Program min c ⊤ x s.t. Ax x = b ≥ 0 (LP) KKT Conditions c − A⊤ λ − s Ax XSe x, s X = diag(x), S = diag(s) Andreas Grothey = = = ≥ 0 b 0 0 OPF contingency generation (KKT) Interior Point Methods (for LP) Barrier Problem min c ⊤ x − µ X ln xi s.t. Ax x = b ≥ 0 (LPµ ) KKT Conditions c − A⊤ λ − s Ax XSe x, s = = = ≥ 0 b µe 0 Introduce logarithmic barriers for x ≥ 0 Andreas Grothey OPF contingency generation (KKTµ ) Interior Point Methods (for LP) Barrier Problem min c ⊤ x − µ X ln xi s.t. Ax x = b ≥ 0 (LPµ ) KKT Conditions c − A⊤ λ − s Ax XSe x, s = = = ≥ 0 b µe 0 Introduce logarithmic barriers for x ≥ 0 (LPµ ) is strictly convex System (KKTµ ) can be solved per Newton-Method Andreas Grothey OPF contingency generation (KKTµ ) Interior Point Methods (for LP) Barrier Problem min c ⊤ x − µ X ln xi s.t. Ax x = b ≥ 0 (LPµ ) KKT Conditions c − A⊤ λ − s Ax XSe x, s = = = ≥ 0 b µe 0 (KKTµ ) Introduce logarithmic barriers for x ≥ 0 (LPµ ) is strictly convex System (KKTµ ) can be solved per Newton-Method For µ → 0 solution of (LPµ ) converges to solution of (LP) Andreas Grothey OPF contingency generation Interior Point Methods (for LP) KKT conditions c − A⊤ λ − s Ax XSe x, s Andreas Grothey = = = ≥ 0 b µe 0 OPF contingency generation (KKTµ ) Interior Point Methods (for LP) KKT conditions c − A⊤ λ − s Ax XSe x, s = = = ≥ 0 b µe 0 (KKTµ ) Newton-Step 0 A⊤ I ∆x ξc c − A⊤ λ − s A 0 0 ∆λ = ξb := b − Ax S 0 X ∆s rxs µ+ e − XSe Andreas Grothey OPF contingency generation Interior Point Methods (for LP) KKT conditions c − A⊤ λ − s Ax XSe x, s = = = ≥ 0 b µe 0 (KKTµ ) Newton-Step 0 A⊤ I ∆x ξc c − A⊤ λ − s A 0 0 ∆λ = ξb := b − Ax S 0 X ∆s rxs µ+ e − XSe Newton Step (reduced) ∆x ξc − X −1 rxs −Θ A⊤ = A 0 ∆y ξb where Θ = X −1 S, X = diag(x), Andreas Grothey S = diag(s) OPF contingency generation Solving NLP by Interior Point Method NLP min f (x) s.t. g (x) Andreas Grothey ≤ 0 OPF contingency generation (NLP ) Solving NLP by Interior Point Method NLP min f (x) − µ X ln zi s.t. g (x) + z z Andreas Grothey = 0 ≥ 0 OPF contingency generation (NLPµ ) Solving NLP by Interior Point Method NLP min f (x) − µ X ln zi s.t. g (x) + z z = 0 ≥ 0 (NLP ) Optimality conditions ∇f (x) − A(x)⊤ y g (x) + z XZe x, z = = = ≥ 0 0 µe 0 Newton Step Q(x, y ) A(x)⊤ ∆x ∇ − f (x) − A(x)⊤ y = A(x) −Θ ∆y −g (x) − µY −1 e where Q(x, y ) = ∇2xx (f (x) + y ⊤ g (x)), Θ=X −1 Z, X = diag(x), Andreas Grothey A(x) = ∇g (x) Z = diag(z) OPF contingency generation Linear Algebra of IPMs Main work: solve r −Q − Θ A⊤ ∆x = A 0 ∆y h | {z } Φ (QP) or r −Q(x, y ) A(x)⊤ ∆x = A(x) Θ ∆y h {z } | Φ (NLP) for several right-hand-sides at each iteration Two stage solution procedure factorize Φ = LDL⊤ backsolve(s) to compute direction (∆x, ∆y ) + corrections ⇒ Φ changes numerically but not structurally at each iteration Key to efficient implementation is exploiting structure of Φ in these two steps Andreas Grothey OPF contingency generation Structure of matrices A and Q for SCOPF: Matrix A W1 W2 T1 T2 W|C| T|C| Andreas Grothey Q1 Matrix Q Q2 OPF contingency generation Q|C| Q0 Structures of A and Q imply structure of Φ: W1⊤ Q1 Q2 W 1 W 2 W2⊤ Q|C| Q0 T1⊤ T2⊤ T1 T2 W|C|T|C| Q A⊤ A 0 ⊤ W|C| ⊤ T|C| Andreas Grothey Q1W1⊤ W1 T2 Q|C|W ⊤ |C| T|C| W|C| T1 Q2W2⊤ W2 T1⊤ P T2⊤ Q A⊤ A 0 OPF contingency generation ⊤ T|C| P −1 Q0 Structures of A and Q imply structure of Φ: W1⊤ Q1 Q2 W 1 W 2 W2⊤ Q|C| Q0 T1⊤ T2⊤ T1 T2 W|C|T|C| Q A⊤ A 0 ⊤ W|C| ⊤ T|C| Φ1 B1 P B1⊤ Φ2 .. B2 . ··· Q A⊤ A 0 ⊤ B2 .. . ⊤ Φ|C| B|C| B|C| Φ0 P −1 Bordered block-diagonal structure in Augmented System! Andreas Grothey OPF contingency generation OOPS: Object Oriented Parallel Solver OOPS OOPS is an IPM implementation, that can exploit (nested) block structures through object oriented linear algebra Solved (multistage) stochastic programming problems from portfolio management with over 109 variables (≈ 2h on 1280 processors) Andreas Grothey D11 D12 A C31 C32 D1 D10 B11 B12 Primal Block Angular Structure Dual Block Angular Structure Primal Block Angular Structure D30 D2 D21 D22 D23 OPF contingency generation D20 B21 B22 B23 Exploiting Structure in IPM Block-Factorization of Augmented System Matrix 10 1 0 1 0 Φ1 B1⊤ x1 b1 B .. .. C B .. C B .. C B B C B C . . C CB . C = B . C B ⊤A @ A @ @bn A xn Φn Bn x b0 B1 · · · Bn Φ0 0 {z } | {z } | {z } | x b Φ Solution of Block-system by Schur-complement The solution to Φx = b is P x0 = C −1 b̃0 , b̃0 = b0 − i Bi Φ−1 i bi −1 ⊤ xi = Φi (bi − Bi x0 ), i = 1, . . . , n where C is the Schur-complement n X ⊤ C = Φ0 − Bi Φ−1 i Bi i =1 ⇒ only need to factor Φi , not Φ Andreas Grothey OPF contingency generation Exploiting Structure in IPM Solution of Block-system by Schur-complement The solution to Φx = b is P x0 = C −1 b̃0 , b̃0 = b0 − i Bi Φ−1 i bi −1 ⊤ xi = Φi (bi − Bi x0 ), i = 1, . . . , n where C is the Schur-complement n X ⊤ C = Φ0 − Bi Φ−1 i Bi i =1 Bottlenecks in this process are Factorization of the Φi P ⊤ Assembling ni=1 Bi Φ−1 i Bi Andreas Grothey OPF contingency generation Structure of Augmented System Matrix Bottlenecks in this process are Factorization of the Φi , Φ= B1⊤ B2⊤ .. . Φ1 Φ2 .. B1 . B2 · · · For DC-OPF Wi = Assembling Φn Bn Bn⊤ R Ai AT i 0 Φ0 , , Pn −1 ⊤ i =1 Bi Φi Bi Φi = Xi−1 Si Wi 0 J Bi⊤ = WiT 0 , where J ∈ IR |Bi |×|Gi | : bus-generator incidence matrix Ai ∈ IR |Bi |×|Li | : node-arc incidence matrix for contingency i R = diag(−V 2 /B1 , . . . , V 2 /B|L| ): resistances > 0 Andreas Grothey OPF contingency generation Block-Factorization for DC-OPF Structure of Φi for DC-OPF −1 R Xi Si WiT , Wi = Φi = Ai Wi 0 AT i 0 , Bi⊤ = 0 J Solve Φi x = b: Wi is invertible and constant throughout IPM iterations To solve Φi x = b only need to factorize Wi : (0) (0) −1 x b Xi Si Wi⊤ = (1) Wi 0 x b (1) ⇒ x (1) = Wi−1 b (1) , x (0) = Xi Si−1 (b (0) − Wi⊤ x (1) ) ⊤ To build Bi Φ−1 i Bi ⊤ = −J ⊤ Wi−⊤ Xi Si−1 Wi−1 J Bi Φ−1 i Bi = −Vi Xi−1 Si Vi⊤ , Andreas Grothey Vi⊤ = Wi−1 J OPF contingency generation , Exploiting Structure in IPM Solution of block-system by Schur-complement The solution to Φx = b is P x0 = C −1 b̃0 , b̃0 = b0 − i Bi Φ−1 i bi n X Vi⊤ = Wi−1 J Vi Xi−1 Si Vi⊤ , C = Φ0 + i =1 Forming Vi Xi−1 Si ViT and factorizing C is (still) expensive Andreas Grothey OPF contingency generation Exploiting Structure in IPM Solution of block-system by Schur-complement The solution to Φx = b is P x0 = C −1 b̃0 , b̃0 = b0 − i Bi Φ−1 i bi n X Vi⊤ = Wi−1 J Vi Xi−1 Si Vi⊤ , C = Φ0 + i =1 Forming Vi Xi−1 Si ViT and factorizing C is (still) expensive ⇒ Solve Cx0 = b̃0 by iterative method Use (preconditioned) iterative method (e.g. PCG/GMRES) ⇒ Evaluating matrix-vector products C · x is cheap: X C · x = Φ0 x + J ⊤ Wi−⊤ Xi−1 Si Wi−1 Jx Multiplication with J is trivial: J is 0-1 matrix. Wi has been factorized Andreas Grothey OPF contingency generation Possible preconditioners Single (base) contingency (Qiu, Flueck ’05) M = Φ0 + nV0 X0−1 S0 V0⊤ Sample Average Approximation M = Φ0 + (Anitescu, Petra ’12) n X Vi Xi−1 Si Vi⊤ |S| i ∈S where S = random selection of contingency scenarios Active Contingencies M = Φ0 + (Chiang, G. ’13) X Vi Xi−1 Si Vi⊤ i ∈A where A = set of contingencies considered active Andreas Grothey OPF contingency generation Active Contingency Preconditioner Active Contingencies (Chiang, G. ’13) M = Φ0 + X Vi Xi−1 Si Vi⊤ i ∈A where A = set of contingencies considered active. Based on the observation Vi Xi−1 Si Vi⊤ Vi = J ⊤ Wi−⊤ constant X = diag(x), x = vector of slacks ⇒ Large contribution Xi−1 Si ≡ small slack xi ≡ active contingency ⇒ Concentrate on active contingencies. Andreas Grothey OPF contingency generation Active Contingency Preconditioner Active Contingencies (Chiang, G. ’13) M = Φ0 + X Vi Xi−1 Si Vi⊤ i ∈A where A = set of contingencies considered active. Based on the observation Vi Xi−1 Si Vi⊤ Vi = J ⊤ Wi−⊤ constant X = diag(x), x = vector of slacks ⇒ Large contribution Xi−1 Si ≡ small slack xi ≡ active contingency ⇒ Concentrate on active contingencies. Which contingencies should be considered active? Andreas Grothey OPF contingency generation Active Contingency Preconditioner: Theoretical Result Convergence speed of an iterative scheme with system matrix C and preconditioner M, is determined by the distribution of eigenvalues of M −1 C Aim: All close to unity Small numbers of clusters Theorem For a given δ > 0 let A consist of all contingencies i for which any xi ,j < 1/δ. Then all eigenvalues λi of M −1 C satisfy |λi (M −1 C ) − 1| = O(δ) Related to Active Set Preconditioners (Forsgren, Gill, Griffin ’07) Andreas Grothey OPF contingency generation Test Problem Buses 3 26 56 118 300 iceland 100 200 300 400 500 Gen 4 5 7 54 69 35 25 50 75 100 125 Cont 2 40 79 177 322 72 180 370 565 760 955 Variables 17 2,630 10,648 53,811 229,077 28,725 50,344 210,779 488,534 881,339 1,389,194 Andreas Grothey Constraints 14 2,626 10,642 53,758 229,009 28,691 50,320 210,730 488,460 881,240 1,389,070 OPF contingency generation Nonzeros 35 7,929 31,060 172,019 683,542 77,059 165,649 701,249 1,635,824 2,960,399 4,674,974 Results Results for Active Contingency preconditioner: #Bus 3 26 56 118 300 iceland 100 200 300 400 500 #Scenarios 3 41 80 178 323 73 181 371 566 761 956 Time(s) <0.1 0.27 1.26 6.68 24.83 3.12 9.09 50.63 205.79 523.65 823.95 Iters 8 13 15 13 13 13 20 28 39 55 46 |A| 2 2 6 7 12 5 7 9 20 20 25 Base case preconditioner only works for smallest two problems Andreas Grothey OPF contingency generation Results buses 3 26 56 118 300 iceland 100 200 300 400 500 Default time(s) memory <0.1 5.2MB 0.21 7.6MB 1.00 14.3MB 6.88 49MB 31.79 198MB 2.28 25MB 9.02 54.6MB 65.97 220MB 251.70 531MB 955.32 985MB 1552.80 1593MB Direct time(s) memory <0.1 5.2MB 0.17 7.5MB 0.77 14.1MB 6.69 64MB 30.42 282MB 2.36 30MB 6.16 53.1MB 45.23 244MB 177.39 667MB 655.50 1380MB 1195.77 2467MB Andreas Grothey Iterative time(s) memory <0.01 5.2MB 0.27 7.4MB 1.26 13.5MB 6.88 24.83 3.12 9.09 43.6MB 50.63 163MB 205.79 387MB 523.65 715MB 823.95 1163MB OPF contingency generation Contingency Generation Andreas Grothey OPF contingency generation Contingency Generation Andreas Grothey OPF contingency generation Contingency Generation “n-1”- (or even “n-2”-security) requires the inclusion of many contingency scenarios. Pan-European system has 13000 nodes and 20000 lines ⇒ Resulting SCOPF model would have ≈ 1010 variables. Only a few contingencies are critical for operation of the system (but which ones)? Contingency Generation Generate contingency scenarios dynamically when needed Andreas Grothey OPF contingency generation Contingency Generation Prototype Algorithm: Set up the model with a few base contingency scenarios Solve model to obtain optimal controls uk∗ repeat Check for violated contingency scenarios. Add violated scenarios to the model ∗ . Re-solve model to obtain new controls uk+1 until no more violated contingencies Andreas Grothey OPF contingency generation Contingency Generation Prototype Algorithm: Set up the model with a few base contingency scenarios Solve model to obtain optimal controls uk∗ repeat Check for violated contingency scenarios. Add violated scenarios to the model ∗ . Re-solve model to obtain new controls uk+1 until no more violated contingencies Can we do this with Interior Point Methods? Interior Point Methods are efficient for large scale (AC)OPF. IPMs are bad at resolving a modified problem instance (warmstarting) ⇒ attempt to dynamically add contingencies into the partially solved OPF. Andreas Grothey OPF contingency generation Warmstarting Interior Point Methods Aim: Use information from solution process of min c ⊤ x s.t. Ax x = b ≥ 0 (LP) to construct a starting point for (nearby problem) min c̃ ⊤ x s.t. Ãx x = b̃ ≥ 0 f (LP) where à ≈ A, b̃ ≈ b, c̃ ≈ c f It is not a good idea to use the solution of (LP) to start (LP). Unlike for the Simplex/Active Set Method! Andreas Grothey OPF contingency generation Interior Point Methods (for NLP) Nonlinear Problem min f (x) s.t. g (x) = 0 x ≥ 0 (NLP) KKT Conditions ∇c(x) − ∇g (x)⊤ λ − s g (x) XSe x, s = = = ≥ 0 0 0 0 (KKTµ ) Introduce logarithmic barriers for x ≥ 0 System (KKTµ ) can be solved per Newton-Method For µ → 0 solution of (NLPµ ) converges to solution of (NLP) Andreas Grothey OPF contingency generation Interior Point Methods (for NLP) Barrier Problem min f (x) − µ X ln xi s.t. g (x) = 0 x ≥ 0 (NLPµ ) KKT Conditions ∇c(x) − ∇g (x)⊤ λ − s g (x) XSe x, s = = = ≥ 0 0 µe 0 (KKTµ ) Introduce logarithmic barriers for x ≥ 0 System (KKTµ ) can be solved per Newton-Method For µ → 0 solution of (NLPµ ) converges to solution of (NLP) Andreas Grothey OPF contingency generation Interior Point Methods (for NLP) KKT conditions ∇c(x) − ∇g (x)⊤ λ − s g (x) XSe x, s = = = ≥ 0 0 µe 0 (KKTµ ) Central Path The set of all solutions to (KKTµ ) for all µ > 0. Central Path joins the analytical center (for µ= ∞) with the NLP solution (for µ = 0). Neighbourhood of the central path (as used by IPOPT) where N (κ) := {(x, λ, s) : Eµ (x, λ, s) ≤ κµ} Eµ (x, λ, s) := max k∇f (x) − ∇g (x)λ − sk kXS − µek , kg (x)k, sd sc Andreas Grothey OPF contingency generation Path Following Methods (for NLP) choose x0 , λ0 , s0 > 0, µ0 = x0⊤ s0 /n, k = 0 Outer iteration update µ: µ+ = σ ⊤ x+ s+ n , 0 < σ < 1, k ← k + 1 Inner iteration compute Newton step (∆x, ∆s, ∆λ) for (KKTµ ) and given µk . Do line search with merit function or filter to compute stepsizes and take step in Newton direction until Eµk (xk , λk , sk ) ≤ κµk Andreas Grothey OPF contingency generation Why? Hippolito (1993): Search direction is parallel to nearby constraints Modified Problem Original Problem Andreas Grothey OPF contingency generation Why? Hippolito (1993): Search direction is parallel to nearby constraints Modified Problem Original Problem ⇒ only small step in search direction can be taken Andreas Grothey OPF contingency generation Warmstarting Heuristics Idea: Start close to the (new) central path, not close to the (old) solution Modified Problem Original Problem ⇒ Start from a previous iterate and do additional modification step. Ok, as long as change to problem is small (compared to µ) Andreas Grothey OPF contingency generation Interior Point Warmstarts: Theoretical Results A typical warmstart results is (Assume à = A): Lemma (based on Gondzio/G. ’03) Let (x, λ, s) ∈ N−∞ (γ0 ) for problem (LP) then a full modification f is feasible and step (∆x, ∆λ, ∆s) in the perturbed problem (LP) (x + ∆x, λ + ∆λ, s + ∆s) ∈ Ñ−∞ (γ) provided that δbc ≤ √ γ0 − γ γ0 µ3/2 2 2B∞ ⇒“small δbc , large µ” where δbc := kc̃ − ÃT y − sk2 + kÃT (ÃÃT )−1 (b̃ − Ãx)k2 := Pc̃−ÃT y−s (s) + Pb̃−Ãx (x) is the orthogonal distance of the warmstart point from primal-dual feasibility in the perturbed problem Andreas Grothey OPF contingency generation Contingency Generation Prototype Algorithm: Set up the model with a few base scenarios Solve model to obtain optimal controls u0∗ . repeat Check for violated contingency scenarios. Add violated scenarios to the model ∗ . Re-solve model to obtain new controls uk+1 until no more violated contingencies Andreas Grothey OPF contingency generation Contingency Generation Prototype Algorithm: Set up the model with a few base scenarios. Solve model to obtain controls u0∗ . repeat Check for violated contingency scenarios. Add violated scenarios to the model. ∗ Re-solve model to obtain new controls uk+1 . until no more violated contingencies Andreas Grothey OPF contingency generation Contingency Generation Prototype Algorithm: Set up the model with a few base scenarios. µ0 = µ̄, k = 0. Solve model to obtain µ0 -center. ⇒ controls uµ0 . repeat Check for violated contingency scenarios. Add violated scenarios to the model. Choose µk+1 : 0 < µk+1 < µk , k ← k + 1 Warmstart and iterate to find µk -center. ⇒ controls uµk . until no more violated contingencies Andreas Grothey OPF contingency generation Contingency Generation Prototype Algorithm: Set up the model with a few base scenarios. µ0 = µ̄, k = 0. Solve model to obtain µ0 -center. ⇒ controls uµ0 . repeat Check for violated contingency scenarios. for all violated scenarios do Set up single scenario problem with u = uµk and solve for µk -center end for Add violated scenarios to the model. Patch together warmstart point for expanded problem. Choose µk+1 : 0 < µk+1 < µk , k ← k + 1 Warmstart and iterate to find µk -center. ⇒ controls uµk . until no more violated contingencies Andreas Grothey OPF contingency generation Contingency Generation Prototype Algorithm: Set up the model with a few base scenarios. µ0 = µ̄, k = 0. Solve model to obtain µ0 -center. ⇒ controls uµ0 . repeat Check for violated contingency scenarios. for all violated scenarios do Set up single scenario problem with u = uµk and solve for µk -center end for Add violated scenarios to the model. Patch together warmstart point for expanded problem. Choose µk+1 : 0 < µk+1 < µk , k ← k + 1 Warmstart and iterate to find µk -center. ⇒ controls uµk . until no more violated contingencies Claim We can ensure that the assembled warmstart point is in the neighbourhood N (κ) ⇒ IPM convergence not negatively affected (warmstart successful) Andreas Grothey OPF contingency generation Derivation of Algorithm IPM applied to SCOPF model minu,xc ,sc s.t. P P f (u) − µ c∈C i ln sc,i KLc (u, xc ) = 0 gc (xc ) + sc = 0 Partially decompose: C = C0 ∪ C0 min u,xc ,sc s.t. f (u) − µ P P i c∈C0 ln sc,i + P ∀c ∈ C ∀c ∈ C Vc,µ (u) c∈C0 KLc (u, xc ) = 0 gc (xc ) + sc = 0 ∀c ∈ C0 ∀c ∈ C0 where Vc,µ (u) = min −µ xc ,sc s.t. P i ln sc,i KLc (u, xc ) = 0 ∀c ∈ C0 gc (xc ) + sc = 0 Andreas Grothey OPF contingency generation Active/Inactive contingencies KKT conditions for contingency problem (Vc,µ (u)) primal feasibility dual feasibility KLc (u, xc )=0 ∇x KLc (u, xc )⊤ λc +∇gc (xc )⊤ νc =0 gc (xc ) + sc =0 Andreas Grothey OPF contingency generation centrality sc,i νc,i =µe s c , νc ≥ 0 Active/Inactive contingencies KKT conditions for contingency problem (Vc,µ (u)) primal feasibility dual feasibility KLc (u, xc )=0 ∇x KLc (u, xc )⊤ λc +∇gc (xc )⊤ νc =0 gc (xc ) + sc =0 sc,i νc,i = µ ⇒ νc,i = µ/sc,i centrality sc,i νc,i =µe s c , νc ≥ 0 ∗ > 0 and thus if contingency c is never active then sc,i → sc,i kνc k = O(µ) → 0 ⇒ kλc k = O(µ) → 0 Andreas Grothey OPF contingency generation Active/Inactive contingencies KKT conditions for contingency problem (Vc,µ (u)) primal feasibility dual feasibility KLc (u, xc )=0 ∇x KLc (u, xc )⊤ λc +∇gc (xc )⊤ νc =0 gc (xc ) + sc =0 sc,i νc,i = µ ⇒ νc,i = µ/sc,i centrality sc,i νc,i =µe s c , νc ≥ 0 ∗ > 0 and thus if contingency c is never active then sc,i → sc,i kνc k = O(µ) → 0 ⇒ kλc k = O(µ) → 0 if contingency is active at solution then kνc k → kνc∗ k > 0 ⇒ kλc k → kλ∗c k > 0 Andreas Grothey OPF contingency generation Combined point is in neighbourhood N (κ) Neighbourhood of the Central Path where N (κ) := {(x, λ, s) : Eµ (x, λ, s) ≤ κµ} Eµ (x, λ, s) := max k∇f (x) − ∇g (x)λ − sk∞ , kg (x)k∞ , kXS − µek∞ {z } | {z } | {z } | dual feasibility Andreas Grothey primal feasibility OPF contingency generation centrality Combined point is in neighbourhood N (κ) Neighbourhood of the Central Path where N (κ) := {(x, λ, s) : Eµ (x, λ, s) ≤ κµ} Eµ (x, λ, s) := max k∇f (x) − ∇g (x)λ − sk∞ , kg (x)k∞ , kXS − µek∞ {z } | {z } | {z } | dual feasibility primal feasibility centrality Central Path conditions for SCOPF problem primal feasibility dual centrality P feasibility ⊤ KLc (u, xc ) =0 ∇f (u)− c ∇u KLc (u, xc ) λc =0 sc,i νc,i =µe gc (xc ) + sc =0 ∇x KLc (u, xc )⊤ λc +∇gc (xc )⊤ νc =0 sc , νc ≥0 Andreas Grothey OPF contingency generation Combined point is in neighbourhood N (κ) Neighbourhood of the Central Path where N (κ) := {(x, λ, s) : Eµ (x, λ, s) ≤ κµ} Eµ (x, λ, s) := max k∇f (x) − ∇g (x)λ − sk∞ , kg (x)k∞ , kXS − µek∞ {z } | {z } | {z } | dual feasibility primal feasibility centrality Central Path conditions for SCOPF problem primal feasibility dual centrality P feasibility ⊤ KLc (u, xc ) =0 ∇f (u)− c ∇u KLc (u, xc ) λc =0 sc,i νc,i =µe gc (xc ) + sc =0 ∇x KLc (u, xc )⊤ λc +∇gc (xc )⊤ νc =0 sc , νc ≥0 Satisfied within κµ by construction Andreas Grothey OPF contingency generation Combined point is in neighbourhood N (κ) Neighbourhood of the Central Path where N (κ) := {(x, λ, s) : Eµ (x, λ, s) ≤ κµ} Eµ (x, λ, s) := max k∇f (x) − ∇g (x)λ − sk∞ , kg (x)k∞ , kXS − µek∞ {z } | {z } | {z } | dual feasibility primal feasibility centrality Central Path conditions for SCOPF problem centrality primal feasibility dual P feasibility ⊤ ∇f (u)− c ∇u KLc (u, xc ) λc =0 sc,i νc,i =µe KLc (u, xc ) =0 gc (xc ) + sc =0 ∇x KLc (u, xc )⊤ λc +∇gc (xc )⊤ νc =0 sc , νc ≥0 Residual is ∇u KLc (u, xc )⊤ λc for added contingency Andreas Grothey OPF contingency generation Combined point is in neighbourhood N (κ) Neighbourhood of the Central Path where N (κ) := {(x, λ, s) : Eµ (x, λ, s) ≤ κµ} Eµ (x, λ, s) := max k∇f (x) − ∇g (x)λ − sk∞ , kg (x)k∞ , kXS − µek∞ {z } | {z } | {z } | dual feasibility primal feasibility centrality Central Path conditions for SCOPF problem centrality primal feasibility dual P feasibility ⊤ ∇f (u)− c ∇u KLc (u, xc ) λc =0 sc,i νc,i =µe KLc (u, xc ) =0 gc (xc ) + sc =0 ∇x KLc (u, xc )⊤ λc +∇gc (xc )⊤ νc =0 sc , νc ≥0 Residual is ∇u KLc (u, xc )⊤ λc for added contingency ⇒ ok, if added while λc is small (compared to µk ) Andreas Grothey OPF contingency generation Statement of Algorithm Choose initial contingency set C0 ⊂ C. Choose µ0 repeat Do IPM iteration in the master problem to get approximate solution u k to (PC0 ,µk ). For all c ∈ C0 solve Vc,µk (u k ) approximately to get sck , λkc if kλkc k > 12 κµk for any c then set C0 ← C0 ∪ {c}. take combined solution of (PC0 ,µk ) and (Vc,µk (u k )) as starting point for next IPM iteration end if µk+1 = σµk until convergence in master problem Andreas Grothey OPF contingency generation Statement of Algorithm Choose initial contingency set C0 ⊂ C. Choose µ0 repeat Do IPM iteration in the master problem to get approximate solution u k to (PC0 ,µk ). For all c ∈ C0 solve Vc,µk (u k ) approximately to get sck , λkc if kλkc k > 12 κµk for any c then set C0 ← C0 ∪ {c}. take combined solution of (PC0 ,µk ) and (Vc,µk (u k )) as starting point for next IPM iteration end if µk+1 = σµk until convergence in master problem Approximate means a point in the neighbourhood N (κ) Andreas Grothey OPF contingency generation Statement of Algorithm Choose initial contingency set C0 ⊂ C. Choose µ0 repeat Do IPM iteration in the master problem to get approximate solution u k to (PC0 ,µk ). For all c ∈ C0 solve Vc,µk (u k ) approximately to get sck , λkc if kλkc k > 12 κµk for any c then set C0 ← C0 ∪ {c}. take combined solution of (PC0 ,µk ) and (Vc,µk (u k )) as starting point for next IPM iteration end if µk+1 = σµk until convergence in master problem Again a point in the neighbourhood N (κ). Usually only needs a single iteration in (Vc,µk (u k )) starting from the previous iterate. Andreas Grothey OPF contingency generation Statement of Algorithm Choose initial contingency set C0 ⊂ C. Choose µ0 repeat Do IPM iteration in the master problem to get approximate solution u k to (PC0 ,µk ). For all c ∈ C0 solve Vc,µk (u k ) approximately to get sck , λkc if kλkc k > 12 κµk for any c then set C0 ← C0 ∪ {c}. take combined solution of (PC0 ,µk ) and (Vc,µk (u k )) as starting point for next IPM iteration end if µk+1 = σµk until convergence in master problem The combined point is still in the N (κ) neighbourhood. ⇒ successful warmstart of enlarged problem. Andreas Grothey OPF contingency generation Regarding Convergence & Efficiency of Algorithm Issues warmstart is always successful (i.e. the patched point is in the N (κ) neighbourhood Andreas Grothey OPF contingency generation Regarding Convergence & Efficiency of Algorithm Issues warmstart is always successful (i.e. the patched point is in the N (κ) neighbourhood All active contingencies will be included eventually 1 since for active contingencies λc → λ∗c > κµ → 0 2 Andreas Grothey OPF contingency generation Regarding Convergence & Efficiency of Algorithm Issues warmstart is always successful (i.e. the patched point is in the N (κ) neighbourhood All active contingencies will be included eventually 1 since for active contingencies λc → λ∗c > κµ → 0 2 Contingency subproblems can be solved efficiently Contingency subproblem is just equation solving ⇒ only a single (usually) Newton step needed. ⇒ FDLF Andreas Grothey OPF contingency generation Regarding Convergence & Efficiency of Algorithm Issues warmstart is always successful (i.e. the patched point is in the N (κ) neighbourhood All active contingencies will be included eventually 1 since for active contingencies λc → λ∗c > κµ → 0 2 Contingency subproblems can be solved efficiently Contingency subproblem is just equation solving ⇒ only a single (usually) Newton step needed. ⇒ FDLF Only a very small fraction of contingencies needed only check for contingencies periodically. pre-screen and discard contingencies which are likely to never be active: Contingency Screening: Ejebe, Irisarri, Mokhtari (1995), Vaahedi, Fuchs, Xu, Mansour (1999), Capitanescu, Wehenkel (2007, 2008), Dent, Ochoa, Harrison, Bialek (2010) Andreas Grothey OPF contingency generation Contingency Generation: Results Prob 6bus IEEE 24 IEEE 48 IEEE 73 IEEE 96 IEEE 118 IEEE 192 Sce 2 38 78 117 158 178 318 Default time(s) iters <0.1 13 5.7 41 52.3 71 204.1 97 351.5 106 - >200 2393 132 Contingency Generation time(s) iters ActS <0.1 13 2 3.9 30 6 32.3 52 15 156.7 92 25 252.9 76 27 1225 75 46 1586 92 40 This is for the (nonlinear) (n − 1) AC-SCOPF problem Work in progress: currently scans all (inactive) scenarios at every iteration. Andreas Grothey OPF contingency generation Conclusions & Outlook Conclusions: “Active Contingencies” preconditioner is effective Only a few contingency scenarios are active at the solution ⇒ Contingency generation Contingencies can be added throughout IPM iterations without leaving ’safe’ neighbourhood. Andreas Grothey OPF contingency generation Conclusions & Outlook Conclusions: “Active Contingencies” preconditioner is effective Only a few contingency scenarios are active at the solution ⇒ Contingency generation Contingencies can be added throughout IPM iterations without leaving ’safe’ neighbourhood. Extension: Much further scope for efficiency gains (contingency screening, efficient load flow solver for subproblems) Transmission constraints and security planning will become increasingly important in future with decentralised and intermittent generation. Many operational and planning models in power systems (unit commitment, transmission switching/islanding) should take contingency constraints into account but currently do not (due to algorithmic complexity). Andreas Grothey OPF contingency generation Thank You! Andreas Grothey OPF contingency generation Bibliography M. Colombo, A. Grothey: A decomposition-based warm-start method for stochastic programming, Computational Optimization and Applications, Volume 55, Issue 2 (2013), Page 311-340. N.-Y. Chiang, A. Grothey: Solving Security Constrained Optimal Power Flow Problems by a Structure Exploiting Interior Point Method. Optimization and Engineering, published online February 2014. N.-Y. Chiang: Structure-Exploiting Interior Point Methods for Security Constrained Optimal Power Flow Problems, PhD Thesis, University of Edinburgh (2013). http://www.maths.ed.ac.uk/ERGO/preprints.html Andreas Grothey OPF contingency generation