Está en la página 1de 11

GAMS Introduction

GAMS is a model developed systems that connect several different optimization algorithms and models. Model is supplied

through an input file to a formula type using a high-level language by the user to the GAMS. GAMS is to find and tools to translate the

model that is automatically linked to optimization algorithms and. As well as to the discovery by the Solver tool, the translated model is

also reported to the user via the output file. The figure below describes this process.

GAMS
Input Output
Translation
File File

Optimization Solver

tool

Rules for naming the extension of the files is as follows.

The input file: Filename. GAMS output file:

Filename. LST command to execute an input file and

translation:

GAMS filename
GAMS input file usually consists of the following:

a) provision of data and indexes

b) a list of the type of formula and the variable indicating the constraint expression and the objective function

c) definition of the expression representing the constraint expression and the objective function

d) threshold value, the initial value specified special selections

e) Run Solver tool


The syntax of the input file format is not fixed, but inconclusive. And it holds many key commands to provide the

flexibility to deal with different types of models. (However, the model

Is given in equation form and operation subroutine or procedure can not be handled.)

To briefly describe the syntax for the input file of the GAMS has prepared two examples.
Example 1

Consider the following nonlinear planning problem given the same issue 8.26 of the body.
min Z = x 2 1+ x2 2+ x3 2

st One- x - One2 x 3 0

x One- x 3 0 (One)

x One- x 2 2+ x 2x 3 4 = 0

0 x One 5

0 x 2 3

0 x 3 3

The initial value

x 1 = 4, x 2 = 2, x 3= 2 (2)

First, inequality One- x - One


2 x 3 0 It should be reorganized following the same linear. This zero
Only because of an error sharing as well because it is easy to handle linear constraint expressions.

x 2- x 3 0 3

GAMS input file for the reconstruction problems TEST. GMS is given in the following pages. The first $ displays appearing column

refers to the flow control statements. The first line is the title, second and third line is to reject more information such as maps and

symbols in the output. It usually contains the three lines is increased. variable x One , x 2 , x 3 The key commands that are used to list the

VARIABLES

It was. Variable represents the objective function value Z It must also be included here. POSITIVE

VARIABLES variables x One , x 2 , x 3 It indicates that a positive number. The objective function values Z Generally

Available in both positive and negative, so should not be included here. Semicolon to mark the end of a sentence; Note

that this is used.

The key command EQUATIONS were used to list the names of the following constraint equation objective function. The name can be

fitted optionally. In this case attached a OBJ for CON1, CON2, CON3, so that the objective function with respect to the constraints.

The actual formula is defined less a name taken from two periods following. The following syntax is used to distinguish between groups of equations and

inequalities.

= E = for =

= G = for

= L = for

The basic operation symbols are as follows.

+ , - : Addition, subtraction

* , /: Multiplication, division
** : Indices

The objective function is expressed as follows:

OBJ .. Z = E = X1 ** 2 + X2 ** 2 + X3 ** 2;

Keep in mind that taking a semicolon at the end. The square of the variable may be displayed using the built-in function SQR. On

page 69 of your textbook GAMS Table 1 shows the total list of built-in functions that GAMS has to offer.

The following is a step of specifying an upper limit value and the initial value from the input file. This is possible hameuroseo display extension is equal to

the following variables additionally.

LO Lower limit

UP Upper limit

L The function value (the initial or calculated)

M Lagrange multiplier value (relative value of a variable)

x One , x 2 , x 3 Inde lower limit is 0. This is the key commands POSITIVE VARIABLES

Now that you have defined before the server does not need to specify a lower limit separately. It specifies the initial value of the variable is not

necessary. If you do not specify GAM specifies the minimum value as the initial value. It is preferable to specify the initial prediction value in the

non-linear planning problem. (E X1.L = 4;)

It is actually specify whether to use any formula from the formula of the model name and listed by key commands

MODEL. If TEST is the name of the model and was determined not to use any formula.

OPTION statement that follows has the ability to remove the output translate the formulas for error correction. In most

cases, it is by using the OPTION = 0 and LIMROW LIMCOL OPTION = 0 in order to prevent that the longer the output file. For

more information, it is in your textbook pages 102-106.

Finally, call an optimization algorithm through the SOLVE statements. Contact SOLVE format is as follows:

SOLVE (model name) USING (solver type) MINIMIZING or


MAXIMIZING (objective variable)

TEST.GMS

$ TITLE Test Problem $


OFFSYMXREF $
OFFSYMLIST

* Example from Problem 8.26 in "Engineering Optimization" by


* Reklaitis, Ravindran and Ragsdell (1983)

VARIABLES X1, X2, X3, Z; POSITIVE VARIABLES

X1, X2, X3;

EQUATIONS CON1, CON2, CON3, OBJ;

