Related:

Command language

The Gekko command language takes advantage of the timeseries-oriented nature of Gekko. You can perform general programming tasks in the command language, but using it for timeseries data management or modeling show its particular forte.

See the list of all features, or read more about language and programming below.

Short-list of all main Gekko features
  • Timeseries-oriented software, with flexible databanks. Array-series (for sparse data) are provided.
  • Data tracing: trace origins of timeseries data backwards in time.
  • Annual, quarters, months, weekly, daily and undated frequencies supported. Conversions between these are in-built.
  • Values, dates, strings, lists, maps, etc., including many functions dealing with these.
  • Matrix calculations, including construction, addition, multiplication, inversion, etc. Also supports nested lists that can represent arrays of data.
  • Seasonal correction via X12A.
  • Graphics by means of embedded gnuplot.
  • User-defined functions and procedures, and libraries can be used to store these.
  • Dynamically loaded and compiled models, including failsafe mode.
  • Gauss and Newton solvers, with ordering and feedback logic. Fair-Taylor or Newton-Fair-Taylor solver for forward-looking models. Any number of simultaneous goals/means possible.
  • In-built equation browser, with integrated labels/explanations.
  • Decomposition/tracking of changes in model equations (also supports GAMS models).
  • GAMS-style expressions supported, including sums over sets, $-conditionals, etc.
  • Tabelling and menu system, outputting in text, html or Excel.
  • Read/write from Excel or other spreadsheets. Formats like tsd, prn, csv also supported.
  • So-called 'Gekcel' add-in for Excel, so that Gekko can be used from within an Excel workbook.
  • Interface to open-source Python or R for econometrics, data mining and many other things.
  • Strict language syntax (via in-built ANTLR parser), with loops, conditionals etc.
  • Free, open source. Easy installation, and used by many Danish organizations.

Timeseries databanks are often organized using some naming patterns/schemes. For instance, the timeseries may use the pattern K{%i}{%j} to state the type {%i} and sector {%j} of capital stocks, for instance Kma, Kmo, Kba, Kbo, where the capital types are ‘m’ and ‘b’, and the sectors are ‘a’ and ‘o’. Looping over and handling such name patterns is central in Gekko, for instance:

FOR string %i = m, b;
  FOR string %j = a, b;
    K{%i}{%j} <2015 2020> = K{%i}{%j}[-1];
  END;
END;

This loops over the types ‘m’ and ‘b’, combined with the sectors ‘a’ and ‘o’. Inside the loop, the capital stock is set equal to the lagged capital stock, that is, the capital stock in the previous time period, effectively telling Gekko to use the values in 2014 for the period 2015-2020. The loop is equivalent to:

Kma <2015 2020> = Kma[-1];
Kmo <2015 2020> = Kmo[-1];
Kba <2015 2020> = Kba[-1];
Kbo <2015 2020> = Kbo[-1];

These four K-timeseries might be reside in a Gekko databank, or alternatively as rows or columns in a spreadsheet or .csv file or some other file format. Central to Gekko is the idea that a string (a sequence of letters inclosed in hyphens, for instance ‘Kma’) can be used either as the string itself (the collection of these particular letters and symbols), or to refer to a timeseries. This might not sound like such a big deal, but in practice it helps to keep the Gekko syntax simple and compact.

In some languages, accessing timeseries like K{%i}{%j} above would have to be done using some function syntax, for instance something like get(“K” + i + j, t) or get(“K”, i, j, t), where t is the time period. Even the lag might not be straightforward, if the frequency is not annual, so that you would have to use a lag() function, for instance get(“K” + i + j, lag(t, -1)) instead of K{%i}{%j}[-1]. This is just an example, but if the software language is for instance matrix-oriented, timeseries manipulations quickly end up being quite verbose and unnatural.