Table of Contents
The GAMS Matlab Control API is built on top of the GAMS Java Control API and provides convenient access to GAMS from within Matlab (2017b or later) and Octave (5.2 or later).
Install
The Matlab API is located in api/matlab
. Add this directory to the Matlab path:
Furthermore, make Matlab aware of the GAMS Java API (see also GAMS Java API below):
GAMS Java API
Instead of adding the GAMS Java API dynamically as done above, it is also possible to add it statically. For this, locate javaclasspath.txt
and add the path [PathToGAMS]/apifiles/Java/api/GAMSJavaAPI.jar
. You can find the location with cd(prefdir)
in Matlab or which javaclasspath
in Octave. Finally, restart Matlab or Octave. Adding the GAMS Java API statically is more efficient.
- Attention
- Since GAMS 44.1.0, the GAMS Java API requires at least Java SE 11 to compile and run. Matlab usually ships Java SE 8. In that case use
GAMSJavaAPI-8.jar
instead ofGAMSJavaAPI.jar
. However, new or updated functionalities that are released after GAMS 43 are not avaiable in this Java API version. Since Matlab R2023a, Matlab does support Java SE 11 (although it may have to be installed by the user). You can usejenv system
to use the Java installed on the system instead of Matlab's shipped Java.
Important Classes
This section provides a quick overview of some fundamental classes of the GAMS Control package. Their usage is demonstrated by an extensive set of examples (located in api/matlab/examples
). All GAMS Matlab Control API classes are contained within the package gams.control
(with subpackages gams.control.globals
, gams.control.engine
and gams.control.options
). The package provides objects to interact with the General Algebraic Modeling System (GAMS). Objects in this package allow convenient exchange of input data and model results (Database) and help to create and run GAMS models (Job), that can be customized by GAMS options (Options). Furthermore, it introduces a way to solve a sequence of closely related models in the most efficient way (ModelInstance).