W Wor Orks Ksho Hop 08 P08 Iintrod Ntroductio Uction To Proce N To Process Ss O Opt Ptim Imiza Izati Tion On Iin NG Gams Ams® ®

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 29

Works

or ksho
hopp 08  – Introductio
ntrod uction
n to Process
Process
Optim
pt imiza
izati
tion
on In GAMS®
AMS®

Jorge Mario Gómez R., Ph.D.


 Associate Professor 
OPTIMIZATION OF CHEMICAL
PROCESSES WORSHOP
Contents
GAMS®
Workshop 08  – Introduction to Process Optimization In GAMS®
• Introduction to o ptimization in GAMS®
GAMS®
• GAMS Structure
• Precedents in GAMS optimization
• Syntax of an input file (name.gms)
• Trucks problem
• Problem
• Problem formulation
• Solution
• Bonus
References
GAMS®
Introduction to Optimization in GAMS®

• General Algebraic Modeling System (GAMS)


• Modeling system for mathematical programming and optimization.
• Free licence limited to 300 variables and 300 constraints.
• A large amount of availiable solvers.
• It has a large library with a lot of examples.
• It allows to solve most of the problems that arise in optimization.
• Intuitive transcription of the “ paper  formulation into the GAMS code.

• http://www.gams.com
GAMS®
GAMS® Structure

Compilation and
Input GAMS file Output GAMS file
expansion in
(NAME.gms) (NAME.lst)

Solver

• Common language through platforms and versions.


• Easy application of different solvers.
• Sintax and logic revision previous to solving.
• Easy interpretation of the output files.
• Almost none interaction of the user and the solver .
GAMS®
GAMS® Structure

• Problem formulation:
min
,  (,)
s.t. ℎ , = 0
 , ≤ 0
  ℝ,  ℤ
• Sorts of problems: Solvers
LP: CPLEX, XPRESS, CBC.
MIP: CPLEX, XPRESS, CBC.
NLP: CONOPT, IPOPT, KNITRO, MINOS.
MINLP: DICOPT, BONMIN,SCIP.

•   Focus:
It takes advantage of the power of the existing solvers.
Less emphasis in the building of algorithms.
More emphasis in the formulation of the model and its refinement.
GAMS®
GAMS® Structure

“…This task requires the following elements:


Sets
Parameters
Variables
Constraints
Objective function…”  Page 1 in [1]

Parts of an optimization problem  Input in GAMS


• Sets indexes  SET
• Given data  PARAMETERS
• Decision variables  VARIABLES
• Constraints  EQUATIONS
• Objective function  EQUATION
GAMS®
Syntax of in Input File

Essential parts of a *.gms file

SETS Problem sets;


PARAMETERS Problem parameters;
VARIABLES Problem variables;
EQUATIONS Problem equations;

-------------------------------------------------------------
Problem formulation The objective function and the constraints are
 formulated here;
-------------------------------------------------------------

MODEL name of the model /equations included in the model/;

SOLVE name of the model USING sort of problem MINIMIZING/MAXIMIZING


objective variable;
GAMS®
Syntax of in Input File

• All declarations finish with a “;”.


• “EQUATIONS” stands for equality and inequality constraints
o =E= equal than.
o =G= greater or equal than.
o =L= less or equal than.
• Take a look at the GAMS User’s Guide at Google for information about
Mathematical functions. For example: Exponentiation
o power(x,n);   ℝ,  ℤ →  ∗  ∗ ⋯∗   
o x**m;  > 0,  ℝ → exp  ∗ ln 
o sqr(x);   ℝ →  ∗  2 
• Variable attributes: x.LO, x.UP, x.L.
o These attributes are used to define the variable bounds and their
initialization, except for the objective variable variable_funobj.

• Comments with ‘*’ at the begining of the line


GAMS®
Syntax of in Input File

SOLVE name of the model USING sort of problem MINIMIZING/MAXIMIZING


objective variable

lp For linear programming


qcp For quadratic constraint programming
nlp For nonlinear programming
dnlp For nonlinear programming with discontinuous derivatives
mip For mixed integer programming
rmip For relaxed mixed integer programming
miqcp For mixed integer quadratic constraint programming
minlp For mixed integer nonlinear programming
rmiqcp For relaxed mixed integer quadratic constraint programming
rminlp For relaxed mixed integer nonlinear programming
mcp For mixed complementarity problems
mpec For mathematical programs with equilibrium constraints
cns For constrained nonlinear systems
GAMS®
Syntax of in Input File

SOLVE name of the model USING sort of problem MINIMIZING/MAXIMIZING


objective variable
GAMS®
Syntax of in Input File

SOLVE name of the model USING sort of problem MINIMIZING/MAXIMIZING


objective variable

Default solver for


