You are on page 1of 33

Introduction to GAMS

Model inspection & Error messages

Dhazn Gillig
Bruce A. McCarl

Department of Agricultural Economics
Texas A&M University

Model Inspection

Are you sure that you know EXACTLY what is in the model?

GAMS can cause one to lose touch with the exact optimization
model being solved, especially when one has a big complicated
data set containing many data calculations.

Thus, when setting up a model one may need to look at individual
equations and variables. GAMS permits this through the use of
model element displays using

! LIMROW and LIMCOL options


Model Inspection – Limrow / Limcol

LIMROW controls the number of rows listed in the equation listing
LIMCOL controls the number of columns listed in the variable listing

If we want more or less variables or equations we can do this by
altering the LIMROW and LIMCOL options

To eliminate => OPTION LIMROW = 0;

To expand => OPTION LIMROW = 100 ; (or any other number)

Limrow / Limcol – Transportation problem illustration Min Cost of shipping goods from S to D minimization of total cost across all possible shipment routes Limited outgoing shipments from each S point i Minimum demand constraint at each D point j Nonnegative shipments .

Limrow / Limcol – Transportation problem illustration .

Limrow / Limcol – Transportation problem illustration For equations we get something like .

Limrow / Limcol – Transportation problem illustration .

Limrow / Limcol – Transportation problem illustration .

Limrow / Limcol – Transportation problem illustration For variables we get something like .

Limrow / Limcol – Transportation problem illustration .

for large models the LIMROW/ LIMCOL option can generate very substantial output files. An alternative way of displaying models called GAMSCHK will be discussed in the next class. .Model Inspection – Limrow / Limcol Unfortunately.

Common Error Messages What to do when ERRORS STRIKE and GAMS stops running? Not to worry. All errors are marked with four asterisks **** at the beginning of a line. it inserts coded error messages inside the echo print in the *. when GAMS detects errors. . One can use to find where errors occur and fix them.LST file.

.gms file where error occurs. Note: always concentrate on fixing the first or first few errors and ignore the others since many subsequent errors may result from a previous error.Common Error Messages Double click on Red Color Lines in the process window. causes the cursor to jump to location in *.

then a cursor will jump to a *.Common Error Messages Double click on Black Color Lines in the process window.lst file where the error is listed. .

go to GAMS 20. errmsg = 0 error messages at the end of *.7 directory and open gmsprm95. then type errmsg = 1 errmsg controls the location in the listing file (*. Alternatively.lst file errmsg = 2 no error messages .Common Error Messages To have error messages displayed immediately following an error line.txt (for window) or gmsprmNT.txt (for NT).lst) of error messages.

This means ! they either must be summed over. . or ! they must appear in the equation definition Not obeying this will cause errors as on next pages.Common Error Messages Note that in every equation all the subscripts (SETS) must be handled in every term.

Destination set is not controlled. The answer is that you cannot and GAMS gives an error...Common Error Messages Set is under control already. By appearing in the equation specification (. Command) SupplyBal(Source). this defines these equations for all elements of the set “Source”. Source set is used in conflicting ways. but then how can you sum over this. Simultaneously. How do you FIX this? .

specification. So what is GAMS to do – give an error message.Common Error Messages Uncontrolled set entered as constant Here the set Source is not operated over in a sum or the . ..

. We have not aligned the data under a column set name so GAMS does not know which data column a number goes with and issues an error.Common Error Messages Now for some other common errors Floating entry ignored We have made an error in typing of a table.

Common Error Messages Dimension different We defined Transport with 2 dimensions but used it with one dimension in the SupplyBal. .

Common Error Messages Duplicate names We already defined TransCost as a parameter and then we used it again in equation specification. . GAMS will object to these multiple declarations.

but this “San Diego” is used later in the PARAMETERS. . Therefore.Common Error Messages Omitted set elements We forgot to include “San Diego” element in Source set. an error arises.

We can use to check for parenthesis.Common Error Messages Mismatched parentheses (A) (B) ? We had an excess number of close “)” in (A) but we had an excess number of open “(“ in (B). .

Common Error Messages Entering improper nonlinear expressions The CostSum equation contains nonlinear terms beyond the capacity of the solver being used. In SOVLE statement. . we define to solve this problem as a LP problem.

.Common Error Messages Using undefined data We declared a TransCost as a parameter but we did not declare numerical values to the TransCost and it is used in the CostSum equation.

Common Error Messages No variable. or equation definition A CostSum equation is used but it has not been declared. . parameter.

Common Error Messages Insufficient semi colon . We forgot to terminate the EQUATIONS statement with the semi colon. .

Common Error Messages Domain violation for element = inconsistent elements of a set We misspelled “New Yor” element of Destination set. .

’ operator expected The algebraic structure of equations must be specified by using . Here we omitted the “.. .” in CostSum equation.Common Error Messages ‘=’ or ‘... notation.

Obviously.Common Error Messages Unknown symbol We named a model “Tranpor”. but then later we solve the model called “Transport”. . misspelled in the MODEL statement.

More Help on Error Messages Double click on a topic to view details .

Hands On Learning Objectives (handson4. Is there anything wrong with the model structure or solutions? .gms and save it as handson4. Learn how to inspect a model structure using OPTION LIMROW and LIMCOL 2. Please run handson2. Please open handson3.gms and inspect the model using OPTION LIMROW and LIMCOL.gms and then fix errors and re-run the problem. 2. Learn how to find and fix errors Things To Do 1.gms): 1.gms. Alter your objective function from to Then run handson4.

References McCarl. ( Basic GAMS class. . B.htm). A.tamu.