The GAMS Matlab Control API provides a Matlab programming interface to the General Algebraic Model System (GAMS). GAMS Matlab Control API objects allow a convenient way to exchange input data and model results with in-memory representation of data (Database), and to create and run GAMS models (Job) that can be customized by GAMS options (Options). Furthermore, they introduce a way to solve a sequence of closely related model instances in a more efficient way (ModelInstance).
- Note
- If you only want to exchange data between Matlab and GAMS, use GAMS Transfer Matlab as it is very likely to be more efficient than GAMS Matlab Control API in case of exchanging very large data sets.
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 Control 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 Workspace manages the anchor to the file system.
With the exception of Workspace 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 ModelInstance class).
- Note
- If you use multiple instances of the Workspace in parallel, you should avoid using the same working directory. Otherwise you may end up with conflicting file names.
Currently only Cplex
, Gurobi
, and SoPlex
fully utilize the power of solving ModelInstances. Some solvers will not work in a multi-threaded application using ModelInstances. For some solvers this is unavoidable because the solver library is not thread safe (e.g. MINOS
). Moreover, ModelInstances are not available for quadratic model types (QCP, MIQCP, RMIQCP).
This version of the GAMS Matlab Control API also does not provide support for the following GAMS components: acronyms, GAMS compilation/execution errors, structured access to listing file, and solver options.
To get started, see Getting Started.
New Class Names
With GAMS 46 the GAMS Matlab Control API has been restructured and classes have been renamed. The following lists a mapping of old to new class names:
GAMS.AbstractRunParameters: gams.control.AbstractRunParameters
GAMS.GAMSCheckpoint: gams.control.Checkpoint
GAMS.GAMSDatabase: gams.control.Database
GAMS.GAMSDatabaseDomainViolation: gams.control.DatabaseDomainViolation
GAMS.GAMSEngineConfiguration: gams.control.engine.Configuration
GAMS.GAMSEngineJob: gams.control.engine.Job
GAMS.GAMSEngineJobBuilder: gams.control.engine.JobBuilder
GAMS.GAMSEngineRunParameters: gams.control.engine.RunParameters
GAMS.GAMSEquation: gams.control.Equation
GAMS.GAMSEquationRecord: gams.control.EquationRecord
GAMS.GAMSGlobals: gams.control.Globals
GAMS.DebugLevel: gams.control.globals.DebugLevel
GAMS.UpdateAction: gams.control.globals.UpdateAction
GAMS.ModelStat: gams.control.globals.ModelStat
GAMS.SolveStat: gams.control.globals.SolveStat
GAMS.SetType: gams.control.globals.SetType
GAMS.VarType: gams.control.globals.VarType
GAMS.EquType: gams.control.globals.EquType
GAMS.ArchType: gams.control.globals.ArchType
GAMS.OSType: gams.control.globals.OSType
GAMS.GAMSJob: gams.control.Job
GAMS.GAMSModelInstance: gams.control.ModelInstance
GAMS.SymbolUpdateType: gams.control.globals.SymbolUpdateType
GAMS.GAMSModelInstanceOpt: gams.control.ModelInstanceOpt
GAMS.GAMSModifier: gams.control.Modifier
GAMS.GAMSOptions: gams.control.Options
GAMS.ZeroResRep: gams.control.options.ZeroResRep
GAMS.TraceOpt: gams.control.options.TraceOpt
GAMS.TFormat: gams.control.options.TFormat
GAMS.SysOut: gams.control.options.SysOut
GAMS.Sys11: gams.control.options.Sys11
GAMS.Sys10: gams.control.options.Sys10
GAMS.Suppress: gams.control.options.Suppress
GAMS.SuffixAlgebraVars: gams.control.options.SuffixAlgebraVars
GAMS.SuffixDLVars: gams.control.options.SuffixDLVars
GAMS.StringChk: gams.control.options.StringChk
GAMS.strictSingleton: gams.control.options.strictSingleton
GAMS.StepSum: gams.control.options.StepSum
GAMS.SolveOpt: gams.control.options.SolveOpt
GAMS.SolveLink: gams.control.options.SolveLink
GAMS.SolPrint: gams.control.options.SolPrint
GAMS.ShowOSMemory: gams.control.options.ShowOSMemory
GAMS.SavePoint: gams.control.options.SavePoint
GAMS.Replace: gams.control.options.Replace
GAMS.ReferenceLineNo: gams.control.options.ReferenceLineNo
GAMS.PyMultInst: gams.control.options.PyMultInst
GAMS.PutNR: gams.control.options.PutNR
GAMS.ProcTreeMemMonitor: gams.control.options.ProcTreeMemMonitor
GAMS.PreviousWork: gams.control.options.PreviousWork
GAMS.PrefixLoadPath: gams.control.options.PrefixLoadPath
GAMS.PageContr: gams.control.options.PageContr
GAMS.On115: gams.control.options.On115
GAMS.NoNewVarEqu: gams.control.options.NoNewVarEqu
GAMS.MIIMode: gams.control.options.MIIMode
GAMS.LstTitleLeftAligned: gams.control.options.LstTitleLeftAligned
GAMS.LogLine: gams.control.options.LogLine
GAMS.Listing: gams.control.options.Listing
GAMS.Keep: gams.control.options.Keep
GAMS.IntVarUp: gams.control.options.IntVarUp
GAMS.InteractiveSolver: gams.control.options.InteractiveSolver
GAMS.ImplicitAssign: gams.control.options.ImplicitAssign
GAMS.HoldFixedAsync: gams.control.options.HoldFixedAsync
GAMS.HoldFixed: gams.control.options.HoldFixed
GAMS.gdxUels: gams.control.options.gdxUels
GAMS.gdxConvert: gams.control.options.gdxConvert
GAMS.gdxCompress: gams.control.options.gdxCompress
GAMS.FreeEmbeddedPython: gams.control.options.FreeEmbeddedPython
GAMS.ForceWork: gams.control.options.ForceWork
GAMS.Filtered: gams.control.options.Filtered
GAMS.FileCase: gams.control.options.FileCase
GAMS.FDOpt: gams.control.options.FDOpt
GAMS.ExecMode: gams.control.options.ExecMode
GAMS.ErrMsg: gams.control.options.ErrMsg
GAMS.Empty: gams.control.options.Empty
GAMS.ECImplicitLoad: gams.control.options.ECImplicitLoad
GAMS.DumpParms: gams.control.options.DumpParms
GAMS.DumpOpt: gams.control.options.DumpOpt
GAMS.Digit: gams.control.options.Digit
GAMS.DFormat: gams.control.options.DFormat
GAMS.CheckErrorLevel: gams.control.options.CheckErrorLevel
GAMS.CharSet: gams.control.options.CharSet
GAMS.LstCase: gams.control.options.LstCase
GAMS.CaptureModelInstance: gams.control.options.CaptureModelInstance
GAMS.AsyncSolLst: gams.control.options.AsyncSolLst
GAMS.AppendOut: gams.control.options.AppendOut
GAMS.AppendExpand: gams.control.options.AppendExpand
GAMS.Action: gams.control.options.Action
GAMS.GAMSParameter: gams.control.Parameter
GAMS.GAMSParameterRecord: gams.control.ParameterRecord
GAMS.GAMSRunParameters: gams.control.RunParameters
GAMS.GAMSSet: gams.control.Set
GAMS.GAMSSetRecord: gams.control.SetRecord
GAMS.GAMSSymbol: gams.control.Symbol
GAMS.GAMSSymbolDomainViolation: gams.control.SymbolDomainViolation
GAMS.GAMSSymbolRecord: gams.control.SymbolRecord
GAMS.GAMSVariable: gams.control.Variable
GAMS.GAMSVariableRecord: gams.control.VariableRecord
GAMS.GAMSWorkspace: gams.control.Workspace
GAMS.GAMSWorkspaceInfo: gams.control.WorkspaceInfo