A new object oriented MATLAB API

Posted on: 01 Feb, 2021 MATLAB Features

MATLAB is a de-facto standard in many fields of science and engineering and is a good combination with GAMS. Until now, MATLAB users had to use the GDXMRW suite of utilities for interfacing with GAMS. However, for other programming languages such as Java or Python, we have been providing more advanced object oriented APIs since 2012. These APIs offer some real benefits for controlling and interacting with GAMS.

We are proud to now also announce the MATLAB version of the object oriented API, which ships with GAMS 34 and allows:

The new API works both with Matlab, as well as GNU Octave, release 5.2 or newer.

Here is a simple example

% create workspace
ws = GAMS.GAMSWorkspace();
% create GAMSJob 't' from 'trnsport' model in GAMS Model Libraries
t = ws.addJobFromGamsLib('trnsport');
% run GAMSJob 't'
% retrieve GAMSVariable 'x' from GAMSJob's output databases
for x = t.outDB.getVariable('x').records
    fprintf('x(%s,%s): level=%g marginal=%g\n', x{1}.keys{:}, x{1}.level, x{1}.marginal);

More examples: https://www.gams.com/34/docs/apis/examples_matlab/files.html

Feel free to play around with the new API and let us know what you think on Twitter.