Gams Tutorial

March 30, 2018 | Author: Suyash Singh | Category: Nonlinear System, Petroleum, Mathematical Optimization, Finite Element Method, Loss Function


Comments



Description

A Brief GAMS TutorialL. T. Biegler Chemical Engineering Department Carnegie Mellon University Pittsburgh, PA GAMS Optimization Background Problem Statement Min F(x, y) s.t. h(x, y) = 0 g(x, y) ≤ 0 x ∈ℜnx, y ∈{0, 1}ny Problem Classes LP: MILP: NLP: MINLP: Approach Leverage powerful existing solvers Less emphasis on building algorithms More emphasis on model formulation and refinement 2 CPLEX, XPRESS, ZOOM CPLEX, XPRESS, ZOOM CONOPT, IPOPT, KNITRO, MINOS DICOPT, BONMIN 1 X. MODEL identify all equations in model_name SOLVE model_name USING problem_type MINIMIZING objective_variable Some Syntax Rules All statements end with semicolons.UP. versions •Easy to apply (and compare) different solvers •Syntax and logic checking prior to solver execution •Common output file for interpretation •Automatic differentiation of model •Closed system. =G=.lst) Optimization Solver •Common language across platforms.GAMS Structure GAMS Input File (name.L. external procedures hard to implement •Not much user interaction with solvers 3 Input File Syntax (name.gms) Essential Parts of File $TITLE State problem title here VARIABLES list variables here EQUATIONS list equations here ………………………. =E=.M qualifiers for variables Use these to bound variables. Problem Statement – state objective and constraint functions ……………………….gms) GAMS Compilation And Expansion GAMS Output File (name. X. except for objective_variable Comments denoted with ‘*’ 4 2 . conventions X. X.LO. =L=. 2] Input in test. con1..04*X1 . Model test /all/.3. x2. x1-x2**2 + x1**2 .l = 2. * initial point x1.. The objective function to be maximized is the profit ($/day) OBJ = 0.4 =E= 0.0. Solve test using NLP minimizing z. Equations con1. x3. x3. con2. x2.l = 4.063*X4*X7 . * upper bounds x1. con2.035*X2 .. x1-x3 =G= 0. x2-x3 =G= 0. x2 – x3 ≥ 0 x1 – x3 ≥ 0 x1 – x22 + x12 – 4 = 0 0 ≤ x1 ≤ 5 0 ≤ x2 ≤ 3 0 ≤ x3 ≤ 3 x0 = [4.lst 5 Alkylation Problem Consider the alkylation process shown below from Bracken & McCormick (1968) Isobutane Recycle X2 Olefin X1 Isobutane X 5 Fresh Acid X3 Reactor HydroCarbons Fractionator Spent Acid Akylate X4 Product X1 = Olefin feed (barrels per day) X2 = Isobutane recycle (barrels per day) X6 = Acid strength (weight percent) X7 = Motor octane number of alkylate The alkylation is derived from simple mass balance relationships and regression equations determined from operating data.l = 2. obj.5. Min x12 + x22 + x32 s.. x3.up = 5. 2.26 in Reklaitis et al (1983) Variables z.10*X3 .Introductory Example $TITLE Test Problem $OFFSYMXREF $OFFSYMLIST * Problem 8.up = 3. con3.gms See output in test. x2.t. obj. con3. Positive Variables x1.up = 3. z =e= sqr(x1)+sqr(x2)+sqr(x3).36*X5 6 3 . ..LO = 145.4 heat-oil 0. X8.2..12+.6.325*(X6-89.X5.. E2. E3.UP = 12. X9..L =12000.2 0.X8. X10.L =1745. X3.UP = 95.LO = 90.E2.LO = 3.22*X4-X1.X7=E=86.X9.04*X1-0.E7. OBJ =E= 0..L =8..UP = 16000.0067*X8**2).6 0. X2.X10=E=3*X7-133.0 0.2 0. X1. X6.L =110.UP = 2000.UP = 162.. X3. External Calcs Gasoline C1 C2 C3 Fuel Chain Heating Oil Jet Fuel C4 Lube Chain Lube Oil Product Yields for Crudes 1 2 3 4-fuel 4-lube gasoline 0.4 0. X7.36*X5.L =1974. E8.1 jet-fuel 0.L =92. X5.UP = 120.1 0.X8*X1=E=X2+X5.UP = 2000.038*X8**2+0. X6.X6*(X4*X9+1000*X3)=E=98000*X3. X4. X1.0 0.098*X8-0.. POSITIVE VARIABLES X1.3 0.X10.2 lube-oil 0.035*X2-10*X3-3.X4.LO = 1. X7.0 0. E5.2 0.Alkylation Problem – Input File $ TITLE ALKYLATION PROBLEM FROM GINO USER'S MANUAL $ OFFSYMXREF $ OFFSYMLIST OPTION LIMROW=0..X4=E=X1*(1.2. SOLVE ALKY USING NLP MAXIMIZING OBJ.222*X10. VARIABLE OBJ.X7.UP = 4.LO = 85.L =3048.2.35+1.3 0..82-0..L =145.X3.. E1.X5=E=1.. X8.2 0..). X10.13167*X8-0.E3.X9=E=35.X2. X8. X7...E5. E6. Index Notation.. X4. X6..UP = 5000.8..0 0.3 0.063*X4*X7-5. X10. MODEL ALKY/ALL/.UP = 93. OPTION LIMCOL=0. X9.X6. E4. E7.3 0. 8 4 . 7 Refinery Scheduling: Additional Features of GAMS: Sets.L =3. X5.E4.E8. X2. EQUATIONS E1.5 0.L =89.E6. X9. Q(P)*PVALUE(P)) .2 0.0.2.SUM(C. * Upper bounds on crude oil usages from their supplies X.5.0 0.0 0.0. heat-oil. DISPLAY X.0. YIELDS(P. 4-fuel.. * Define model and solve MODEL SCHEDULE /ALL/. TCOST(C) = CCOST(C) + OCOST(C). 2 8. TABLE YIELDS(P. POSITIVE VARIABLES X.6 0. X4 =E= X("4-fuel") + X("4-lube"). 4-lube 25.0 0. 10 5 .0. lube-oil 20. X4.UP = CSUPPLY("4-fuel"). TCOST(C)*X(C)). 4-lube 2.5 0. 9 Refinery Scheduling: Problem Statement * Define the optimization variables VARIABLES X(C) Crude oils used in kbbl per week Q(P) Amounts of products produced in kbbl X4 Total amount of crude 4 used in kbbl PROFIT Total profit from product sales in k$.0/ PVALUE(P) Product Values in $ per bbl / gasoline 45. 4-lube 200.L.3 0.0/ OCOST(C) Crude operating costs in $ per bbl / 1 5.0. kbbl per wk /gasoline 170.0. * Define index sets SETS C Crudes /1*3.0 0.0..0.L. 2 100.2 0.3 0.0. 3 15.0. heat-oil 85. C) Yields of products for crudes 1 2 3 4-fuel 4-lube gasoline 0. PRODUCTION(P).4 heat-oil 0. SOLVE SCHEDULE USING LP MAXIMIZING PROFIT.Refinery Scheduling: Problem Data $TITLE Refinery Scheduling $OFFUPPER $OFFSYMXREF OFFSYMLIST *OPTION SOLPRINT = OFF.50/ TCOST(C) Total costs: crude plus operating. 4-fuel 3.2 lube-oil 0.0. jet-fuel. 2 15. CRUDE4. PROFIT =E= SUM(P.1 jet-fuel 0. OBJFUN.UP(C) = CSUPPLY(C).0.1 0. 4-lube/ P Products /gasoline. lube-oil/ *Define and initialize the problem data PARAMETER CSUPPLY(C) Crude oil supply kbbl per wk / 1 100. jet-fuel 85. PROFIT. Q. 4-fuel 200.3 0. Q(P) =E= SUM(C. * Define constraints and objective function EQUATIONS OBJFUN Objective function to be maximized CRUDE4 Total crude 4 usage PRODUCTION(P) Amounts of products produced.UP(P) = PDEMAND(P).5. heat-oil 30.. 4-fuel 25.2 0.0.0.2 0. * Define upper and lower bounds * Upper bounds on amounts of product produced from their maximum demands Q.C)*X(C)).3 0. lube-oil 60.0/ PDEMAND(P) Maximum product demands. Q. 3 100. X4.0.4 0.0/ CCOST(C) Crude oil costs in $ per bbl /1 15. jet-fuel 15.0. 3 7.L. Power Generation via Fuel Oil Fuel Oil Generator 1 Power (50 kW) Blast Furnace Gas Generator 2 Minimize Fuel Oil Consumption Fuel (oil or BFG) = A0 + A1*Power+A0*(Power)2 Coefficients in the fuel consumption equations A0 gen1(oil) gen2(oil) gen2(gas) 1.0.0/.001358 gen2. PARAMETER PMAX(G) Maximum power outputs of generators / GEN1 30.15186 .000778.4609 gen1(gas) 1.oil 1.20310 .7266 .0/.16310 .oil 0.00145 gen1.0/.000916 . gas/ K Constants in Fuel Consumption Equations /0*2/. PARAMETER PMIN(G) Minimum power outputs of generators / GEN1 18.gas 1.15186 .00145 . * Define and Input the Problem Data TABLE A(G. 11 Power Generation via Fuel Oil: Problem Data $TITLE Power Generation via Fuel Oil $OFFUPPER $OFFSYMXREF OFFSYMLIST *OPTION SOLPRINT = OFF.000916 gen2.16310 .K) Coefficients in the fuel consumption equations 0 1 2 gen1. GEN2 14.gas 0. SCALAR GASSUP Maximum supply of BFG in units per h /10. GEN2 25. * Define index sets SETS G Power Generators /gen1*gen2/ F Fuels /oil.8008 .000778.4609 .22560 .8008 0.20310 .7266 A1 .5742 .22560 A2 .F. 12 6 .0/ PREQ Total power output required in MW /50.5742 0.001358 .0. X. P.F)). F) Power outputs of generators from specific fuels Z(F) Total Amounts of fuel purchased OILPUR Total amount of fuel oil purchased..L. P(G) =E= SUM(F.. Z(F) =G= SUM((K.Power Generation via Fuel Oil: Problem Statement * Define optimization variables VARIABLES P(G) Total power output of generators in MW X(G.G). OILPUR =E= Z("OIL"). SOLVE FUELOIL USING NLP MINIMIZING OILPUR. FUELUSE(F).. * Define model and solve MODEL FUELOIL /all/. P(G)) =G= PREQ. * Specify initial values for power outputs P. 13 Suggested GAMS Exercises •Refinery Scheduling – make product demands lower bound requirements • Maximize profit • Minimize operating cost •Fuel Oil – Restrict fuel oil supply to 10 ton/h.L.UP("gas") = GASSUP. Z.F. a(G.F)**(ORD(K)-1)).UP(G) = PMAX(G). DISPLAY X.LO(G) = PMIN(G). OILPUR. PWR(G).K)*X(G. * Upper bound on BFG consumption from GASSUP Z. * Impose Bounds and Initialize Optimization Variables * Upper and lower bounds on P from the operating ranges P.L. * Define Objective Function and Constraints EQUATIONS TPOWER Required power must be generated PWR(G) Power generated by individual generators OILUSE Amount of oil purchased to be minimized FUELUSE(F) Fuel usage must not exceed purchase.5*(PMAX(G)+PMIN(G)).L(G) = . • Minimize BFG purchased • Minimize BFG and Fuel Oil purchased •Alkylation – Add relaxation variables between bounds and reformulate problem 14 7 . P. purchase BFG. Z. X(G. TPOWER.L.. POSITIVE VARIABLES P. OILUSE. SUM(G. algebraic variables Carnegie Mellon tf. p ) = 0 z o = z(0 ) z y u p l l l l ≤ z(t ) ≤ z u u u ≤ y(t) ≤ y ≤ u(t ) ≤ u ≤ p ≤ p u t. u(t). p ) dt G(z (t ). y (t ). u (t ). t f ) s. p. differential variables y. Equilibrium (physical properties. hydraulics. Momentum) Algebraic Equations •Constitutive Equations. Energy.Dynamic Optimization Problem min ψ (z(t). final time u. t . time z. y(t). time independent parameters DAE Models in Engineering Differential Equations •Conservation Laws (Mass.t. y(t ). rate laws) Characteristics •Large-scale models – not easily scaled •Sparse but no regular structure •Direct solvers widely used •Coarse-grained decomposition of linear algebra Carnegie Mellon 8 .u (t ).t . dz (t ) = F (z (t ). control variables p. l≠ j ∑ l (τ )u j ij l j (τ ) = ∏τ τ −τ j l −τ j Differential variables Continuous Carnegie Mellon Algebraic and Control variables Discontinuous 9 .τ ∈ [0.1] i '=1 Finite element.Nonlinear Programming Formulation Nonlinear Dynamic Optimization Problem Continuous variables Collocation on finite Elements Discretized variables Nonlinear Programming Problem (NLP) Carnegie Mellon Collocation on Finite Elements True solution • • • • • Polynomials • • • • • • • × × × × • × × × × × × αi × × to ti Collocation points i −1 tf tij = ∑ α i ' + α iτ j . i element i Mesh points × × j=2 × z(t) = j=1 × × × y(t) = × NCOL × (τ )y ij × × × NCOL j=1 × NCOL l j (τ ) = NCOL l =0. l≠ j ∏τ τ −τ j l −τ j ∑l j= 0 j (τ )z ij ∑l j=1 j u(t) = NCOL l =1. t. j . p ) l k j ik i ij ij ij G (zi . NCOL Carnegie Mellon Example: Car Problem Min tf s. t Time. p ) = 0 NCOL z i + 1 . z 1' = z 2 z 2' = u z2 ≤ zmax -2 ≤ u ≤ 1 Carnegie Mellon Acceleration. u(t) Velocity. j . j pl ≤ p ≤ pu i = 1. z2(t) Velocity.0 = o ∑ j=0 l j ( 1 )z ij 0 z1 = z( 0 ). y . j ≤ ui...ui . j = 1. t 10 . u(t) Acceleration. j .. j .y i. j ui.t c( x) = 0 x L ≤ x ≤ xu y i . z f = z i +1 zi ≤ zi . ∑ k=0 & (τ ) z = α F ( z .j . j ≤ y i.. z2(t) Time.t f NCOL ) min f ( x) n x∈ℜ s.j ..u i. u .j ≤ y i . j ≤ zi l l l u u u s. yi . NFE.p.Nonlinear Programming Problem min ψ (z i . j ≤ ui.t.. ncol . SU(i.j) = YES $ ( (ORD(i) LE nfe) $ (ORD(j) EQ ncot) ) .JJ. pt used /2/ .i) = YES $ ( (ORD(k) LE nk) $ (ORD(i) EQ nfe) ) .j) actual dim of control variable .i. SRES(i. *************************************************** ***** 11 . SCALAR NCOF equal to ncol+1 . nk . data-driven program in Windows. more elegant set notation and conditional statements.jp) actual dim of PHIPR .j) = YES $ ( (ORD(i) LE nfe) $ (ORD(j) GT 1) $ (ORD(j) LE ncof) ) . SET SRES(i. uses IPOPT and ADOL-C Carnegie Mellon Dynamic Optimization: GAMS Define Sets and Conditional Sets • • • • • • • • • • • • • • • • • • • • • • • Carnegie Mellon $TITLE The Car Problem: Minimum Time for a Fixed Distance $OFFUPPER $OFFSYMXREF OFFSYMLIST $OFFDIGIT * This program is the GAMS formulation of the car problem ************************************************** ****** SETS K equation # (max 10) /K1*K10/ I finite elements # (max 20) /I1*I20/ J collocation coeff. SUPRO(i) = YES $ (ORD(i) LE nfe) .KP) (J.jp) = YES $ ( (ORD(k) LE nk) $ (ORD(i) LE nfe) $ (ORD(jp) LE ncof) ) . SET SALF(i) actual dim of alpha . ABORT $ (nfe GT 20) "Error in defining NFE (max 20)".jp) actual dim of coll. ************************************************** ****** SCALARS NK actual # of equations /2/ NFE actual # of FE used /2/ NCOL actual # coll. ************************************************** ****** ABORT $ (nk GT 10) "Error in defining NK (max 10)".JS) . SPHIPR(j. • • • • • • • • • • • • • • • • • • • • • • • • • • • • SET SXCOL(k. SET SDPHI(jp) actual dim of dominator of PHI . SERR(i. SXEND(k. SDPHI(jp) = YES $ ( (ORD(jp) LE ncof) ) . general formulation with all collocation equations • DynoPC – requires only statement of model. nfe . (XCOL) . SET SXEND(k. SCALAR NCOT equal to ncol+2 .j) = YES $ ( (ORD(i) LE nfe) $ (ORD(j) GT 1) $ (ORD(j) LE ncof) ) . SCONT(k.i) = YES $ ( (ORD(k) LE nk) $ (ORD(i) GT 1) $ (ORD(i) LE nfe) ) .j) actual dim of residual eq . SET SPHIPR(j. SET SERR(i.JP.j) actual dim of error eq .Dynamic Optimization: Methods of Solution • GAMS – requires complex set notation and conditional statements. general formulation with all collocation equations • AMPL – similar to GAMS. ABORT $ (ncol GT 3) "Error in defining NCOL (max 3)". SXCOL(k. coeff.i) actual dim of continuity eq .i. SET SU(i. NCOF = ncol+1 . SET SUPRO(i) dim of contol profile .i) end condition for state variables .jp) = YES $ ( (ORD(j) GT 1) $ (ORD(j) LE ncot) $ (ORD(jp) LE ncof) ) . SET SCONT(k. NCOT = ncol+2 . # /J1*J5/ COL # possible coll pt (max 3) /C1*C3/ ALIAS (K. SALF(i) = YES $ (ORD(i) LE nfe) . tau(jp))/ (tau(j) . • • • • • • • • • • • 1.JP) = SUM (JS $ ( (ORD(JS) LE ncof) $ (ORD(JS) NE ORD(JP)) ). ( (1.TAU(JJ)) )) / DPHI(JP) ..jp)*PHIPR(j.j) residual equations for eq 2 ECONT(k. XCOL(k.j) lower bounds for error control eq 2 EERR2U(i.j) $ SRES(i.211324865405187 .jp)*PHIPR(j. *______________________________________________________ _ TABLE GENTAU(col.j) upper bounds for error control eq 2 EULO(i) lower bounds for control profile EUUP(i) upper bounds for control profile EOBJ objective function . .i) end conditions EERR1L(i.tau(jp)) ) ) ) .1127016653792585 J4 J5 1. (TAU(JP) . XCOL('K2'.j) control variables OBJ objective function . XCOL('K1'..i. SUM(jp $ (ORD(jp) LE ncof). . PROD(JJ $ ( (ORD(JJ) LE ncof) $ (ORD(JJ) NE ORD(JP)) $ (ORD(JJ) NE ORD(JS)) ).i) .jp) the roots of Lagrange polyn.i) .j) .j) .. ********************************************** **** EQUATIONS ERES1(i.i.tau(jp)) ) ) ) . XEND(k.j)* PROD(jp $ (ORD(jp) NE ORD(j) AND ORD(jp) LE ncof).j) residual equations for eq 1 ERES2(i.i.i.5 *______________________________________________________ _ Carnegie Mellon •Dynamic Optimization: GAMS Define Variables and Equations • • • • • • • • • • • • • • • • • • • ********************************************** *** VARIABLES XCOL(k.i) $ SCONT(k. XCOL(k. ******************************************************** C1 C2 C3 + C2 C3 J2 J3 .j) upper bounds for error control eq 1 EERR2L(i.0 .jp) $(ncol EQ 2) + gentau('C3'.'J1') =E= SUM(j $ (ORD(j) LE ncof).5 1.j) ) =E= 0 . • • • • • • • • * Assign tau according to the specified NCOL TAU(jp) $ ( ORD(jp) LE ncot) = gentau('C1'.i-1.i) continuity equations EXEND(k.j) lower bounds for error control eq 1 EERR1U(i.0 . * continuity equations ECONT(k. *_______________________________________________________ * Calculate DPHI (needed for calculating PHIPR) DPHI(JP) $ SDPHI(JP) = PROD(J $ ( (ORD(J) LE ncof) $ (ORD(J) NE ORD(JP)) ). XCOL(k. . Carnegie Mellon ( (1. (TAU(J) .i) =E= SUM(j $ (ORD(j) LE ncof).i.JP) $ SPHIPR(J.tau(jp))/ (tau(j) . SUM(jp $ (ORD(jp) LE ncof).i.j) $ SRES(i.jp) $(ncol EQ 1) + gentau('C2'.j) ) =E= 0 .jp) ) ALPHA(i) * ( U(i.jp) $(ncol EQ 3) . * residual equations for eq 2 ERES2(i.Dynamic Optimization: GAMS Define Problem Data • • • • • • • • • • • • • • PARAMETERS TAU(jp) tau at specified ncol PHIPR(j..i) $ SXEND(k. *_______________________________________________________ * Calculate PHIPR (1-st derivative of PHI) PHIPR(J.TAU(J)) ) . 12 .jp) ) ALPHA(i) * ( XCOL('K2'. * end condition equations EXEND(k. *_____________________________________________ ___ • • • • • • • • • • • • • • • • • • • • • • * residual equations for eq 1 ERES1(i.jp) collocation coefficients XEND(k.j)* PROD(jp $ (ORD(jp) NE ORD(j) AND ORD(jp) LE ncof).788675134594813 .jp) 1-st deriv of phi DPHI(jp) dominator of phi .8872983346207415 .i) state variable at the end condition ALPHA(i) time at i-th finite element U(i. U(i.jp) = 150 .UP('K1'..j) $ SERR(i.i.i) $ SXEND('K1'.j) = 1. U. XCOL.j) . U.i.'I1'.jp) = 300 .lower bounds EERR2L(i.'J1') = 0 .i.L(i.jp)*PHIPR(j.i.tau(js))/(tau(jp) . XCOL.jp)* PROD(js $ (ORD(js) NE ORD(jp) AND ORD(js) LE ncof).tau(js))/(tau(jp) .jp) = 100 .LO(i. ( (1.j) $ SU(i.L('K1'.i.tau(js)) ) ) ) =L= 1.j) $ SU(i.i. parameters.FX('K1'.tau(js))/(tau(jp) .0E-2 .1. ( (1.tau(js)) ) ) ) =L= 1.jp) ) ALPHA(i) * SUM(jp $ (ORD(jp) LE ncof).0 . ALPHA.i.UP(i) $ SALF(i) = 50 .0 . Initialization. ALPHA.jp) $ SXCOL('K1'. XCOL. states OPTION NLP = MINOS5 .L(i) = 10 .i. ALPHA.tau(js)) ) ) ) =L= 1 . SUM(jp $ (ORD(jp) GT 1 AND ORD(jp) LE ncof).j) .jp) $ SXCOL('K1'.i) = 300 . not variables SOLVE PROBLEM1 USING NLP MINIMIZING OBJ .i.0 .j) $ SERR(i.jp)* PROD(js $ (ORD(js) NE ORD(jp) AND ORD(js) LE ncof). OPTION LIMCOL = 0 .jp) = 5 .i.jp)* PROD(js $ (ORD(js) NE ORD(jp) AND ORD(js) GT 1 AND ORD(js) LE ncof).1 ..i.i) $ SXEND('K2'.jp)* PROD(js $ (ORD(js) NE ORD(jp) AND ORD(js) GT 1 AND ORD(js) LE ncof).0E-2 . U(i.tau(js)) ) ) ) =G= . OBJ =E= SUM(i $ SALF(i).j) = . XCOL('K1'. U(i. XCOL('K1'.UP('K2'. U(i. SUM(jp $ (ORD(jp) LE ncof).jp) = 0 .j) $ SERR(i.FX('K2'. XCOL('K2'. • • • • • • • • • • • • • • • • • • • * lower bounds for control profile EULO(i) $ SUPRO(i) .i. XCOL('K2'. XCOL('K2'.. SUM(jp $ (ORD(jp) LE ncof). * final conditions XEND.jp) $ SXCOL('K2'.1.i) = 0 * starting points XCOL.jp)*PHIPR(j. * upper bounds EERR1U(i.tau(js))/(tau(jp) .jp)*PHIPR(j.jp)* PROD(js $ (ORD(js) NE ORD(jp) AND ORD(js) GT 1 AND ORD(js) LE ncof). ALPHA(i) ) .jp) ) ALPHA(i) *SUM(jp $ (ORD(jp) LE ncof).2 .L('K1'.'I1'. •Compare with finite elements as OPTION LIMROW = 50 .. 13 .0 .jp) $ SXCOL('K2'. ( (0 .tau(js))/(tau(jp) .jp) ) ALPHA(i) * SUM(jp $ (ORD(jp) GT 1 AND ORD(jp) LE ncof).j) = .. XCOL.jp)*PHIPR(j.j) $ SERR(i. SUM(jp $ (ORD(jp) GT 1 AND ORD(jp) LE ncof). *_______________________________________________________ * the objective function EOBJ .0 .LO(k.i.FX('K1'. U. Example illustrates: •GAMS structure/language for complex problem formulations •AMPL language is much simpler •DynoPC makes problem setup much easier Similar input files for •Catalyst mixing (CATMIX) •Parameter estimation (PARAM) Suggested Exercises •Run all three files •Change NCOL and NFE ******************************************************* •Modify bounds on controls and * MODEL PROBLEM1/ALL/ . * upper bounds EERR2U(i. SUM(jp $ (ORD(jp) LE ncof).0E-2 .jp)* PROD(js $ (ORD(js) NE ORD(jp) AND ORD(js) GT 1 AND ORD(js) LE ncof). *_______________________________________________________ * upper bounds for control profile EUUP(i) $ SUPRO(i) .tau(js)) ) ) ) =G= .0E-2 . XCOL('K2'.i. SUM(jp $ (ORD(jp) LE ncof).'J1') = 0 . Carnegie Mellon Dynamic Optimization: GAMS Define Bounds. ( (1. ( (1. Model… • • • • • • • • • • • • • • • • • • • • • • • • Carnegie•Mellon * Bounds on variables XCOL.tau(js)) ) ) ) =G= .0 . ( (1.tau(js))/(tau(jp) .jp) $ SXCOL(k.j) .2.j) ..i.UP(i.j) $ SU(i.FX('K2'.jp) ) ALPHA(i) *SUM(jp $ (ORD(jp) GT 1 AND ORD(jp) LE ncof). * initial conditions XCOL.LO(i) $ SALF(i) = 1 . XEND. * error equations for eq 2 .0 .i.Dynamic Optimization: GAMS Define Error Equations (optional) • • • • • • • • • • • • • • • • • • • • • • • • • • • • • * error equations for eq 1 ..lower bounds EERR1L(i.
Copyright © 2024 DOKUMEN.SITE Inc.