For previous users only: A new interface between MATLAB and GAMS (version 2.0)
We are pleased to announce a new major release of the MATLAB/GAMS interface.
The new interface merges the read and write routines of GDXMRW and the
original MATLAB/GAMS interface into one system with three routines:
- gams - a routine that allows gams to be executed as a Matlab function.
- rgdx - a routine for reading "gdx" files directly into Matlab structures.
- wgdx - a routine for writing "gdx" files that can be read directly into Gams models.
Placeholders for the deprecated routines (from version 1 of GDXMRW)
readgdx.m
and
writegdx.m
are also provided but the user is encouraged to switch to the new, more
efficient rgdx and wgdx routines. The routine "gams" is not backwards
compatible: calls of the old form:
gams('qp', Q)
must be replaced by (for example)
sQ.name = 'Q'; sQ.val = Q; gams('qp',sQ);
(due to a change by Matlab in the mex interface).
There is also a requirement for a "header" line in the GAMS file if
you are using output parameters and some changes to the syntax within
the GAMS file are needed.
From version 23.4 of GAMS onwards, the MATLAB facilities are provided within
the GAMS distribution
(download current GAMS distribution)
for Windows, Mac and Linux platforms. Simpler installation procedures are
provided in the documentation in the GAMS distribution or online at:
(GDXMRW new version installation and documentation).
Deprecated ways of interfacing MATLAB and GAMS
Current documentation
(for version 008) is available only as a pdf file.
Note that this version includes the ability to do execution time
over-writing of parameters, and uses a slightly different scheme for
passing parameters from MATLAB to GAMS. It is only available for PC,
linux and solaris boxes.
Original version of the documentation:
Mathematical Programming Technical Report 98-19, November 1998.
Two alternatives for interfacing MATLAB and GAMS
There are two possible ways to interface between Matlab and GAMS.
The first mechanism is provided as a download below and allows you to pass
data to and from a gams program via parameters to a "gams mex interface".
This can be invoked for example as:
In this setting "qp.gms" is a GAMS file that contains a few extra lines
to facilitate the read-in of Q and the write-out of the solution x.
Examples are given in the documentation found above on this page.
The second mechanism is to use the GDXMRW facilities that are available
and documented as
GDXMRW download.
Essentially two mex procedures are provided that read and write a gdx file.
A GAMS program can then use built in GAMS procedures to read and write these
same gdx files. The invocation in GAMS would be something like:
- qsp = full2sp(Q,'par');
- writegdx('q.gdx','par','Q',qsp);
- system('gams qp');
- xsp = readgdx('x.gdx','x');
- x = sp2full(xsp,'par');
The writegdx call creates a file q.gdx containing the data that is in the matlab matrix Q. The file qp.gms would read this in using "$gdxin" or execute_load. More details can be found at
GDX documentation.
The readgdx routine reads the file x.gdx that was created by the qp.gms file
into a matlab matrix x. Some helper utilities sp2full and full2sp are
provided that help manipulate the input and output data structures (that are
basically in i,j,val format) to have the correct (dense) matlab matrix
structure.
Download and installation instructions
All the files needed to
download
this link are available on
the ftp site of the Computer Sciences Department at the University of Wisconsin.
Several examples of the use of this link are found in this "zip" file,
along with instructions for installation. It is suggested that the
archive file "matgams.zip" is unzipped ("unzip matgams.zip") in a new
directory.
If you download and use this software, please acknowledge use by
citing the above technical report in your work.
Previously used versions are also still downloadable but without any
support provided.
-
Current version should work for solaris (64), windows (32 and 64) and
lnx (32 and 64).
-
2007: This worked for 32 and some 64 bit versions of Matlab (7.3).
-
2005: This worked for 32 bit versions of Matlab (7.0, 7.1 and 7.2).
-
2003: This worked for
versions of MATLAB prior to version 7, and is no longer supported. If
you wish to use this, you should you the original documentation as
provided above.
For windows users, the above zip file contains the dll for
version 6.5 of Matlab. It seems the dll is not backwards
compatible.
For users of version 6 to 6.49, a dll that appears
to work can be found in this
zip archive.
A version 5 matlab "gams.dll" can be found in this
zip archive. This comes as is, and no bug fixing or support
will be provided.
To use these versions, just unzip the 2003 archive and use the resulting
gams.dll in place of the version 6.5 dll that comes with that
distribution.
Example output
Sample output from a tomotherapy example can be found in
PDF form.
These pictures are associated with a project described in:
David M. Shepard, Michael C. Ferris, Gustavo Olivera and Thomas R. Mackie
Optimizing the Delivery of Radiation to Cancer Patients.
Mathematical Programming Technical Report 98-07, June 1998.
This file is large since it contains a bunch of postscript figures.
Compressed versions are also available for download:
UNIX compress,
ZIP archive.