Conditional Compilation

Top  Previous  Next

GAMS provides commands that allow significant compile time changes in the basic structure of any set of GAMS instructions dependent on user defined items.  These features allow one do several things including

Simplify maintenance of models that share common features but have significant differences involving features that could not simultaneously exist in a compiled GAMS code.
Add memory, execution time or solver requirements that are desirable to avoid if not needed.
Develop utilities that may be used across a wide variety of applications in different contexts.

Any of these items can be structured so that they can be activated or deactivated by the choice of a single controlling variable, as I will show below.

 

Control variables

Environment variables

$If and $Ifi conditionals

Forms of conditionals

Incorporating Goo: $Goto and $Label

Redefining expressions

Running external programs or commands

Writing messages to LST, LOG and other files

End the job: $Exit, $Abort, $Error, $Stop, $Terminate

Longer examples