Matlab API

GAMS Matlab API provides a Matlab programming interface to the General Algebraic Model System (GAMS). GAMS Matlab API objects allow a convenient way to exchange input data and model results with in-memory representation of data (GAMSDatabase), and to create and run GAMS models (GAMSJob) that can be customized by GAMS options (GAMSOptions). Furthermore, they introduce a way to solve a sequence of closely related model instances in a more efficient way (GAMSModelInstance).

Note
There also exists the data exchange tool GDXMRW to exchange data between Matlab and GDX files. Note that the GDXMRW can be more efficient in case of exchanging very large data sets. However, the GAMS Matlab API offers more features, for example, to start and modify a GAMS job.

The underlying GAMS engine relies to some extent on file based communication (e.g. the listing file) and other unmanaged resources. Since the GAMS Matlab API is based on the GAMS Java API, the use of external resources in the Java environment requires special attention. Hence, some objects need to be properly disposed before the Java garbage collector does its job.

A GAMS program can include other source files (e.g. $include), load data from GDX files (e.g. $GDXIN or execute_load), and create PUT files. All these files can be specified with a (relative) path and therefore an anchor into the file system is required. The base object GAMSWorkspace manages the anchor to the file system.

With the exception of GAMSWorkspace the objects in the gams package cannot be accessed across different threads unless the instance is locked. The classes themselves are thread safe and multiple objects of the class can be used from different threads (see below for restrictions on solvers that are not thread safe within the GAMSModelInstance class).

Note
If you use multiple instances of the GAMSWorkspace in parallel, you should avoid using the same WorkingDirectory. Otherwise you may end up with conflicting file names.

Currently only Cplex, Gurobi, and SoPlex fully utilize the power of solving GAMSModelInstances. Some solvers will not work in a multi-threaded application using GAMSModelInstances. For some solvers this is unavoidable because the solver library is not thread safe (e.g. MINOS), other solvers are in principle thread safe but the GAMS link is not (e.g. SNOPT). Moreover, GAMSModelInstances are not available for quadratic model types (QCP, MIQCP, RMIQCP).

This version of the GAMS Matlab API also does not provide support for the following GAMS components: acronyms, GAMS compilation/execution errors, structured access to listing file, and solver options.