gams.execution.GamsJob Class Reference

The GamsJob class manages the execution of a GAMS program given by GAMS model source. More...

Inherits object.

Public Member Functions

def __init__ (self, ws, file_name=None, source=None, checkpoint=None, job_name=None)
 Constructor. More...
def run (self, gams_options=None, checkpoint=None, output=None, create_out_db=True, databases=None)
 Run GamsJob. More...
def interrupt (self)
 Send Interrupt to running Job. More...


 name = property(get_job_name)
 Retrieve name of GamsJob.
 workspace = property(get_workspace)
 Get GamsWorkspace containing GamsJob.
 out_db = property(get_out_db)
 Get GamsDatabase created by run method.

Detailed Description

The GamsJob class manages the execution of a GAMS program given by GAMS model source.

The GAMS source (or more precisely the root of a model source tree) of the job can be provided as a string or by a filename (relative to the working directory of the GamsWorkspace) of a text file containing the GAMS model source. The run method organizes the export of the input GamsDatabases, calls the GAMS compiler and execution system with the supplied options and on successful completion provides through the property out_db (of type GamsDatabase) the results of the model run.

While the result data is captured in a GamsDatabase, the run method can also create a GamsCheckpoint that not only captures data but represents the state of the entire GamsJob and allows some other GamsJob to continue from this state. In case of a compilation or execution error, the run method will throw an exception. If the log output of GAMS is of interest, this can be captured by providing the output parameter of the run method (e.g. sys.stdout).

Constructor & Destructor Documentation

◆ __init__()

def gams.execution.GamsJob.__init__ (   self,
  file_name = None,
  source = None,
  checkpoint = None,
  job_name = None 


It is not allowed to specify both file_name and source at the same time.
wsGamsWorkspace containing GamsJob
file_nameGAMS source file name
sourceGAMS model as string
checkpointGamsCheckpoint to initialize GamsJob from
job_nameJob name (determined automatically if omitted)

Member Function Documentation

◆ interrupt()

def gams.execution.GamsJob.interrupt (   self)

Send Interrupt to running Job.

Note: On Mac OS this call requires the tool pstree to be installed

False if no process available, True otherwise

◆ run()

def (   self,
  gams_options = None,
  checkpoint = None,
  output = None,
  create_out_db = True,
  databases = None 

Run GamsJob.

gams_optionsGAMS options to control job
checkpointGamsCheckpoint to be created by GamsJob
outputStream to capture GAMS log
create_out_dbFlag to define if out_db should be created
databasesEither a GamsDatabase or a list of GamsDatabases to be read by the GamsJob