Loading...
Searching...
No Matches
gams.control.execution.GamsJob Class Reference

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

Public Member Functions

def __init__ (self, ws, file_name=None, source=None, checkpoint=None, job_name=None)
 Constructor.
 
def run (self, gams_options=None, checkpoint=None, output=None, create_out_db=True, databases=None)
 Run GamsJob.
 
def run_engine (self, engine_configuration, extra_model_files=None, engine_options=None, gams_options=None, checkpoint=None, output=None, create_out_db=True, databases=None, remove_results=True)
 Run GamsJob on GAMS Engine.
 
def interrupt (self)
 Send Interrupt to running Job.
 

Properties

property name = property(get_job_name)
 Retrieve name of GamsJob.
 
property workspace = property(get_workspace)
 Get GamsWorkspace containing GamsJob.
 
property 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.control.execution.GamsJob.__init__ (   self,
  ws,
  file_name = None,
  source = None,
  checkpoint = None,
  job_name = None 
)

Constructor.

Note
It is not allowed to specify both file_name and source at the same time.
Parameters
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.control.execution.GamsJob.interrupt (   self)

Send Interrupt to running Job.

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

Returns
False if no process available, True otherwise

◆ run()

def gams.control.execution.GamsJob.run (   self,
  gams_options = None,
  checkpoint = None,
  output = None,
  create_out_db = True,
  databases = None 
)

Run GamsJob.

Parameters
gams_optionsGAMS options to control job
checkpointGamsCheckpoint to be created by GamsJob
outputStream to capture GAMS log (e.g. sys.stdout or an object created by the build-in function open())
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

◆ run_engine()

def gams.control.execution.GamsJob.run_engine (   self,
  engine_configuration,
  extra_model_files = None,
  engine_options = None,
  gams_options = None,
  checkpoint = None,
  output = None,
  create_out_db = True,
  databases = None,
  remove_results = True 
)

Run GamsJob on GAMS Engine.

Parameters
engine_configurationGamsEngineConfiguration object
extra_model_filesList of additional file paths (apart from main file) required to run the model (e.g. include files)
engine_optionsDictionary of GAMS Engine options to control job execution
gams_optionsGAMS options to control job
checkpointGamsCheckpoint to be created by GamsJob
outputStream to capture GAMS log (e.g. sys.stdout or an object created by the build-in function open())
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
remove_resultsRemove results from GAMS Engine after downloading them