Download presentation
Presentation is loading. Please wait.
Published byCecil Richards Modified over 9 years ago
1
GAMS advanced syntax From McCarl Guide From own guess-based experiments
2
System Attributes
3
Gams Attributes
4
System Attributes System.<attribute> Parameter report1(*); Set report2(*); report1("memory")=%system.memory%; report2("%system.date%")=yes; display report1,report2;
5
GAMS Attributes Command line arguments gams.<attribute> Parameter report1(*); Set report2(*); report1(“lpsolver")=%gams.lp%; report2("%gams.lp%")=yes; display report1,report2;
6
GAMS Timing Compilation Syntax check $control operations Execution Syntax execution
7
At Execution Time Execute normal GAMS syntax: Data(Set)=normal(10,2); Solve, If, Sum, Smin, Loop, … Execute, Execute_unload Option, Display, …
8
At Compilation Time Check GAMS syntax Execute special $ sign syntax $call $load $unload
9
Save Restart Break code into sequentially executed pieces Avoids compile time problems (if code segment 1 produces a file to be used in code segment 2) Can be nicely automated
10
$ Dollar Options $ must be in first column Several $ options can be in one line $onlisting offsymlist Some options require values, e.g. $eolcom @$ Generally, carried out at compile time!
11
External file inclusion $include filename $libinclude filename $libinclude filename $batinlcude filename $batinlcude filename $sysinclude filename $sysinclude filename Can append path statements before filename (absolute, relative, %var%)
12
GDX $Control Variables $Gdxin filename.gdx $Load p1 s1 $Gdxin $Gdxout filename.gdx $Unload p1 s1 dangerous because $Gdxout of compile time For unload use better: Execute_Unload
13
Output (*.lst file) $Control $onlisting $offlisting $onuellist $offuellist $onupper $offupper $show $single $double $onsymlist $offsymlist $onsymxref $offsymxref $offdollar $ondollar $offinclude $oninclude …
14
Input file control $offmargin $onmargin $mincol 20 maxcol 40 $ondelim $offdelim $ontext $offtext $offglobal $onglobal
15
Messages / Comments $log $error $error $remark $title $stitle $hidden $oneolcom $offeolcom $oninline $offinline $offnestcom $onnestcom
16
GAMS syntax symbol substitution $comment $comment $stars $dollar $eolcom $inlinecom Why change?
17
Forced program termination $exit… quits only local file $abort text… stops entire compilation $stop… stops without error $goto name… jumps to: $label name Usually these termination statements are combined with $if statements
18
Control Variables $set name value $setlocal name value $setglobal name value $drop name $droplocal name $dropglobal name Action scope differs: (setlocal < set < setglobal) (setlocal < set < setglobal)
19
Conditional Control Statements $If condition statementtoexecute $Ifi… case insensitive $if version $ife… $ifthen $ifelse $else
20
GAMS Symbol Tests $if exist filename statement $if dexist dirname statement $if declared symbol statement $if dimension 4 symbol statement $if defined symbol statement $if putopen statement $if settype symbol statement (partype, filtype, equtype, vartype, modtype, …) $if errorfree gamsstatement $if errorlevel n gamsstatement $if warnings gamsstatement Statement can be special or normal gams syntax
21
File Creation at Compile Time $Onecho > file $Offecho
22
$Macro $macro ratio(a,b) a/b $macro reciprocal(a) 1/a Scalar a /2/,d/4/,c; c=ratio(a,d); display c; c=reciprocal(d);
23
Other features ask Allows user dialog
24
Undocumented $maxgoto$onuni
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.