|
<< Click to Display Table of Contents >> Gekko 2.4 to 3.x cheat sheet |
![]() ![]()
|
The following "cheat sheet" shows syntax differences between Gekko 2.4 and 3.x, focusing on some of the most oft-used parts of Gekko 2.4. Regarding 3.x syntax, the short elevator pitch is a useful read, and besides there is the guide. Among other thinds, the syntax changes in 3.x have to do with (a) how the symbols % and # are interpreted, (b) databanks now contain all kinds of variables not just series, and (c) lists now contain all kinds of variables not just strings (more on this here). Beware that "2.4" covers all versions 2.x.x. A two-page printing-ready pdf version of the cheat sheet is available here.
Gekko 2.4 to 3.x cheat sheet |
||
Series |
Gekko 2.4 |
Gekko 3.x |
definition element access list of names
frequency symbol |
series x = 1, 2, m, 3; |
x = 1, 2, m(), 3; |
Lists |
Gekko 2.4 |
Gekko 3.x |
list of strings singleton list 'funny' strings mix strings and lists
listfile f.lst out listfile f.lst in
union intersection difference concatenate
prefix (and suffix) remove element text sort/trim
element access print list elements print series |
list m1 = a, b, c; list m1 = a; list m = #m2 strip = 'z'; |
#m1 = a, b, c; #m1 = a,; |
Scalars |
Gekko 2.4 |
Gekko 3.x |
value definition date definition string definition string concatenate print string print series |
val v = 1.23; string s2 = 'a' + %s + 'b'; |
%v = 1.23; %s2 = 'a{%s}b'; //or like 2.4 |
Wildcards |
Gekko 2.4 |
Gekko 3.x |
index with wildcard index with range search inside databank search inside list print matching series |
index x* m; |
index x* to #m; |
Loops |
Gekko 2.4 |
Gekko 3.x |
date loop |
for date d = %d1 to %d2; ... |
for date %d = %d1 to %d2; ... |
Matrix |
Gekko 2.4 |
Gekko 3.x |
matrix definition element access print matrix print matrix |
matrix m = [1, 2 || 3, 4]; |
#m = [1, 2; 3, 4]; |
Miscellaneous |
Gekko 2.4 |
Gekko 3.x |
import for all periods export for all periods use {} for path parts value to survive read list to survive read |
import <csv> data; |
import <csv all> data; |
Model/sim example |
Gekko 2.4 |
Gekko 3.x |
The model/sim syntax is very similar. In 3.x, lists and scalars that must survive read statements must be placed in the Global databank. Series operators include a "=" symbol. And you must use more {}-curlies when referring to scalars and lists. |
reset; |
reset; |
About {}-curlies in Gekko 3.x |
||
In Gekko 3.x, it is more often required to enclose a string %s or a list of strings #m in curlies, that is, {%s} or {#m}. This applies to the following statements: assignments, analyze, checkoff, collapse, compare, copy, disp, doc, endo, exo, export, findmissingdata, import, interpolate, itershow, ols, prt/mulprt/plot/sheet, read, rebase, rename, smooth, splice, truncate, write, x12a, where assignments refer to series/scalar/list etc. statements. Consider this difference:
delete {%s}, {#m}; delete %s, #m;
If the string %s contains 'x1' and the list #m contains the strings 'x2', 'x3', 'x4', the first statement deletes the series x1, x2, x3, x4 (4 in all). In the next statement, it is the string and list objects %s and #m themselves that are deleted (2 in all). Understanding this conceptual difference is important! |
||