Chemical Engineering Optimization Models with GAMS

Slides:



Advertisements
Similar presentations
BTS Confidentiality Seminar Series June 11, 2003 FCSM/CDAC Disclosure Limiting Auditing Software: DAS Mark A. Schipper Ruey-Pyng Lu Energy Information.
Advertisements

MATH 224 – Discrete Mathematics
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 10.
Lecture 3 Linear Programming: Tutorial Simplex Method
Linear Programming. Introduction: Linear Programming deals with the optimization (max. or min.) of a function of variables, known as ‘objective function’,
CHEN 4460 – Process Synthesis, Simulation and Optimization
What is GAMS?. While they are not NLP solvers, per se, attention should be given to modeling languages like: GAMS- AIMMS-
Computational Methods for Management and Economics Carla Gomes Module 8b The transportation simplex method.
The Web Warrior Guide to Web Design Technologies
Advanced GAMS 1. Good Modeling Practices 2. Fixing Misbehaving Models 3. Linking GAMS 4. Advanced GAMS Syntax.
Introduction to C Programming
CENG536 Computer Engineering Department Çankaya University.
ITEC113 Algorithms and Programming Techniques
© 2007 Pearson Education Chapter 14: Solving and Analyzing Optimization Models.
Good modeling practices AGEC 641 Lab, Fall 2011 Mario Andres Fernandez Based on material written by Gillig and McCarl. Improved upon by many previous lab.
GAMS/GAMSIDE AGEC 641 Lab, Fall 2011 Mario Andres Fernandez Based on material written by Gillig and McCarl and improved upon by previous lab instructors.
Linear Programming and CPLEX Ting-Yuan Wang Advisor: Charlie C. Chen Department of Electrical and Computer Engineering University of Wisconsin-Madison.
1 Chapter 8: Linearization Methods for Constrained Problems Book Review Presented by Kartik Pandit July 23, 2010 ENGINEERING OPTIMIZATION Methods and Applications.
Page 1 Page 1 ENGINEERING OPTIMIZATION Methods and Applications A. Ravindran, K. M. Ragsdell, G. V. Reklaitis Book Review.
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
5.6 Maximization and Minimization with Mixed Problem Constraints
Introduction to C Programming
Spreadsheet Modeling & Decision Analysis:
By Hrishikesh Gadre Session I Introduction to EES Department of Mechanical Engineering Louisiana State University Engineering Equation.
Matrix Mathematics in MATLAB and Excel
Linear Programming.
Fundamentals of Python: From First Programs Through Data Structures
Multi stream, multi phase heat exchangers Modeling, optimization and heat integration Candidate: Axel Holene ; Supervisors: Sigurd Skogestad, Johannes.
Mathematics of Cryptography Part I: Modular Arithmetic, Congruence,
LINEAR PROGRAMMING SIMPLEX METHOD.
Introduction to Mathematical Programming OR/MA 504 Chapter 3.
A GAMS TUTORIAL. WHAT IS GAMS ? General Algebraic Modeling System Modeling linear, nonlinear and mixed integer optimization problems Useful with large,
MATLAB Tutorials Session I Introduction to MATLAB Rajeev Madazhy Dept of Mechanical Engineering LSU.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Purpose  This training course describes how to configure the the C/C++ compiler options.
Special Conditions in LP Models (sambungan BAB 1)
Operator Precedence First the contents of all parentheses are evaluated beginning with the innermost set of parenthesis. Second all multiplications, divisions,
 2004 Prentice Hall, Inc. All rights reserved. 1 Chapter 11 - JavaScript: Arrays Outline 11.1 Introduction 11.2 Arrays 11.3 Declaring and Allocating Arrays.