CON1 .. X2 - X3 = G = 0;

CON2 .. X1-X3 = G = 0;

CON3 .. X1 - X2 ** 2 + X1 * X2 - 4 = E = 0;
OBJ .. Z = E = SQR (X1) + SQR (X2) + SQR (X3);

* Upper bounds

X1.UP = 5; X2.UP
= 3; X3.UP = 3;

* Initial point

X1.L = 4;

X2.L = 2;

X3.L = 2;

MODEL TEST / ALL /;

OPTION LIMROW = 0; OPTION

LIMCOL = 0;

SOLVE TEST USING NLP MINIMIZING Z;

The type of the Solver tool available in GAMS is as follows:

LP: Linear Programming NLP: nonlinear

programming MIP: linear mixed integer

programming

RMIP: linear mixed integer programming, expand the integer variables as continuous variables

MINLP: Lee Jinsu integer variables and linear and non-linear continuously variable non-linear mixed-integer

Programming

RMINLP: Nonlinear Mixed Integer Programming Expand integer variable as a continuous variable
Optimization of the default software options associated with each Solver tool in GAMS Student Edition are as follows:

LP: BDMLP MIP, RMIP: ZOOM NLP,

RMINLP: MINOS 5.3 MINLP:

DICOPT ++

BDMLP will unpack the linear programming using the simplex method. ZOOM is solves the linear programming and mixed integer using the method and

organization Branch and Bound methods. MINOS is 5.3 solves a nonlinear programming using the reduced stitching traversing the Lagrange function is

attached. The method is linear if the simplex method, if the constraint expression and the objective function. And DICOPT ++ solves Using the penalty function

approach law external chakdoen with respect to non-linear mixed-integer programming. For more information on these solutions are given in the text.

GAMS, but using Solver tool listed above as the default option if you want to use if we find another tool, for example,

when solving the LP if you would like to use the ZOOM BDMLP instead be specified as follows:

OPTION LP = ZOOM;

When you run the input file to solve the examples (GAMS TEST to enter the command line and press Enter key) and then

get the output files TEST.LST appears on two pages.

Until the first part (line 4 line 36) the output file is the same as the input file. The following statistics are displayed for the

problem size. (That is, four variables: x One , x 2 , x 3 Z: Equation 4: 3 restrictions

Expression and the objective function). When using GAMS interpretation of fraud in the US non-linear models are referred to the derivative related

items. We have to find a summary for non-linear models with the results of the objective function Z = 7.2177 notifies the local optimum value is found. Use

only resources it has stated that the calculation time is 1.648 seconds. A detailed description of the output file is shown to the user textbook pages

117-121.

And the information is listed on formulas and variables. The value given as a named column LEVEL is the actual calculated

result. For example x 1 = 2.526, x 2 = 0.916, x 3 = 0, Z = 7.218 to be.

The column labeled LOWER, UPPER indicates the lower and upper limits MARGINAL column shows the number of credit or the Lagrange

multiplier values. For instance, the value A third constraint (CON3) is a multiplier

2.637 inde This means that the dietary restrictions enabled.

TEST.LST

GAMS 2.25.082 386/486 DOS 05/07/99 10:11:12 PAGE

Test Problem
4

5 * Example from Problem 8.26 in "Engineering Optimization" by 6 * Reklaitis, Ravindran

and Ragsdell (1983)

7*
8 VARIABLES X1, X2, X3, Z; 9 POSITIVE VARIABLES

X1, X2, X3; 10

11 EQUATIONS CON1, CON2, CON3, OBJ; 12

13 CON1 .. X2 - X3 = G = 0;
14 CON2 .. X1-X3 = G = 0;

15 CON3 .. X1 - X2 ** 2 + X1 * X2 - 4 = E = 0;

16 OBJ .. Z = E = SQR (X1) + SQR (X2) + SQR (X3);


17

18 * Upper bounds 19

X1.UP = 5; 20

X2.UP = 3; 21 X3.UP

= 3; 22

23 * Initial point 24 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; 35

COMPILATION TIME = 0.000 SECONDS VERID MW2-25-082

GAMS 2.25.082 386/486 DOS 05/07/99 10:11:12 PAGE

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 NZ 5

DERIVATIVE POOL 6 CONSTANT POOL 8

CODE LENGTH 57

GENERATION TIME = 0.000 SECONDS

EXECUTION TIME = 0.060 SECONDS VERID MW2-25-082

GAMS 2.25.082 386/486 DOS 05/07/99 10:11:12 PAGE

Test Problem Solution


Report SOLVE TEST USING NLP FROM LINE 34

SOLVE SUMMARY

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 .110 1000.000

ITERATION COUNT, LIMIT 15 1000

EVALUATION ERRORS 0 0

MINOS 5.3 (Nov 1990) Ver: 225-386-02


=====

