GAMS Example 3

← ChE 477: Process Optimization

$OFFSYMLIST OFFSYMXREF OFFUELLIST OFFUELXREF
OPTION DECIMALS=5, LIMROW=0, LIMCOL=0, SYSOUT=OFF, SOLPRINT=OFF;
* --------------------
* CHE 478 - EXAMPLE 3:     prepared by: Dr. Ugur Akman, Assoc. Prof.
* --------------------
*           Linear Programming (LP)
*           minimize f(X) = 2*X1 - X2
*            s.t.   h1(X) =   X1 - 2*X2 -  2 = 0
*                   g1(X) =   X1 +   X2 -  2 > 0
*                   g2(X) = 2*X1 + 3*X2 - 12 < 0
*                      X1 > 0    (X1 is a positive variable)
*                      X2 > 0    (X2 is a positive variable)
*
*                    f(X) : objective function (OBJ)
*                   X1,X2 : decision variables
*                      h1 : equality constraint
*                      g1 : first inequality constraint
*                      g2 : second inequality constraint
*

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

* Define the positive variables in the optimization model
* i.e., nonnegativity constraints
  POSITIVE VARIABLES X1, X2 ;

* Define the equations of the optimization model
* i.e., objective function equation (OBJECT),
*       constraint equations (H1,G1,G2),
  EQUATIONS  OBJ , H1 , G1 , G2 ;

* Enter the equations
  OBJ ..           F =E= 2*X1 - X2 ;
  H1  ..   X1 - 2*X2 =E=  2 ;
  G1  ..   X1 +   X2 =G=  2 ;
  G2  .. 2*X1 + 3*X2 =L= 12 ;

* Solve the optimization model using all equations
* i.e., solve the equations defined by model name EXPML3
*       using linear programming (LP) by minimizing obj. fct.
  MODEL EXMPL3 /ALL/ ;
  SOLVE EXMPL3 USING LP MINIMIZING F ;

* Display the values of the variables at the optimal solution
  DISPLAY  F.L ;
  DISPLAY X1.L ;
  DISPLAY X2.L ;
  DISPLAY H1.L ;
  DISPLAY G1.L ;
  DISPLAY G2.L ;