Chapter 19: Solver Re-Visited Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
GAMS Anwendung Nutzeroberfläche eigene Programme Modellierungs- System GAMS AMPL ILOG Studio … Solver CPLEX, CONOPT, MINOS, COIN, BARON,...
Array Dependence Analysis COMP 621 Special Topics By Nurudeen Lameed
How to get started with GAMS MS&E 348 – Lecture 1/20/04.
Seungchan Lee Intelligent Electronic Systems Human and Systems Engineering Department of Electrical and Computer Engineering Software Release and Support.
/* Documentations */ Pre process / Linking statements Global declarations; main( ) { Local Declarations; Program statements / Executable statements; }
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
Disciplined Software Engineering Lecture #2 Software Engineering Institute Carnegie Mellon University Pittsburgh, PA Sponsored by the U.S. Department.
Copyright © 1994 Carnegie Mellon University Disciplined Software Engineering - Lecture 1 1 Disciplined Software Engineering Lecture #2 Software Engineering.
Mechanical Engineering Department 1 سورة النحل (78)
 Minimization Problem  First Approach  Introduce the basis variable  To solve minimization problem we simple reverse the rule that is we select the.
EE/Econ 458 Duality J. McCalley.
Integer LP In-class Prob
Spreadsheet Modeling & Decision Analysis A Practical Introduction to Management Science 5 th edition Cliff T. Ragsdale.
CHAPTER 2 PROBLEM SOLVING USING C++ 1 C++ Programming PEG200/Saidatul Rahah.
Linear Programming Water Resources Planning and Management Daene McKinney.
September 28, 2000 Improved Simultaneous Data Reconciliation, Bias Detection and Identification Using Mixed Integer Optimization Methods Presented by:
System To Generate Test Data: The Analysis Program Syed Nabeel.
GAMS: General Algebraic Modeling System Linear and Nonlinear Programming The full system documentation is provided electronically with the software.
5.3 Mixed Integer Nonlinear Programming Models. A Typical MINLP Model.
Production systems LP and MILP models. Introduction  Linear programing (LP) is a base tool in optimization  George B. Dantzig developed the simplex.
Working with GAMS Vikas Argod Research Computing and Cyberinfrastructure
LINGO TUTORIAL.
Lecture 5 Good modeling Chengcheng Fei 2017 Fall
Lecture 7 GAMS Check Chengcheng Fei 2017 Fall
Solver & Optimization Problems
5.3 Mixed-Integer Nonlinear Programming (MINLP) Models
5.3 Mixed Integer Nonlinear Programming Models
A Mathematical Programming Language
The Simplex Method The geometric method of solving linear programming problems presented before. The graphical method is useful only for problems involving.
A QUICK START TO OPL IBM ILOG OPL V6.3 > Starting Kit >
Lecture 2 General Problem
Presentation transcript:

Chemical Engineering Optimization Models with GAMS CACHE DESIGN CASE STUDIES SERIES Case Study No.6 1991   Editor: Ignacio E. Grossmann

Introduction to GAMS Ignacio E. Grossmann  Department of Chemical Engineering  Carnegie Mellon University  Pittsburgh, PA 15213

Introduction to GAMS The General Algebraic Modeling System (GAMS) is a high-level modeling system for mathematical programming and optimization.

Introduction to GAMS The conventions for naming the extensions of the files are as follows:   Input file:  Filename.GMS Output file: Filename.LST 

Introduction to GAMS The GAMS input file is in general organized into the following sections:  Specification of indices and data (parameters, sets).  Listing of names and types of variables and equations (constraints and objective function).  Definition of the equations (constraints and objective function).  Specification of bounds, initial values and special options.  Call to the optimization solver. 

Introduction to GAMS The format of the input files is not rigid (although the syntax is). There is a rather large number of keywords so as to provide the flexibility for handling simple and complex models. 

Example 1  

Example 1   Initial starting point:

Example 1 First we should note that the inequality (2)                                    (2) can actually be rearranged in linear form as:    (3)  Using (3) instead of (2) is a much better choice, not only because we avoid the potential for a division by zero, but also because we obtain a linear constraint which is easier to handle.

Example 1   Dollar Control Options Comments Main code

Example 1 - Dollar Control Options $title: This option sets the title in the page header of the listing file. $onsymxref [On/Off Symbol Reference]: This option controls the following, Collection of cross references for identifiers like sets, parameters, and variables. Cross-reference report of all collected symbols in listing file. Listing of all referenced symbols and their explanatory text by symbol type in listing file. $onsymlist [On/Off Symbol List]: Controls the complete listing of all symbols that have been defined and their text. GAMS-A User’s Guide Tutorial by Richard E. Rosenthal (2008)

