GAMS Example 2

← ChE 477: Process Optimization

$OFFSYMLIST OFFSYMXREF OFFUELLIST OFFUELXREF
OPTION DECIMALS=5, LIMROW=0, LIMCOL=0, SYSOUT=OFF, SOLPRINT=OFF;
* --------------------
* CHE 478 - EXAMPLE 2:     prepared by: Dr. Ugur Akman, Assoc. Prof.
* --------------------
*           minimize f(X) = (a*X1 - b)^c + (d*X2 - e)^f
*             s.t.   X1min < X1 < X1max
*                    X2min < X2 < X2max
*
*                     f(X) : objective function (OBJ)
*                    X1,X2 : decision variables
*                    X1min : lower bound on X1
*                    X1max : upper bound on X1
*                    X2min : lower bound on X2
*                    X2max : upper bound on X2
*

* Define the constants in the optimization model
  SCALAR
  A   /  2. /
  B   / -1. /
  C   /  2. /
  D   /  4. /
  E   /  2. /
  F   /  2. /
  X1MIN / -2. /
  X1MAX /  4. /
  X2MIN / -1. /
  X2MAX /  5. / ;

* Define the variables in the optimization model
  VARIABLES
  X1 , X2 , OBJ ;

* Enter the simple bounds on variables
  X1.LO = X1MIN ;
  X1.UP = X1MAX ;
  X2.LO = X2MIN ;
  X2.UP = X2MAX ;

* Define the equations of the optimization model
* i.e., objective function equation (OBJECT),
  EQUATIONS
  OBJECT ;

* Enter the initial guesses for the variables
* INITIAL GUESS
  X1.L = 3. ;
  X2.L = 2. ;

* Enter the equations
  OBJECT  ..   OBJ =E= (A*X1-B)**C + (D*X2-E)**F ;

* Solve the optimization model using all equations
* i.e., solve the equations defined by model name EXPML2
*       using nonlinear programming (NLP) by minimizing obj. fct.
  MODEL EXMPL2 /ALL/ ;
  SOLVE EXMPL2 USING NLP MINIMIZING OBJ ;

* Display the values of the variables at the optimal solution
  DISPLAY  X1.L ;
  DISPLAY  X2.L ;
  DISPLAY OBJ.L ;