nlp is ipopt;
GAMS®
Trucks Problem - Problem

Before starting!!! Create a new project (File/Project/New Project).


GAMS®
Trucks Problem - Problem

 A tracking company has borrowed $600.000 for new equipment and is


contemplating three kinds of trucks. Truck A costs $10.000, truck B $20.000,
and truck C $23.000. How many trucks of each kind should be ordered to
obtain the greatest capacity in ton-mile per day base on the following
data? 

• Truck A requires one driver per day and produces 2.100 ton-miles per 
day 
• Truck B requires two drives per day and produces 3.600 ton-miles per 
day 
• Truck C requires two drives per day and produces 3.780 ton-miles per 
day 
• There is a limit of 30 trucks and 145 drives.

Reference [1], Problem 1.8, Page 29.


GAMS®
Trucks Problem  – Problem Formulation

Sets:
 = ,, Let be  the set containing the types of truck. Index 
Scalars
_: Maximum resources, [$]
_: Maximum of trucks, [-]
_: Maximum of drivers, [-]

Parameters
_  : Purchase cost by truck type, ∈ [$]
_  : Drivers required for each type of truck, ∈ [-]
_  : Production by truck type, ∈ [ton-miles per day]

Variables:
  ∈ ℤ+ : Number of trucks by truck type, ∈ [-]
: Total production per day, [ton-miles/day]
GAMS®
Trucks Problem  – Problem Formulation

Constraints:
_: Maximum drivers; [-]

 _  ∗   ≤ _
∈
_: Maximum of trucks; [-]

   ≤ _
∈
_: Maximum cost; [$]

 _  ∗   ≤ _
∈
Objective function:
_: Total Maximum production, [ton-miles per day]

max =  _  ∗ 
∈
GAMS®
Trucks Problem  – Solution

Sets:
 = ,, Let be  the set containing the types of truck.

Scalars
_: Maximum resources, [$]
_: Maximum of trucks, [-]
_: Maximum of drivers, [-]
GAMS®
Trucks Problem  – Solution
Parameters
_  : ∈
Purchase cost by truck type, [$]
_  : Drivers required for each type of truck,∈ [-]
_  : Production by truck type, ∈ [ton-miles per day]
GAMS®
Trucks Problem  – Solution

Variables:
  ∈ ℤ+ : Number of trucks by truck type,  ∈  [-]

Variables:
: Total production per day, [ton-miles/day]
GAMS®
Trucks Problem  – Solution

Constraints:
_:  ∈  _  ∗   ≤ _
_:  ∈    ≤ _
_ :  ∈  _  ∗   ≤ _
GAMS®
Trucks Problem  – Solution

Objective function:
_: Total Maximum production, [ton-miles per day]

max =  _  ∗  
∈
GAMS®
Trucks Problem  – Solution
GAMS®
Trucks Problem  – Solution
GAMS®
Trucks Problem  – Solution
GAMS®
Trucks Problem  – Solution
GAMS®
Trucks Problem  – Solution
GAMS®
Trucks Problem  – Solution
GAMS
Bonus 8

In the Optibeer   brewery are four different kinds of beers: light,


“  ” 

lager, ale and premium. Each kind of beer uses different amounts of 
the four main components of beer: water, malt, hops and yeast. Each
kind of beer has a different utility in dollars.
Maximize the revenue of the Optibeer   brewery based on the fact 
“  ” 

that each raw material has certain availability.

Required amount of component in each beer (lb/L)


Light Lager Ale Premium Availability (lb)
Water 7 6 5 4 Unlimited
Malt 1 1 0 3 50
Hops 2 1 2 1 150
Yeast 1 1 1 4 80
Utility ($/L) 6 5 3 7
Adapted from Reference [4]
GAMS
Practice

The Fresh Milk cooperative supplies milk in gallon jugs from its two
warehouses located in Buffalo (New York) and Williamsport
(Pennsylvania). It has a capacity of 2000 gallons per day at Buffalo and
1600 gallons per day at Williamsport. It delivers 800 gallons/day to
Rochester (New York). Syracuse (New York) requires 1440 gallons/day and
the remainder (1360 gallons) are trucked to New York City. The cost to
ship the milk to each of the destinations is different and is given in the
following table. Establish the shipping strategy for minimum cost.
GAMS®
References

[1] E. Thomas F, D. Himmelblau, and L. Lasdon, OPTIMIZATION OF


CHEMICAL PROCESSES, Second Edition. New York: McGraw-Hill, 2001.
[2] Rosenthal, R.E. (2015) A GAMS Tutorial, in GAMS – A User’s Guide

[3] GAMS Homepage. Recovered from http://www.gams.com/

[4] Dantzig G. B., Linear Programming and Extensions, Princeton University


Press, Princeton, New Jersey, 1963, Chapter 3-3.

You might also like