Design of Process Operations using Hybrid Dynamic Optimization Paul I. Barton and Cha Kun Lee Department of Chemical Engineering Massachusetts Institute of Technology 77 Massachusetts Avenue Cambridge, MA 02139 FOCAPO 14th January 2003 Outline • Modeling, Simulation and Sensitivity Analysis of Process Operations as Hybrid Systems • Global Dynamic Optimization of Hybrid Systems • Examples Hybrid Systems • Hybrid systems exhibit both discrete state and continuous state dynamics Impulse All Vapor Two Phase All Liquid P > Pburst Intact Burst Pressure Vessel with Rupture Disk Tank with Impulsive Input Flash Vessel with Phase Transitions • Accurate dynamic models of process operations, e.g., start-ups and shut-downs are best analyzed using hybrid systems Modeling Process Operations • Increasing need for efficient, safe and environmentally friendly process operations • How will these improvements in process operations be achieved? • Detailed physical models, and rigorous analysis and optimization frameworks • Continuous process dynamics familiar, but as perturbation from steady-state becomes larger, discrete aspects become more and more important too • Hybrid Systems is the rigorous modeling paradigm for process operations Tank-Changeover Example min tf u(t),tf t t∗ Feasible Path CH4 (P1 ) N2 (P2 ) O2 (P3 ) N2 Explosive Region (P4 ) Pressure Vessel CH4 O2 Mole fraction space • Objective: Minimize the time needed to change from a tank full of methane to one full of oxygen Tank-Changeover Example f k = N k − C v Ak q Pk +P P √k −P 2 b+ Pk −P Laminar/ Turbulent P Pk f4 = N 4 − C v A4 (uk < 0.5) ∨ ( PPk ≥ 1) P4 P > 0.53 P Pk Choked Flow q P P +P4 √−P4 2 b+ P −P4 Laminar/ Turbulent > 0.53 P4 P (u4 < 0.5) ∨ ( PP4 ≥ 1) ≤ 0.53 ≤ 0.53 (uk > 0.5) ∧ ( PPk < 1) Zero Flow Choked Flow (u4 > 0.5) ∧ ( PP4 < 1) uk < 0.5 Zero Flow u4 < 0.5 fk = N k Pk f k = N k − C v Ak √ 0.85 2 f4 = N 4 f4 = N4 − Cv A4 √P2 0.85 Valve k ∈ {1, 2, 3} Valve 4 For all i ∈ I, f(4+i) = Mi0 − N1 y1i − N2 y2i − N3 y3i + N4 y4i f(7+i) = Mi − MT yi f(10+i) = y4i − yi f14 = y1 + y2 + y3 − 1 f15 = P V − MT RT Tank Tank-Changeover Example • Controls: on/off signals to valves as a function of time – infinite dimensional optimal control problem • Control parameterization leads to the following: – Initial positions of valves known – Allow position to switch at finite number of switching times – Continuous switching times decision variables in NLP – Embeds optimal control if sufficient number of switches allowed Control parameterization ∂x(p,t) ∂p Master NLP sets p Parametric Sensitivities Gradients Objective function, Constraints t x(p, t) u(p, t) Control Variables Hybrid System IVP t State Variables t Parametric Sensitivities of Dynamic Systems Given a dynamic system expressed in terms of a vector of time invariant parameters p: ẋ(p, t) = f (x(p, t), p, t) • then there exists a nx by np matrix of partial derivatives determined by the related matrix differential equations: ∂f ∂x ∂f ∂ ẋ = + ∂p ∂x ∂p ∂p • extension to DAEs straightforward ∂x ∂p Parametric Sensitivities of Hybrid Systems • [Galán et al. (1999)] • Existence and uniqueness for sensitivities of hybrid systems embedded with: – nonlinear ODEs – linear time invariant DAEs • In general, sensitivities of hybrid systems exist almost everywhere • Critical parameter values at which (for example) sequence of events changes qualitatively – theorems break down – typically associated with discontinuity or nondifferentiability in the objective function Direct Stochastic Search Objective function, Constraints NLP Solver sets p x(p, t) u(p, t) Control Variables Hybrid System IVP t State Variables t Results from Stochastic Search Valve Valve Signal Profiles Signal Profiles State Space Plot State Space Plot, Composition Space Values x 10 -3 Values Valve 3 Signal Explosive Limit 1.00 Valve 2 Signal 950.00 0.95 Valve 1 Signal 900.00 0.90 850.00 0.85 800.00 0.80 750.00 0.75 700.00 0.70 650.00 0.65 600.00 0.60 Y(N2) 550.00 0.55 500.00 0.50 450.00 0.45 400.00 0.40 350.00 0.35 300.00 0.30 250.00 0.25 200.00 0.20 0.15 150.00 0.10 100.00 0.05 50.00 0.00 0.00 -0.05 Time 0.00 50.00 100.00 150.00 200.00 250.00 Y(CH4) 0.00 0.20 0.40 0.60 0.80 1.00 Results from Stochastic search Pressures Flow Through Valves Pressures Flows Through Valves Values Values P [BAR] 12.00 P3 [BAR] 11.50 P2 [BAR] 60.00 N3 [MOL/S] N2 [MOL/S] N1 [MOL/S] 55.00 P1 [BAR] 11.00 P4 [BAR] 10.50 10.00 N4 [MOL/S] 50.00 45.00 9.50 9.00 40.00 8.50 35.00 8.00 7.50 30.00 7.00 6.50 25.00 6.00 5.50 20.00 5.00 15.00 4.50 4.00 10.00 3.50 3.00 5.00 2.50 2.00 0.00 Time 0.00 50.00 100.00 150.00 200.00 250.00 Time 0.00 50.00 100.00 150.00 200.00 250.00 Verification Problems The direct stochastic search approach • can deal with nonsmoothness in the master problem • cannot guarantee the global minimum, can be computationally expensive and can encounter difficulties with constraints These methods cannot be used for problems where location of the global minimum is crucial, e.g., formal verification of logic based controllers. LSH 3 LSH 4 Tank A Tank B ZSL 1 ZSH 1 ZSL 2 HS 1 pump on HS 7 Tank A level high LSH 3 start filling HS Tank A 1 ZSH 2 HS 2 stop filling Tank A HS 1 S R HV 1 ZSH 1 A A open valve valve open HV 2 ZSL 1 HV 2 HV 2 HS 7 start filling HS Tank B 2 S stop filling Tank B HS 2 R Tank B level high LSH 4 pump off HS 7 Feed Pump PSL 5 pump suct. PSL 5 press. low ZSH 2 open valve valve open HV 1 operate pump R stop pump OR close valve valve closed HV 1 S ZSL 1 A close valve valve closed OR DI 5s Other Approaches • Discrete time horizon [Bemporad, Borrelli and Morari (2000)] • Total discretization [Avraam, Shah and Pantelides (1998)] • Partial discretization – Solve directly as an NLP with hybrid system embedded ∗ Stochastic methods [Barton, Banga and Galán (2000)] ∗ Nonsmooth optimization methods – Reformulation of problem as a global Mixed-Integer Dynamic Optimization problem • Two stage decomposition of switched systems [Xu and Antsaklis (2001)] • Reachability analysis of hybrid automata [Alur et al. (1995)], [Shakernia, Pappas and Sastry (2000)] DAEPACK and ABACUSS II Software packages are available that can robustly handle simulation and sensitivity analysis of hybrid systems: • ABACUSS II / ABACUSS 3 – Advanced equation based modeling environment – Features include robust sensitivity analysis, sparsity pattern generation, interface to NLP solvers, etc. • DAEPACK – All structural symbolic and numerical information required by modern algorithms for hybrid systems can be generated automatically from a FORTRAN source file – Works with very general code: functions, subroutines, common blocks, iterative procedures, etc. • Very easy to get qualitatively wrong sensitivities using standard codes - must use our symbolic tools Outline • Modeling, Simulation and Sensitivity Analysis of Process Operations as Hybrid Systems – Hybrid systems framework is modeling paradigm for process operations – Interesting problems motivate development of global optimization methods • Global Dynamic Optimization of Hybrid Systems • Examples Motivation Problems that require the global minimum to be located motivate the development of tools for the deterministic global optimization of hybrid systems. A key tool is the ability to • construct convex relaxations for general, nonlinear Bolza type functions [Singer and Barton (2001)]: ´ Z tf ¡ ³ ¢ f ẋ(p, t), x(p, t), p, t dt F (p) = φ ẋ(p, tf ), x(p, tf ), p + t0 where x(p, t) is given by the solution of an embedded dynamic system described by linear time varying ODEs: ẋ(p, t) = A(t)x(p, t) + B(t)p + q(t) x(p, t0 ) = Ep + k • this has recently been extended to nonlinear ODEs embedded Hybrid Trajectories The time horizon is split into contiguous intervals called epochs: • Tµ , the sequence of modes, is called the hybrid mode trajectory • Tτ , the sequence of epochs, is called the hybrid time trajectory Mode 1 Mode 1 ẋ = −2x + p ẋ = −2x + p ẋ = x − 2p Mode 2 t t0 Epoch 1 I1 = [t0 , t1 ] t1 Epoch 2 I2 = [t01 , t2 ] Tµ = 1, 2, 1 t2 Epoch 3 I3 = [t02 , tf ] Tτ = I 1 , I 2 , I 3 tf Classes of Hybrid Optimization Problems • Tµ unchanged and vector field does not jump at events: – parametric sensitivities continuous (no jumps) – smooth Master NLP • Tµ unchanged: – parametric sensitivities discontinuous functions of time – smooth Master NLP • Tµ to be determined: – nonsmooth nonconvex Master NLP – decomposition approach - MIDO: Master problem searches over different sequences Convexity theory for fixed Tµ and Tτ • With Tµ and Tτ fixed, convexity theory holds and convex relaxations can be constructed. • Well-known methods for obtaining convex relaxations on Euclidean spaces can be employed, e.g., McCormick’s method, αBB. For example: Z 1 −x2 (p, t) dt F (p) = 0 U (p) = Z 1 (xL (t) + xU (t))(xL (t) − x(p, t)) − xL (t)2 dt 0 • This enables standard global optimization algorithms, such as Branch and Bound, nonconvex Outer Approximation, etc., to be applied. Example min F (p) = p∈[−4,4] Z 3 −x2 (p, t) dt, 0 where x(p, t) is given by the solution to the following hybrid system, Mode 1 : ẋ(p, t) = −2tx(p, t) + p, x(p, t) + p , t + 10 = {1, 2, 1}, and state continuity is enforced at t1 = 1, Mode 2 : ẋ(p, t) = x(p, 0) = 1, Tµ t2 = 2. 0 4 0 xL (t) −5 Value Value Value F (p) −5 xU (t) 2 0 −10 U (p) −15 −15 −2 0 1 2 3 −20 −4 −2 0 −10 2 4 −20 −4 −2 0 Time t Parameter p Parameter p (a) Implied State Bounds for p = [−4, 4] (b) Objective Function and Convex Underestimator (c) Branch and Bounding 2 4 Varying Sequence of Modes • Binary decision variables are introduced to represent the sequence of modes: Z 5 −x2 (p, y, t) dt, min F (p, y) = p,y s.t. y11 + y21 = 1, 0 y12 + y22 = 1, y13 + y23 = 1, where x(p, y, t) is given by the solution to the following hybrid system, µ ¶ x+p Mode 1 : ẋ(p, y, t) = y11 (−2tx + p) + y21 , t + 10 µ ¶ x+p , Mode 2 : ẋ(p, y, t) = y12 (−2tx + p) + y23 t + 10 ¶ µ x+p , Mode 3 : ẋ(p, y, t) = y13 (−2tx + p) + y23 t + 10 x(p, 0) = 1, p ∈ P = [−4, 4], y ∈ Y binary, Tµ = 1, 2, 3 and state continuity is enforced at t1 = 1 and t2 = 2. Hybrid Superstructure y11 y12 y1ne Mode 1 Mode 1 Mode 1 .. . .. . .. . yi1 z1 Mode i yi2 z2 Mode i .. . yine z3 zn e Mode i .. . .. . ynm 1 ynm 2 ynm ne Mode nm Mode nm Mode nm t t0 Epoch 1 n m P i=1 yi1 = 1 t1 Epoch 2 n m P i=1 yi2 = 1 t2 Epoch ne n m P i=1 yine = 1 tf MIDO Reformulation • Bilinear terms destroy LTV structure of hybrid system • Introduce nm × ne dynamic LTV systems: ẋmi (p, Z, t) = A(m) (t)xmi (p, Z, t) + B(m) (t)p + q(m) (t), ∀ m ∈ M, i = 1, . . . , ne , M is the set of nm modes, and ne is the total number of epochs • Introduce nx × ne additional parameters to represent initial conditions for each epoch: z1 = E 0 p + k 0 , zi = xmi (p, Z, t0i ), ∀ m ∈ M, i = 1, . . . , ne . • Bilinearities shifted to constraints: ! Ãn m X ymi xmi (p, Z, ti ) +Ei p+ki , ∀ i = 1, . . . , ne −1. zi+1 = Di m=1 MIDO Reformulation • Reformulated problem is a MIDO with a set of LTV ODE systems • Using nonconvex OA, MIDO is solved as a nonconvex MINLP • Ability to construct convex lower bounding MINLP is key, resulting in the following subproblems in OA: – Primal: noncovex NLP, provides upper bound – Primal Bounding: convex NLP, potentially reduces number of primal problems to solve – Relaxed Master: MILP, provides lower bound Nonconvex Outer Approximation [Kesavan and Barton (1999)] 1 k = 1, y given UBD = +∞ Primal Bounding Problem Convex NLPB(yk ) Is Primal Bounding Feasible? Yes New Integer Realization, yk k =k+1 No Integer Cut Primal Problem Nonconvex NLP(yk ) Solve for UBD Solve Feasibility Problem Derive Linearizations Yes Is Relaxed Master Feasible? No Global solution = UBD Relaxed Master Problem (MILP) NLP(yk ) and NLPB(yk ) can be solved in parallel Solving the MIDO • Exact linearizations can be obtained for bilinear/trilinear constraints introduced in the reformulation • Additional linearizations in the relaxed Master problem only have to be constructed for nonlinear terms in the objective function and constraints • Mode assignment constraints constitute S0S1 sets and can be exploited when solving the relaxed Master problem • It suffices to add only linearizations of the active constraints in the primal bounding problem to the relaxed Master problem not all nm × ne sets of dynamic systems have to be solved Outline • Modeling, Simulation and Sensitivity Analysis of Process Operations as Hybrid Systems – Hybrid systems framework is modeling paradigm for process operations – Interesting problems motivate development of global optimization methods • Global Dynamic Optimization of Hybrid Systems – Construct convex relaxations for LTV ODE hybrid system with Tµ and Tτ fixed – Reformulation into MIDO when Tµ is optimization parameter • Examples Catalyst Loading Problem • Given – an isothermal PFR at steady state, – 2 loading bays, – 3 possible kinds of catalyst on support, Section 1 Section 2 Isothermal, steady state PFR l=0 l=1 determine the optimal catalyst loading profile for the PFR that will maximize the profit. • This can be viewed as an optimization problem with a hybrid system embedded. • Optimal Tµ corresponds to the optimal choice of catalyst loading. Catalyst Loading Problem Section 1 Section 2 Isothermal, steady state PFR l=0 l=1 Reaction scheme A+B 1 I 2 4 W1 W2 Kinetics 3 P ẋA = −(k1 + k2 )xA ẋB = −(k1 + k2 )xB ẋW1 = k2 xA ẋI = k1 xA − (k3 + k4 )xI ẋW2 = k4 xI ẋP = k3 xI Catalyst Loading Problem xA (0) = 1000 xP (1) − 0.01xW1 (1) − 0.1xW2 (1) Section 1 Section 2 Catalyst k1 k2 k3 k4 1 2.098 1.317 0.021 0.033 2 29.53 110.2 3 182.6 2325 k1 /k2 k3 /k4 1 1.594 0.627 0.295 0.079 2 0.268 3.728 1.826 0.143 3 0.079 12.729 max xP (1) − 0.01xW1 (1) − 0.1xW2 (1) Tµ Tµ = 1, 3 F = 290.4 • For 10 catalyst sections, we get Tµ = 1, 1, 1, 1, 3, 3, 3, 3, 3, 3 with F = 296.5 Batch Reaction and Distillation • Building on the previous example, we consider a batch reaction and distillation problem: R1 R2 F1 Raw Material F2 D1 D2 Product and By-Product • The objective is to minimize raw material and waste treatment costs while maintaining a desired level of production of product. • Amount of raw material, recycle flows, and choice of catalyst are optimization variables. Each reactor’s run is for 1.5h. Batch Reaction and Distillation • Components B, W1 and P form a ternary and 2 binary azeotropes: B Region 3 Region 4 Azeotrope Composition W1 -P B-W1 -P B-W1 B Region 2 Region 5 0.72 0.35 0.65 W1 0.15 0.06 P 0.85 0.22 Region 1 W1 P Product Cut Sequence 1 : { A, W1 -P, W1 , I, B-W1 , W2 } 4 : { B, A, B-W1 -P, I, P, W2 } 2 : { A, W1 -P, B-W1 -P, I, B-W1 , W2 } 5 : { A, W1 -P, B-W1 -P, I, P, W2 } 3 : { B, A, B-W1 -P, I, B-W1 , W2 } Batch Reaction and Distillation • Process constraints: – molar solvent to reactant ratio (B, W1 , W2 : A, I) ≥ 15 – at least 2 times B in excess of A – 99% pure P • Optimal solution: (Cost of $5.061M to produce 300 kmol P) 540.5 I 1458.3 B-W1 -P 8107.2 B-W1 5.4 A 4634.3 W1 R1 R2 F1 F2 894.2 A R1: Catalyst 3 R2: Catalyst 1 D1 D2 1680.0 B D1: Region 1 D1: Region 4 445.2 B-W1 59.9 W2 875.0 B-W1 -P 20.0 W1 -P 280.0 P Batch Reaction and Distillation • Postulating a superstructure with 4 trains: R1 F1 D1 R2 Raw Material F2 D2 R3 F3 D3 Product By-Product R4 Fixed Points F4 D4 Batch Reaction and Distillation • Optimal solution: (Cost of $1.905M to produce 300 kmol P) 3.2 A 1565.0 B-W1 6061.1 W1 205.7 W1 12.9 W2 R1 541.2 A 541.2 B F1 Catalyst 1 D1 Region 1 311.4 I 22.6 W2 R2 F2 Catalyst 3 20.0 W1 -P D2 Region 4 280.0P 17.1 I 8.8 P 4928.2 W2 Conclusion • Modeling, Simulation and Sensitivity Analysis of Process Operations as Hybrid Systems – Hybrid systems framework is modeling paradigm for process operations – Interesting problems motivate development of global optimization methods • Global Dynamic Optimization of Hybrid Systems – Construct convex relaxations for LTV ODE hybrid system with Tµ and Tτ fixed – Reformulation into MIDO when Tµ is optimization parameter • Examples – Catalyst loading problem – Batch reaction and distillation problem Future Work • Varying Tτ • Development of convexity theory for nonlinear dynamic systems (done) • Extension of results for nonlinear hybrid systems Acknowledgments • This work was supported by the DoD Multidisciplinary University Research Initiative (MURI) program administered by the Army Research Office under Grant DAAD19-01-1-0566 • The National Science Foundation under Grant CCR-0208956 • The Engineering Research Program of the Office of Basic Energy Sciences at the U.S. DoE under Grant DE-FG02-94ER1444 • Adam B. Singer, supported by the National Science Foundation under Grant CTS-0120441