Example 1 - Input file The keyword VARIABLES is used to list our variables x1, x2 and x3. Note that Z, the objective function value must also be included. The keyword POSITIVE VARIABLES is used to specify the non-negativity of x1, x2, x3. The objective function values should not be included here as in general it might take positive or negative values. Finally, note that the semicolon ; must be included to specify the end of the lists.

Example 1 - Input file The keyword EQUATIONS is for listing the names of the constraints and objective function. Constraints: CON1, CON2, CON3 Objective function: OBJ Syntax Meaning =E= = =G= > =L= < + Addition - Subtraction * Multiplication / Division ** exponent Note the semi-colon ; is needed at the end.

Example 1 - Input file Next in the input file we specify the upper bounds and initial values. This is done by adding a subfield to the variables. .LO lower bound  .UP upper bound  .L  level value, meaning actual value (initial or final)  .M  dual prices, Lagrange or Kuhn-Tucker multipliers

Example 1 - Input file The keyword MODEL is used to name our model and to specify which equations should be used. In this case we name our model as TEST and specify that all equations be used.  The OPTION statements are used to suppress output for debugging the compilation of the equations. OPTION LIMROW = 0 and OPTION LIMCOL = 0 to avoid long output files.

Example 1 - Input file Finally, we invoke the optimization algorithm with the SOLVE statement. Here the format is as follows:   SOLVE (model name) USING (solver type) MINIMIZING (objective variable)   or   SOLVE (model name) USING (solver type) MAXIMIZING (objective variable) 

Example 1 - Input file    The main solver types available in GAMS are as follows:  LP      linear programming  NLP     nonlinear programming  MIP     mixed-integer linear programming  RMIP    relaxed MILP where the integer variables are treated as continuous  MINLP   mixed-integer nonlinear programming in which the integer variables are 0-1 and linear; the continuous variables can be nonlinear  RMINLP  mixed-integer nonlinear programming where the integer variables are treated as continuous 

