|
Improperly placed semi colons - error A |
Top Previous Next |
|
What is wrong in the example above? The cause is what is probably the most common GAMS error for new users -- the placement of semi colons. GAMS commands should be terminated with a semi colon (;). However, commands can occupy more than one line. In the above case the original input looked like the following. (errsemic.gms) SET PERIODS TIME PERIODS /T1*T5/; ELAPSED ELAPSED TIME /1*12/ ; PRODUCTS LIST OF PRODUCTS /WHEAT,STRAWBERRY/;
This SET command is meant to continue for several lines, but the semi colon at the end of the first line terminates it. In turn, GAMS is looking for a command phrase in the second line and does not recognize the word ELAPSED, so it says UNKNOWN SYMBOL. The error is repeated at the end of the second line with yet another semi colon. There are two ways of fixing this. One may get rid of the semi colons in the first 2 lines only leaving a semi colon at the actual end of the SET declaration (i.e., the end of the third line) or one may enter the word SET on the second line and third lines. Note GAMS does not strictly require a semicolon at the end of each command. In particular when the next line begins with one of the recognized GAMS keywords (SET, PARAMETER, EQUATIONS etc.) then a semicolon is assumed. However, it is good practice to terminate all commands with a semicolon. Certainly the lines before all calculations and equation specifications (.. lines) must have a semicolon. |