#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.
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 andfalse
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; otherwisefalse
.
◆ 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
-
other Another GAMSJob to compare to.
- Returns
- Returns
true
if the two GAMSJob are different; otherwisefalse
.
◆ operator=()
Assigns a GAMSJob.
- Parameters
-
other Another 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
-
other Another GAMSJob to compare to.
- Returns
- Returns
true
if the two GAMSJob are equal; otherwisefalse
.
◆ 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
-
gamsCheckpoint GAMSCheckpoint to be created by GAMSJob.
◆ run() [3/8]
void gams::GAMSJob::run | ( | GAMSOptions & | gamsOptions | ) |
Run GAMSJob.
- Parameters
-
gamsOptions GAMSOptions 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
-
gamsOptions GAMSOptions to control the GAMSJob. gamsCheckpoint GAMSCheckpoint to be created by GAMSJob. output Stream to capture GAMS log. createOutDB Flag that activates writing to outDB. databases GAMSDatabases read by the GAMSJob.
◆ run() [5/8]
void gams::GAMSJob::run | ( | GAMSOptions & | gamsOptions, |
GAMSCheckpoint | gamsCheckpoint | ||
) |
Run GAMSJob.
- Parameters
-
gamsOptions GAMSOptions to control the GAMSJob. gamsCheckpoint GAMSCheckpoint to be created by GAMSJob.
◆ run() [6/8]
void gams::GAMSJob::run | ( | GAMSOptions & | gamsOptions, |
GAMSDatabase | db | ||
) |
Run GAMSJob.
- Parameters
-
gamsOptions GAMSOptions to control the GAMSJob. db GAMSDatabase read by the GAMSJob.
◆ run() [7/8]
void gams::GAMSJob::run | ( | GAMSOptions & | gamsOptions, |
std::ostream & | outstream | ||
) |
Run GAMSJob.
- Parameters
-
gamsOptions GAMSOptions to control the GAMSJob. outstream Stream to capture GAMS log.
◆ run() [8/8]
void gams::GAMSJob::run | ( | std::ostream & | outstream | ) |
Run GAMSJob.
- Parameters
-
outstream Stream 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
-
engineConfiguration GAMSEngineConfiguration object extraModelFiles Set of additional file paths (apart from main file) required to run the model (e.g. include files) engineOptions Dictionary of GAMS Engine options to control job execution gamsOptions GAMS options to control job checkpoint GAMSCheckpoint to be created by GAMSJob output Stream to capture GAMS log createOutDB Flag to define if OutDB should be created removeResults Remove results from GAMS Engine after downloading them databases GAMSDatabases read by the GAMSJob
◆ workspace()
GAMSWorkspace gams::GAMSJob::workspace | ( | ) |
Get GAMSWorkspace containing GAMSJob.