GAMS 2.25  PC AT/XT                              09/16/97  23:48:05  PAGE      1  Test Problem         4     5  * Example from Problem 8.26 in "Engineering Optimization"     6  * by Reklaitis, Ravindran and Ragsdell (1983)     7  *     8     9  VARIABLES X1, X2, X3, Z ;    10  POSITIVE VARIABLES X1, X2, X3 ;    11    12  EQUATIONS CON1, CON2, CON3, OBJ ;    13    14  CON1..  X2 - X3 =G= 0 ;    15  CON2..  X1 - X3 =G= 0 ;    16  CON3..  X1 - X2**2 + X1*X2 - 4 =E= 0 ;    17  OBJ..   Z =E= SQR(X1) + SQR(X2) + SQR(X3) ;    18    19  * Upper bounds    20    X1.UP = 5 ;    21    X2.UP = 3 ;    22    X3.UP = 3 ;    23    24  * Initial point    25    X1.L = 4 ;    26    X2.L = 2 ;    27    X3.L = 2 ;    28    29  MODEL TEST / ALL / ;    30    31  OPTION LIMROW = 0;    32  OPTION LIMCOL = 0;    33    34  SOLVE TEST USING NLP MINIMIZING Z;    COMPILATION TIME     =        0.060 SECONDS        VERID TP5-00-  038  GAMS 2.25  PC AT/XT                              09/16/97  23:48:05  PAGE      2  Test Problem  Model Statistics    SOLVE TEST USING NLP FROM LINE 34        MODEL STATISTICS  BLOCKS OF EQUATIONS       4     SINGLE EQUATIONS        4  BLOCKS OF VARIABLES       4     SINGLE VARIABLES        4  NON ZERO ELEMENTS        10     NON LINEAR N-Z          5  DERIVATIVE POOL           6     CONSTANT POOL           2  CODE LENGTH              57  GENERATION TIME      =        0.000 SECONDS    EXECUTION TIME       =        0.110 SECONDS        VERID TP5-00-  038  GAMS 2.25  PC AT/XT                              09/16/97  23:48:05  PAGE      3  Test Problem  Solution Report     SOLVE TEST USING NLP FROM LINE 34                   S O L V E      S U M M A R Y       MODEL   TEST                OBJECTIVE  Z       TYPE    NLP                 DIRECTION  MINIMIZE       SOLVER  MINOS5              FROM LINE  34  **** SOLVER STATUS     1 NORMAL COMPLETION  **** MODEL STATUS      2 LOCALLY OPTIMAL  **** OBJECTIVE VALUE                7.2177   RESOURCE USAGE, LIMIT          0.336     1000.000   ITERATION COUNT, LIMIT        15         1000   EVALUATION ERRORS              0            0       M I N O S    5.3    (Nov 1990)         Ver: 225-DOS-02       = = = = =       B. A. Murtagh, University of New South Wales         and       P. E. Gill,  W. Murray,  M. A. Saunders and M. H. Wright       Systems Optimization Laboratory, Stanford University.   D E M O N S T R A T I O N    M O D E     You do not have a full license for this program.     The following size retrictions apply:        Total nonzero elements:  1000        Nonlinear nonzero elements:  300     Estimate work space needed    --     39 Kb   Work space allocated          --    160 Kb   EXIT -- OPTIMAL SOLUTION FOUND   MAJOR ITNS, LIMIT             7     200   FUNOBJ, FUNCON CALLS         34      34   SUPERBASICS                   1   INTERPRETER USAGE           .00   NORM RG / NORM PI     9.678E-10                         LOWER     LEVEL     UPPER    MARGINAL  ---- EQU CON1            .        0.916     +INF       .  ---- EQU CON2            .        2.526     +INF       .  ---- EQU CON3           4.000     4.000     4.000     2.637  ---- EQU OBJ             .         .         .        1.000  ---- VAR X1              .        2.526     5.000      .  ---- VAR X2              .        0.916     3.000      EPS  ---- VAR X3              .         .        3.000      EPS  ---- VAR Z              -INF      7.218     +INF       .    **** REPORT SUMMARY :        0     NONOPT                               0 INFEASIBLE                               0  UNBOUNDED                               0     ERRORS  GAMS 2.25  PC AT/XT                              09/16/97  23:48:05  PAGE      4  Test Problem  Solution Report     SOLVE TEST USING NLP FROM LINE 34        EXECUTION TIME       =        0.050 SECONDS        VERID TP5-00-  038    USER: CACHE DESIGN CASE STUDIES SERIES               G911007-  1447AX-TP5        GAMS DEMONSTRATION VERSION  **** FILE SUMMARY  INPUT      C:\GAMS\TEST.GMS  OUTPUT     C:\GAMS\TEST.LST

GAMS 2.25 PC AT/XT 09/16/97 23:48:05 PAGE 2 Test Problem Model Statistics SOLVE TEST USING NLP FROM LINE 34 MODEL STATISTICS BLOCKS OF EQUATIONS 4 SINGLE EQUATIONS 4 BLOCKS OF VARIABLES 4 SINGLE VARIABLES 4 NON ZERO ELEMENTS 10 NON LINEAR N-Z 5 DERIVATIVE POOL 6 CONSTANT POOL 2 CODE LENGTH 57 GENERATION TIME = 0.000 SECONDS EXECUTION TIME = 0.110 SECONDS VERID TP5-00- 038 GAMS 2.25 PC AT/XT 09/16/97 23:48:05 PAGE 1 Test Problem 4 5 * Example from Problem 8.26 in "Engineering Optimization" 6 * by Reklaitis, Ravindran and Ragsdell (1983) 7 * 8 9 VARIABLES X1, X2, X3, Z ; 10 POSITIVE VARIABLES X1, X2, X3 ; 11 12 EQUATIONS CON1, CON2, CON3, OBJ ; 13 14 CON1.. X2 - X3 =G= 0 ; 15 CON2.. X1 - X3 =G= 0 ; 16 CON3.. X1 - X2**2 + X1*X2 - 4 =E= 0 ; 17 OBJ.. Z =E= SQR(X1) + SQR(X2) + SQR(X3) ; 18 19 * Upper bounds 20 X1.UP = 5 ; 21 X2.UP = 3 ; 22 X3.UP = 3 ; 23 24 * Initial point 25 X1.L = 4 ; 26 X2.L = 2 ; 27 X3.L = 2 ; 28 29 MODEL TEST / ALL / ; 30 31 OPTION LIMROW = 0; 32 OPTION LIMCOL = 0; 33 34 SOLVE TEST USING NLP MINIMIZING Z; COMPILATION TIME = 0.060 SECONDS VERID TP5-00- 038 The derivative pool refers to the fact that analytical gradients for the nonlinear model have been generated by GAMS.

