|
Now that I have been through the most essential basic elements of the GAMS syntax, I can review the general format of GAMS statements and GMS files. A GAMS program is a collection of statements in the GAMS language. A number of comments can be made about how the file needs to be formatted
| • | Statements must be ordered so that items are initially declared before they are used. If they are used on the right hand side of a calculation (an = statement) they also must be given data before use. If they are used in a model equation then they must be given data before a Solve appears. This is enforced by GAMS indicating a lack of declaration and numerical specification as a compilation error so one does not need to meticulously check order of declaration, definition and use.1 |
| • | Individual GAMS statements can be formatted in almost any style. Multiple lines may be used for a statement, blank lines can be embedded, any number of spaces or tabs may be inserted and multiple statements may be put on one line separated by a ; |
| • | Every GAMS statement should be terminated with a semicolon, as all the examples in this book illustrate. |
| • | GAMS is not case sensitive, thus it is equivalent to type the command VARIABLE as variable or the variable names XCOTTON as XcOttoN. However, there is case sensitivity with respect to the way things are printed out with the first presentation being the one used as discussed in the Rules for Item Capitalization and Ordering chapter. |
Declaration where one announces the existence of a named item giving it a name.
Assignment giving it a specific value or replacing its value with the results of an expression.
Subsequent usage.
1 This and a number of the other points in this section are adapted from Richard E. Rosenthal's "A GAMS Tutorial" that appeared in the GAMS Users Guide documents by Brooke et al.
|