Common errors in GAMS

The table below lists the most common errors in GAMS. In order to learn how to find an error and correct it, go to lesson 8.

Error message Description Example (from the Wheat/Maize farm model)
8 Error 8
‘)’ expected
  OBJECTIVE..  sum(c, mb(c)*X(c) =e= Z ;

* ) forgotten in order to close the sum

36 Error 36
‘=’ or ‘..’ or ‘:=’ or ‘$=’ operator expected rest of statement ignored
Among other possibilities, the two dots were forgotten after the name of the equation in the attribution.

 

OBJECTIVE sum(c, mb(c)*X(c) = Z ;
* (..) omitted after OBJECTIVE
37 Error 37
‘=l=’ or ‘=e=’ or ‘=g=’ operator expected
In GAMS equations, signs are indicated as follows : « equal » is written « =e= », « less than or equal to » is written « =l= » (means lower than) and « greater than or equal to » is written « =g= » (means greater than) OBJECTIVE..  sum(c, mb(c)*X(c) = Z ;

 *instead of =e= we wrote =

71 Error 71
The symbol shown has been declared as an equation, but no Symbolic equation (..) was found. hint – look for commas in the Documentation text for the equations. use quotes around the Text or eliminate the commas.
An equation has been declared but has not been attributed.

 

 
96 Error 96
Blank needed between identifier and text (-or- illegal character in identifier) (-or- check for missing ‘;’ on previous line
Common error implying that a semi-colon has been omitted. OBJECTIVE EQUATIONS

objective function
LAND          soil constraint
LABOUR        labour constraint *omission ; here OBJECTIVE..  sum(c, mb(c)*X(c)) =e= Z ;
LAND..    sum(c, X(c)) =l= dterre ;
LABOUR..  sum(c, bmo(c)*X(c)) =l= dmo ;

120 Error 120
Unknown identifier entered as set
When it should have a SET, GAMS reads another identifier

 

 

PARAMETER
BMO(V) labour needs per hectare and per crop (hours)
/wheat    25
maize   50/
;*V instead of C in BMO(V)
140 Error 140
Unknown symbol
GAMS does not recognize the symbol used. This may be because you forgot to declare an entity.  
160 Error 160
Unique element expected – a starting symbol was encountered and parsing will continue by entering ‘element’. An UNQUOTED element has to start with a letter or digit followed by letters, digits, ‘+’, ‘-‘ or ‘_’. The length is limited to 63 characters. The following words are reserved (starting symbols of a GAMS statement) and cannot be used for UNQUOTED set elements:ABORT, ACRONYM(S), ALIAS, BINARY, DISPLAY, ELSE EQUATION(S), EXECUTE, FILE(S), FOR, FREE, IF, INTEGER, LOOP MODEL(S), NEGATIVE, OPTION(S), PARAMETER(S) POSITIVE, PROCEDURE(S), PUT, PUTCLEAR, PUTCLOSE, PUTHD PUTPAGE, PUTTL, SCALAR(S), SEMICONT, SET(S), SOS1, SOS2 TABLE, VARIABLE(S), WHILE QUOTED elements can contain any character. Single and double quotes can be used (starting and ending quote have to match)
One of the elements that you declared does not meet GAMS norms : start with a letter or a number, followed by letters, numbers, ‘+’, ‘-‘ or ‘_’ and a maximum of 63 characters. Furthermore, you may not use a reserved word. SET C crop / table, but/ ;

* the word table was used, which is a WORD RESERVED for the element, instead of wheat

170 Error 170
Domain violation for element
The element does not belong to the domain (in most cases to SET) defined sets
C crops  /wheat,maize/
;
parameter
BMO(C)
/barley    25
maize   50/ ;*barley is not an element of C
338 Error 338
Unique element expected – symbol was not an element and the following text will be skipped until a proper symbol is found to recover. Remember that an UNQUOTED element has to start with a letter or digit followed by letters, digits, ‘+’, ‘-‘ or ‘_’. The length is limited to 63 characters. The following words are reserved (starting symbols of a GAMS statement) and cannot be used for UNQUOTED set elements:
ABORT, ACRONYM(S), ALIAS, BINARY, DISPLAY, ELSE EQUATION(S), EXECUTE, FILE(S), FOR, FREE, IF, INTEGER, LOOP MODEL(S), NEGATIVE, OPTION(S), PARAMETER(S) POSITIVE, PROCEDURE(S), PUT, PUTCLEAR, PUTCLOSE, PUTHD PUTPAGE, PUTTL, SCALAR(S), SEMICONT, SET(S), SOS1, SOS2 TABLE, VARIABLE(S), WHILE QUOTED elements can contain any character. Single and double quotes can be used (starting and ending quote have to match)
One of the elements declared does not meet GAMS norms : start with a letter or a number, followed by letters or numbers, ‘+’, ‘-‘ or ‘_’ and a maximum of 63 characters. Furthermore, you may not use a reserved word. SET C crops / +wheat, +maize/ ;

* the name +wheat and +maize was given to the elements instead of wheat and maize

409 Error 409

Unrecognizable item – skip to find a new statement        looking for a ‘;’ or a key word to get started again

  EQUATIONS
OBJECTIVE       objective function
LAND          soil constraint
LABOUR         labour constraint
;
OBJECTIVE..  sum(c, mb(c)*X(c)) =e= Z ;
LABOUR..  sum(c, bmo(c)*X(c)) =l= dmo ;
LAND..    sum(c, X(c)) =l= dterre 
*omission ; here

Errors at the end of the model which indicate that resolution has not been successfully carried out :

Error 256
Error(s) in analysing solve statement. More detail appears
Below the solve statement above

Error 257
Solve statement not checked because of previous errors