The column MARGINAL gives the dual variables or multipliers. GAMS 2.25 PC AT/XT 09/16/97 23:48:05 PAGE 3 Test Problem Solution Report SOLVE TEST USING NLP FROM LINE 34 S O L V E S U M M A R Y MODEL TEST OBJECTIVE Z TYPE NLP DIRECTION MINIMIZE SOLVER MINOS5 FROM LINE 34 **** SOLVER STATUS 1 NORMAL COMPLETION **** MODEL STATUS 2 LOCALLY OPTIMAL **** OBJECTIVE VALUE 7.2177 RESOURCE USAGE, LIMIT 0.336 1000.000 ITERATION COUNT, LIMIT 15 1000 EVALUATION ERRORS 0 0 M I N O S 5.3 (Nov 1990) Ver: 225-DOS-02 = = = = = B. A. Murtagh, University of New South Wales and P. E. Gill, W. Murray, M. A. Saunders and M. H. Wright Systems Optimization Laboratory, Stanford University. D E M O N S T R A T I O N M O D E You do not have a full license for this program. The following size retrictions apply: Total nonzero elements: 1000 Nonlinear nonzero elements: 300 Estimate work space needed -- 39 Kb Work space allocated -- 160 Kb EXIT -- OPTIMAL SOLUTION FOUND MAJOR ITNS, LIMIT 7 200 FUNOBJ, FUNCON CALLS 34 34 SUPERBASICS 1 INTERPRETER USAGE .00 NORM RG / NORM PI 9.678E-10 LOWER LEVEL UPPER MARGINAL ---- EQU CON1 . 0.916 +INF . ---- EQU CON2 . 2.526 +INF . ---- EQU CON3 4.000 4.000 4.000 2.637 ---- EQU OBJ . . . 1.000 ---- VAR X1 . 2.526 5.000 . ---- VAR X2 . 0.916 3.000 EPS ---- VAR X3 . . 3.000 EPS ---- VAR Z -INF 7.218 +INF . **** REPORT SUMMARY : 0 NONOPT 0 INFEASIBLE 0 UNBOUNDED 0 ERRORS The column MARGINAL gives the dual variables or multipliers.

GAMS 2.25 PC AT/XT 09/16/97 23:48:05 PAGE 4 Test Problem Solution Report SOLVE TEST USING NLP FROM LINE 34 EXECUTION TIME = 0.050 SECONDS VERID TP5-00- 038 USER: CACHE DESIGN CASE STUDIES SERIES G911007- 1447AX-TP5 GAMS DEMONSTRATION VERSION **** FILE SUMMARY INPUT C:\GAMS\TEST.GMS OUTPUT C:\GAMS\TEST.LST

Example 2   Consider the problem of assigning process streams to heat exchangers:

Example 2 Streams Exchangers 1 2 3 4 A 94 54 68 B 74 10 88 82 C 73 8 The cost Cij of assigning stream i to exchanger j is as follows: Streams Exchangers 1 2 3 4 A 94 54 68 B 74 10 88 82 C 73 8 76 D 11 81 21

Example 2 SETS N numbers /1*3/; PARAMETER A(N) array / 1 24 2 64 3 98 /; COUNT = A(‘1’)**3+ A(‘2’)**3+ A(‘3’)**3; COUNT = SUM(N, A(N)**3 );

Example 2 SETS I streams / A, B, C, D / J exchangers / 1*4 / ; EQUATION ASSI(J); ASSI(‘1’).. SUM( I, X(I, ‘1’) ) =E= 1; ASSI(‘2’).. SUM( I, X(I, ’2’) ) =E= 1; ASSI(’3’).. SUM( I, X(I, ’3’) ) =E= 1; ASSI(’4’).. SUM( I, X(I, ’4’) ) =E= 1; ASSI(J).. SUM( I, X(I,J) ) =E= 1;