BA Murtagh, University of New South Wales and

PE Gill, W. Murray, MA Saunders and MH Wright Systems Optimization

Laboratory, Stanford University.


Work space it allocated -- 0.04 Mb

EXIT - OPTIMAL SOLUTION FOUND MAJOR ITNS,

LIMIT 7 200

FUNOBJ, FUNCON CALLS 34 34

SUPERBASICS One

INTERPRETER USAGE 0.00

NORM RG / NORM PI 9.678E-10

LOWER LEVEL UPPER MARGINAL

---- EQU CON1 . .916 + INF .

---- EQU CON2 . 2.526 + INF .

---- EQU CON3 4.000 4.000 4.000 2.637

---- EQU OBJ . . . 1.000

LOWER LEVEL UPPER MARGINAL

---- VAR X1 . 2.526 5.000 .

---- VAR X2 . .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.082 386/486 DOS 05/07/99 10:11:12 PAGE

Test Problem Solution

Report SOLVE TEST USING NLP FROM LINE 34

EXECUTION TIME = 0.000 SECONDS VERID MW2-25-082


USER: Dr. Geongbeom Yi G950706: 1556CR-MW2

For Personal Use Only

* * * * FILE SUMMARY

INPUT C: \ DUMP \ TEST.GMS

OUTPUT C: \ DUMP \ TEST.LST

Example 2

Let us consider the problem of specifying a process flow in the heat exchanger in the book of 409-410 pages "Optimization

of Chemical Process" of Edgar and Himmelblau.

n
min Z=n C ij x ij
j = One
i = One

n
st x ij = One j = One,..., n
i = One

n
x ij = One i = One,..., n (4)

j = One

x ij = 0,1 i = One,..., n j = One,... n

This problem has been known to issue dividends. here i It is n Index for the two process streams and j

It is n The index for the two heat exchangers. If the process i Heat Exchanger j When assigned to a binary variable

Number x ij = One And otherwise x ij = 0 to be.

All heat exchangers two expressions Pharmaceuticals j Will be allocated to one process flow, all process flows i

Indicates that it should be allocated to a single heat exchanger.

Process Flow i A heat exchanger j Costs that arise when dividends are as follows;

In GAMS using the index set constitutes the model of equation (4). Except that the index as it appears in the input file

HEAT.GMS the next page has an input file structure similar to that of Example 1. Input data are given in the TABLE SETS

section. For a description of these are shown in your textbook pages 43-57. Which set of elements are denoted by letters

and numbers. * If the number is used to indicate a range. That is, 1 - 4 are to mean 1, 2, 3, 4. If you only enter a number in a

consistent halttaeneun TABLE it does not need to take the correct position. character
Fee may be entered using a key command of SCALAR or PARAMETER. variable x ij

Together with the index X ( I, J) It was designated as Formula ASSI (J) It is j = 1,2,3,4 In connection with formula, and ASSJ (I) It is i

= A, B, C, D And it is related. It was declared with the core instruction of BINARY VARIABLES. As summed symbols are

described in the user textbook pages 17-18 as follows:

SUM (index of summation, in terms sum)

The OPTION = OFF SOLPRINT was used to prevent transmit the calculated results in the output file. And variable x ij And the

objective function Z In order to only the output value of the DISPLAY

Note that this index can not be used. For more information about DISPLAY it can be found in your textbook pages

143-148. SOLVE In the door x ij Because the Solver tool Lee Jinsu MIP

I used to.

HEAT.GMS

One

* Asignment problem for heat exchangers from pp. 409-410 in

* "Optimization of Chemical Processes" by Edgar and Himmelblau

SETS

I streams / A, B, C, D /
J exchangers / 1 * 4 /;

TABLE C (I, J) Cost of assigning stream i to exchanger j

One 2 3 4

A 94 One 54 68

B 74 10 88 82

Heat exchanger 1 Heat exchanger 2 Heat exchanger 3 Heat exchanger 4

A process stream 94 One 54 62

Process flow B 74 10 88 82

Process flow C 73 88 8 76

Process stream D 11 74 81 21

C 73 88 8 76

D 11 74 81 21 .;

VARIABLES X (I, J), Z;

BINARY VARIABLES X (I, J) .;


EQUATIONS ASSI (J), ASSJ (I), OBJ;

ASSI (J) .. SUM (I, X (I, J)) = E = 1;

ASSJ (I) .. SUM (J, X (I, J)) = E = 1;


OBJ .. Z = E = SUM ((I, J), C (I, J) * X (I, J));

MODEL HEAT / ALL /;

OPTION LIMROW = 0; OPTION


LIMCOL = 0; OPTION SOLPRINT =
OFF;

SOLVE HEAT USING MIP MINIMIZING Z;

DISPLAY XL, ZL;

También podría gustarte