gams::GAMSJob Class Reference

#include <gamsjob.h>

Public Member Functions

 GAMSJob ()
 Standard constructor. More...
 
 ~GAMSJob ()
 Desctructor. More...
 
GAMSJob operator= (const GAMSJob &other)
 
bool operator!= (const GAMSJob &other) const
 
bool operator== (const GAMSJob &other) const
 
bool isValid () const
 
void run ()
 Run GAMSJob. More...
 
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, GAMSCheckpoint gamsCheckpoint, std::ostream &output, bool createOutDB, std::vector< gams::GAMSDatabase > databases)
 
GAMSDatabase outDB ()
 Get GAMSDatabase created by Run method. More...
 
std::string name ()
 Retrieve name of GAMSJob. More...
 
GAMSWorkspace workspace ()
 Get GAMSWorkspace containing GAMSJob. More...
 
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 58 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 ( std::ostream &  outstream)

Run GAMSJob.

Parameters
outstreamStream to capture GAMS log.

◆ 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,
std::ostream &  outstream 
)

Run GAMSJob.

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

◆ run() [5/8]

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

Run GAMSJob.

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

◆ run() [6/8]

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

Run GAMSJob.

Parameters
gamsCheckpointGAMSCheckpoint to be created by GAMSJob.

◆ run() [7/8]

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

Run GAMSJob.

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

◆ run() [8/8]

void gams::GAMSJob::run ( GAMSOptions gamsOptions,
GAMSCheckpoint  gamsCheckpoint,
std::ostream &  output,
bool  createOutDB,
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.

◆ workspace()

GAMSWorkspace gams::GAMSJob::workspace ( )

Get GAMSWorkspace containing GAMSJob.