Example 2  

GAMS 2.25  PC AT/XT                              09/16/97  23:53:18  PAGE      1  Test Problem         4     5  *     6  * Assignment problem for heat exchangers from pp.409-410  in     7  * Optimization of Chemical Processes" by Edgar and  Himmelblau     8  *     9    10  SETS    11       I  streams     / A, B, C, D /    12       J  exchangers  / 1*4 / ;    13    14   TABLE C(I,J) Cost of assigning stream i to exchanger j    15    16           1    2    3    4    17      A   94    1   54   68    18      B   74   10   88   82    19      C   73   88    8   76    20      D   11   74   81   21 ;    21    22    23   VARIABLES X(I,J), Z;    24   BINARY VARIABLES X(I,J);    25    26   EQUATIONS ASSI(J), ASSJ(I), OBJ;    27    28   ASSI(J).. SUM( I, X(I,J) ) =E= 1;    29   ASSJ(I).. SUM( J, X(I,J) ) =E= 1;    30   OBJ..     Z =E= SUM ( (I,J), C(I,J)*X(I,J) ) ;    31    32   MODEL HEAT / ALL /;    33    34   OPTION LIMROW = 0;    35   OPTION LIMCOL = 0;    36   OPTION SOLPRINT = OFF;    37    38   SOLVE HEAT USING MIP MINIMIZING Z;    39    40   DISPLAY X.L, Z.L ;  GAMS 2.25  PC AT/XT                              09/16/97  23:53:18  PAGE      2  Test Problem  Model Statistics    SOLVE HEAT USING MIP FROM LINE 38        MODEL STATISTICS  BLOCKS OF EQUATIONS       3     SINGLE EQUATIONS        9  BLOCKS OF VARIABLES       2     SINGLE VARIABLES       17  NON ZERO ELEMENTS        49     DISCRETE VARIABLES     16  GENERATION TIME      =        0.050 SECONDS    EXECUTION TIME       =        0.160 SECONDS        VERID TP5-00-  038 

EXECUTION TIME = 0.060 SECONDS VERID TP5-00- 038 GAMS 2.25  PC AT/XT                              09/16/97  23:53:18  PAGE      3  Test Problem  Solution Report     SOLVE HEAT USING MIP FROM LINE 38                   S O L V E      S U M M A R Y       MODEL   HEAT                OBJECTIVE  Z       TYPE    MIP                 DIRECTION  MINIMIZE       SOLVER  ZOOM                FROM LINE  38  **** SOLVER STATUS     1 NORMAL COMPLETION  **** MODEL STATUS      1 OPTIMAL  **** OBJECTIVE VALUE               97.0000   RESOURCE USAGE, LIMIT          0.047     1000.000   ITERATION COUNT, LIMIT        16         1000     Z O O M / X M P    ---   PC Version 2.2 Nov 1990   Dr Roy E. Marsten and Dr Jaya Singhal,   XMP Optimization Software Inc.   Tucson, Arizona     D E M O N S T R A T I O N    M O D E     You do not have a full license for this program.     The following size retrictions apply:        Total nonzero elements: 1000        Total discrete variables: 20     Estimate work space needed    --     16 Kb   Work space allocated          --    273 Kb                  Iterations      Time   Initial LP             16       .00   Heuristic               0       .00   Branch and bound        0       .00   Final LP                0       .00      **** REPORT SUMMARY :        0     NONOPT                               0 INFEASIBLE                               0  UNBOUNDED  GAMS 2.25  PC AT/XT                              09/16/97  23:53:18  PAGE      4  Test Problem  E x e c u t i o n    ----     40 VARIABLE  X.L              1           2           3           4  A                                           1.000  B                   1.000  C                               1.000  D       1.000    ----     40 VARIABLE  Z.L                  =       97.000    EXECUTION TIME       =        0.060 SECONDS        VERID TP5-00-  038    USER: CACHE DESIGN CASE STUDIES SERIES               G911007-  1447AX-TP5        GAMS DEMONSTRATION VERSION  **** FILE SUMMARY  INPUT      C:\GAMS\HEAT.GMS  OUTPUT     C:\GAMS\HEAT.LST 

~The End~