Install
GAMS comes with a ready-to-use GAMS Transfer Matlab (for Matlab 2018a or newer). Simply add the GAMS Matlab API to the Matlab path:
For other software products, e.g. Octave, you must compile the MEX source code first. Simply run:
Example
As an introductory example, we consider creating a GDX file in Matlab with content equal to the solution data of model trnsport.
Create with GAMS:
Create with Matlab:
The example illustrates the general GAMS Transfer workflow: A Container can be filled with different symbols, here are shown Set, Parameter, Variable and Equation (not shown: Alias) and is later written to a GDX file.
Instead of starting with an empty container in
one could initialize it by reading from a GDX file:
Each symbol in the container has multiple symbol records – the actual data – that can be provided at symbol creation (see for example set i
), but adding or modifying data thereafter is possible, too.
A symbol, e.g. the variable x
(also accessible through m.data.x
), stores its symbol records in x.records
, but provides further meta data:
Besides name
and description
each symbol has modifyable meta data dimension
, size
and domain
to define the symbol domain and shape as well as the possible dependency on other sets. Note that size
is of particular importance when using matrix like record formats to store symbol records (compare property format
).
The example further shows that in table like matrix like record formats the first dimension
columns are the record's domain information with column names domain_labels
. Added record value columns follow (level
and marginal
). Missing value columns, here lower
, upper
and scale
are considered to hold default values specified by default_values
– in this example 0, Inf and 1, respectively.