Loading...
Searching...
No Matches
gams::GAMSJob Class Reference

#include <gamsjob.h>

Public Member Functions

 GAMSJob ()
 Standard constructor.
 
 ~GAMSJob ()
 Desctructor.
 
GAMSJob operator= (const GAMSJob &other)
 
bool operator!= (const GAMSJob &other) const
 
bool operator== (const GAMSJob &other) const
 
bool isValid () const
 
void run ()
 Run GAMSJob.
 
void run (std::ostream &outstream)
 
void run (GAMSOptions &gamsOptions)
 
void run (GAMSOptions &gamsOptions, std::ostream &outstream)
 
void run (GAMSOptions &gamsOptions, GAMSDatabase db)
 
void run (GAMSCheckpoint gamsCheckpoint)
 
void run (GAMSOptions &gamsOptions, GAMSCheckpoint gamsCheckpoint)
 
void run (GAMSOptions &gamsOptions, const GAMSCheckpoint &gamsCheckpoint, std::ostream &output, bool createOutDB, const std::vector< gams::GAMSDatabase > &databases)
 
void runEngine (const GAMSEngineConfiguration &engineConfiguration, GAMSOptions *gamsOptions, gams::GAMSCheckpoint *checkpoint, std::ostream *output=nullptr, const std::vector< gams::GAMSDatabase > &databases={}, const std::set< std::string > &extraModelFiles={}, const std::unordered_map< std::string, std::string > &engineOptions={}, bool createOutDB=true, bool removeResults=true)
 
GAMSDatabase outDB ()
 Get GAMSDatabase created by Run method.
 
std::string name ()
 Retrieve name of GAMSJob.
 
GAMSWorkspace workspace ()
 Get GAMSWorkspace containing GAMSJob.
 
bool interrupt ()
 
LogId logID ()
 

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 method OutDB (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, it can be captured by providing a TextWriter instance.

Definition at line 60 of file gamsjob.h.

Constructor & Destructor Documentation

◆ GAMSJob()

gams::GAMSJob::GAMSJob ( )

Standard constructor.

◆ ~GAMSJob()

gams::GAMSJob::~GAMSJob ( )

Desctructor.

Member Function Documentation

◆ interrupt()

bool gams::GAMSJob::interrupt ( )

Send interrupt signal to running GAMSJob Note: On Mac OS using Mono this call requires the tool pstree to be installed

Returns
Returns true when the interrupt signal was sent and false when there is no Job running

◆ isValid()

bool gams::GAMSJob::isValid ( ) const

Check if a GAMSDatabaseDomainViolation is valid.

Returns
Returns true if the GAMSCheckpoint is valid; otherwise false.

◆ logID()

LogId gams::GAMSJob::logID ( )

Get the GAMS log ID.

Returns
Returns the GAMS log ID.

◆ name()

std::string gams::GAMSJob::name ( )

Retrieve name of GAMSJob.

◆ operator!=()

bool gams::GAMSJob::operator!= ( const GAMSJob other) const

Compares two GAMSJob objects.

Parameters
otherAnother GAMSJob to compare to.
Returns
Returns true if the two GAMSJob are different; otherwise false.

◆ operator=()

GAMSJob gams::GAMSJob::operator= ( const GAMSJob other)

Assigns a GAMSJob.

Parameters
otherAnother GAMSJob used as data source.
Returns
Returns the assigned GAMSJob (*this).

◆ operator==()

bool gams::GAMSJob::operator== ( const GAMSJob other) const

Compares two GAMSJob objects.

Parameters
otherAnother GAMSJob to compare to.
Returns
Returns true if the two GAMSJob are equal; otherwise false.

◆ outDB()

GAMSDatabase gams::GAMSJob::outDB ( )

Get GAMSDatabase created by Run method.

◆ run() [1/8]

void gams::GAMSJob::run ( )

Run GAMSJob.

◆ run() [2/8]

void gams::GAMSJob::run ( GAMSCheckpoint  gamsCheckpoint)

Run GAMSJob.

Parameters
gamsCheckpointGAMSCheckpoint to be created by GAMSJob.

◆ run() [3/8]

void gams::GAMSJob::run ( GAMSOptions gamsOptions)

Run GAMSJob.

Parameters
gamsOptionsGAMSOptions to control the GAMSJob.

◆ run() [4/8]

void gams::GAMSJob::run ( GAMSOptions gamsOptions,
const GAMSCheckpoint gamsCheckpoint,
std::ostream &  output,
bool  createOutDB,
const std::vector< gams::GAMSDatabase > &  databases 
)

Run GAMSJob.

Parameters
gamsOptionsGAMSOptions to control the GAMSJob.
gamsCheckpointGAMSCheckpoint to be created by GAMSJob.
outputStream to capture GAMS log.
createOutDBFlag that activates writing to outDB.
databasesGAMSDatabases read by the GAMSJob.

◆ run() [5/8]

void gams::GAMSJob::run ( GAMSOptions gamsOptions,
GAMSCheckpoint  gamsCheckpoint 
)

Run GAMSJob.

Parameters
gamsOptionsGAMSOptions to control the GAMSJob.
gamsCheckpointGAMSCheckpoint to be created by GAMSJob.

◆ run() [6/8]

void gams::GAMSJob::run ( GAMSOptions gamsOptions,
GAMSDatabase  db 
)

Run GAMSJob.

Parameters
gamsOptionsGAMSOptions to control the GAMSJob.
dbGAMSDatabase read by the GAMSJob.

◆ run() [7/8]

void gams::GAMSJob::run ( GAMSOptions gamsOptions,
std::ostream &  outstream 
)

Run GAMSJob.

Parameters
gamsOptionsGAMSOptions to control the GAMSJob.
outstreamStream to capture GAMS log.

◆ run() [8/8]

void gams::GAMSJob::run ( std::ostream &  outstream)

Run GAMSJob.

Parameters
outstreamStream to capture GAMS log.

◆ runEngine()

void gams::GAMSJob::runEngine ( const GAMSEngineConfiguration &  engineConfiguration,
GAMSOptions gamsOptions,
gams::GAMSCheckpoint checkpoint,
std::ostream *  output = nullptr,
const std::vector< gams::GAMSDatabase > &  databases = {},
const std::set< std::string > &  extraModelFiles = {},
const std::unordered_map< std::string, std::string > &  engineOptions = {},
bool  createOutDB = true,
bool  removeResults = true 
)

Run GAMSJob on GAMS Engine

Parameters
engineConfigurationGAMSEngineConfiguration object
extraModelFilesSet of additional file paths (apart from main file) required to run the model (e.g. include files)
engineOptionsDictionary of GAMS Engine options to control job execution
gamsOptionsGAMS options to control job
checkpointGAMSCheckpoint to be created by GAMSJob
outputStream to capture GAMS log
createOutDBFlag to define if OutDB should be created
removeResultsRemove results from GAMS Engine after downloading them
databasesGAMSDatabases read by the GAMSJob

◆ workspace()

GAMSWorkspace gams::GAMSJob::workspace ( )

Get GAMSWorkspace containing GAMSJob.