Loading...
Searching...
No Matches
GAMS.GAMSWorkspace Class Reference

Public Member Functions

void GamsLib (string model)
 Retrieves model from GAMS Model Library.
 
void TestLib (string model)
 Retrieves model from GAMS Test Library.
 
void EmpLib (string model)
 Retrieves model from Extended Math Programming Library.
 
void DataLib (string model)
 Retrieves model from GAMS Data Utilities Library.
 
void ApiLib (string model)
 Retrieves model from GAMS API Library.
 
void FinLib (string model)
 Retrieves model from Practical Financial Optimization Library.
 
void NoaLib (string model)
 Retrieves model from Nonlinear Optimization Applications Library.
 
void PsoptLib (string model)
 Retrieves model from Power System Optimization Modelling Library.
 
 GAMSWorkspace (string workingDirectory=null, string systemDirectory=null, DebugLevel debug=DebugLevel.KeepFilesOnError)
 Constructor.
 
 GAMSWorkspace (GAMSWorkspaceInfo wsInfo)
 Constructor.
 
GAMSDatabase AddDatabaseFromGDX (string gdxFileName, string databaseName=null, string inModelName=null)
 Database creation from an existing GDX file.
 
GAMSDatabase AddDatabase (string databaseName=null, string inModelName=null)
 Empty Database creation.
 
GAMSDatabase AddDatabase (GAMSDatabase sourceDatabase, string databaseName=null, string inModelName=null)
 Database creation from existing database.
 
GAMSJob AddJobFromString (string gamsSource, GAMSCheckpoint checkpoint=null, string jobName=null)
 Create GAMSJob from string model source.
 
GAMSJob AddJobFromFile (string fileName, GAMSCheckpoint checkpoint=null, string jobName=null)
 Create GAMSJob from model file.
 
GAMSJob AddJobFromGamsLib (string model, GAMSCheckpoint checkpoint=null, string jobName=null)
 Create GAMSJob from model from GAMS Model Library.
 
GAMSJob AddJobFromTestLib (string model, GAMSCheckpoint checkpoint=null, string jobName=null)
 Create GAMSJob from model from GAMS Test Library.
 
GAMSJob AddJobFromEmpLib (string model, GAMSCheckpoint checkpoint=null, string jobName=null)
 Create GAMSJob from model from Extended Math Programming Library.
 
GAMSJob AddJobFromDataLib (string model, GAMSCheckpoint checkpoint=null, string jobName=null)
 Create GAMSJob from model from GAMS Data Utilities Library.
 
GAMSJob AddJobFromFinLib (string model, GAMSCheckpoint checkpoint=null, string jobName=null)
 Create GAMSJob from model from Practical Financial Optimization Library.
 
GAMSJob AddJobFromApiLib (string model, GAMSCheckpoint checkpoint=null, string jobName=null)
 Create GAMSJob from model from API Library.
 
GAMSJob AddJobFromNoaLib (string model, GAMSCheckpoint checkpoint=null, string jobName=null)
 Create GAMSJob from model from Nonlinear Optimization Applications Library.
 
GAMSJob AddJobFromPsoptLib (string model, GAMSCheckpoint checkpoint=null, string jobName=null)
 Create GAMSJob from model from Power System Optimization Modelling Library.
 
GAMSCheckpoint AddCheckpoint (string checkpointName=null)
 Create GAMSCheckpoint.
 
GAMSOptions AddOptions (GAMSOptions optFrom=null)
 Create GAMSOptions.
 
GAMSOptions AddOptions (string optFile)
 Create GAMSOptions.
 

Public Attributes

string ScratchFilePrefix = "_gams_net_"
 A string used to prefix automatically generated files.
 

Properties

string Version [get]
 GAMS Version used.
 
int MajorRelNumber [get]
 GAMS Major Release Number.
 
int MinorRelNumber [get]
 GAMS Minor Release Number.
 
int GoldRelNumber [get]
 GAMS GOLD Release Number.
 
static string APIVersion [get]
 API Version used.
 
static int APIMajorRelNumber [get]
 API Major Release Number.
 
static int APIMinorRelNumber [get]
 API Minor Release Number.
 
static int APIGoldRelNumber [get]
 API GOLD Release Number.
 
double MyEPS [get, set]
 Reset value to be stored in and read from GAMSDatabase for Epsilon, default is double.Epsilon.
 
string WorkingDirectory [get]
 Get the working directory.
 
string SystemDirectory [get]
 Get the system directory.
 

Detailed Description

The GAMSWorkspace is the base class in the GAMS namespace. Most objects of the GAMS namespace (e.g. GAMSDatabase and GAMSJob) have to be created by an "Add" method of GAMSWorkspace.

Unless a GAMS system directory is specified during construction of GAMSWorkspace, GAMSWorkspace determines the location of the GAMS installation automatically. This is a source of potential problems if more than one GAMS installation exist on the machine (see below).

Furthermore, a working directory (the anchor into the file system) can be provided when constructing the GAMSWorkspace instance. All file based operation inside a GAMS model should be relative to this location (e.g. $GDXIN and $include). There are options to add input search paths (e.g. IDir) and output path (e.g. PutDir) to specify other file system locations. If no working directory is supplied, GAMSWorkspace creates a temporary folder and on instance destruction removes this temporary folder.

In a typical .NET solution a single instance of GAMSWorkspace will suffice, since the class is thread-safe.

Note: If you use multiple instances of the GAMSWorkspace in parallel, you should avoid using the same WorkingDirectory. Otherwise you may end up with conflicting file names.

Working with different GAMS Versions on one Machine

When creating a new instance of GAMSWorkspace, one way of defining the GAMS system directory is setting the systemDirectory parameter of the constructor accordingly. If it is not set, it is tried to be defined automatically. However, this can be tricky if there is more than on version of GAMS installed on a machine and especially if there are different applications running with different GAMS versions.

The automatic identification relies on information left in the Windows registry by the GAMS installer. Hence the system directory of the last GAMS installation will be found in this automatic identification step. One way of resetting the information in the registry is running the executable "findthisgams.exe" from the directory that should be detected automatically. While this can be done from the outside of the application it is not much more convenient than the SystemDirectory argument in the GAMSWorkspace constructor. With MONO, first the PATH and then the (DY)LD_LIBRARY_PATH instead of the registry is checked for a valid GAMS system directory.

If one has a very structured way of organizing the GAMS installations (e.g. following the GAMS default installation location) one can construct from the GAMS assembly information enough information to point to the best matching GAMS system directory:

string sysdir = @"C:\GAMS\" + GAMSWorkspace.APIMajorRelNumber;
Definition: GAMSWorkSpace.cs:239
static int APIMajorRelNumber
API Major Release Number.
Definition: GAMSWorkSpace.cs:675

This avoids the automatic identification of the GAMS system directory but might be the most convenient solution for systems running multiple applications using different versions of the GAMS.NET API together with different versions of GAMS.

Constructor & Destructor Documentation

◆ GAMSWorkspace() [1/2]

GAMS.GAMSWorkspace.GAMSWorkspace ( string  workingDirectory = null,
string  systemDirectory = null,
DebugLevel  debug = DebugLevel::KeepFilesOnError 
)
inline

Constructor.

Parameters
workingDirectoryGAMS working directory, anchor for all file-based operations (determined automatically if omitted, in user's temporary folder)
systemDirectoryGAMS system directory (determined automatically if omitted)
debugDebug Flag

◆ GAMSWorkspace() [2/2]

GAMS.GAMSWorkspace.GAMSWorkspace ( GAMSWorkspaceInfo  wsInfo)
inline

Constructor.

Parameters
wsInfoGAMSWorkspaceInfo defining GAMS working directory, GAMS system directory and Debug Flag

Member Function Documentation

◆ AddCheckpoint()

GAMSCheckpoint GAMS.GAMSWorkspace.AddCheckpoint ( string  checkpointName = null)
inline

Create GAMSCheckpoint.

Parameters
checkpointNameIdentifier of GAMSCheckpoint or filename for existing checkpoint (determined automatically if omitted or set to empty string)
Returns
Reference to GAMSCheckpoint

◆ AddDatabase() [1/2]

GAMSDatabase GAMS.GAMSWorkspace.AddDatabase ( GAMSDatabase  sourceDatabase,
string  databaseName = null,
string  inModelName = null 
)
inline

Database creation from existing database.

Parameters
sourceDatabaseSource GAMSDatabase to initialize Database from
databaseNameIdentifier of GAMSDatabase (determined automatically if omitted)
inModelNameGAMS string constant that is used to access this database
Returns
Reference to GAMSDatabase

◆ AddDatabase() [2/2]

GAMSDatabase GAMS.GAMSWorkspace.AddDatabase ( string  databaseName = null,
string  inModelName = null 
)
inline

Empty Database creation.

Parameters
databaseNameIdentifier of GAMSDatabase (determined automatically if omitted)
inModelNameGAMS string constant that is used to access this database
Returns
Reference to GAMSDatabase

◆ AddDatabaseFromGDX()

GAMSDatabase GAMS.GAMSWorkspace.AddDatabaseFromGDX ( string  gdxFileName,
string  databaseName = null,
string  inModelName = null 
)
inline

Database creation from an existing GDX file.

Parameters
databaseNameIdentifier of GAMSDatabase (determined automatically if omitted)
gdxFileNameGDX File to initialize Database from
inModelNameGAMS string constant that is used to access this database
Returns
Reference to GAMSDatabase

◆ AddJobFromApiLib()

GAMSJob GAMS.GAMSWorkspace.AddJobFromApiLib ( string  model,
GAMSCheckpoint  checkpoint = null,
string  jobName = null 
)
inline

Create GAMSJob from model from API Library.

Parameters
modelModel name
checkpointGAMSCheckpoint to initialize GAMSJob from
jobNameJob name (determined automatically if omitted)
Returns
Handle to new instance of GAMSJob

◆ AddJobFromDataLib()

GAMSJob GAMS.GAMSWorkspace.AddJobFromDataLib ( string  model,
GAMSCheckpoint  checkpoint = null,
string  jobName = null 
)
inline

Create GAMSJob from model from GAMS Data Utilities Library.

Parameters
modelModel name
checkpointGAMSCheckpoint to initialize GAMSJob from
jobNameJob name (determined automatically if omitted)
Returns
Handle to new instance of GAMSJob

◆ AddJobFromEmpLib()

GAMSJob GAMS.GAMSWorkspace.AddJobFromEmpLib ( string  model,
GAMSCheckpoint  checkpoint = null,
string  jobName = null 
)
inline

Create GAMSJob from model from Extended Math Programming Library.

Parameters
modelModel name
checkpointGAMSCheckpoint to initialize GAMSJob from
jobNameJob name (determined automatically if omitted)
Returns
Handle to new instance of GAMSJob

◆ AddJobFromFile()

GAMSJob GAMS.GAMSWorkspace.AddJobFromFile ( string  fileName,
GAMSCheckpoint  checkpoint = null,
string  jobName = null 
)
inline

Create GAMSJob from model file.

Parameters
fileNameGAMS source file name
checkpointGAMSCheckpoint to initialize GAMSJob from
jobNameJob name (determined automatically if omitted)
Returns
Handle to new instance of GAMSJob

◆ AddJobFromFinLib()

GAMSJob GAMS.GAMSWorkspace.AddJobFromFinLib ( string  model,
GAMSCheckpoint  checkpoint = null,
string  jobName = null 
)
inline

Create GAMSJob from model from Practical Financial Optimization Library.

Parameters
modelModel name
checkpointGAMSCheckpoint to initialize GAMSJob from
jobNameJob name (determined automatically if omitted)
Returns
Handle to new instance of GAMSJob

◆ AddJobFromGamsLib()

GAMSJob GAMS.GAMSWorkspace.AddJobFromGamsLib ( string  model,
GAMSCheckpoint  checkpoint = null,
string  jobName = null 
)
inline

Create GAMSJob from model from GAMS Model Library.

Parameters
modelModel name
checkpointGAMSCheckpoint to initialize GAMSJob from
jobNameJob name (determined automatically if omitted)
Returns
Handle to new instance of GAMSJob

◆ AddJobFromNoaLib()

GAMSJob GAMS.GAMSWorkspace.AddJobFromNoaLib ( string  model,
GAMSCheckpoint  checkpoint = null,
string  jobName = null 
)
inline

Create GAMSJob from model from Nonlinear Optimization Applications Library.

Parameters
modelModel name
checkpointGAMSCheckpoint to initialize GAMSJob from
jobNameJob name (determined automatically if omitted)
Returns
Handle to new instance of GAMSJob

◆ AddJobFromPsoptLib()

GAMSJob GAMS.GAMSWorkspace.AddJobFromPsoptLib ( string  model,
GAMSCheckpoint  checkpoint = null,
string  jobName = null 
)
inline

Create GAMSJob from model from Power System Optimization Modelling Library.

Parameters
modelModel name
checkpointGAMSCheckpoint to initialize GAMSJob from
jobNameJob name (determined automatically if omitted)
Returns
Handle to new instance of GAMSJob

◆ AddJobFromString()

GAMSJob GAMS.GAMSWorkspace.AddJobFromString ( string  gamsSource,
GAMSCheckpoint  checkpoint = null,
string  jobName = null 
)
inline

Create GAMSJob from string model source.

Parameters
gamsSourceGAMS model as string
checkpointGAMSCheckpoint to initialize GAMSJob from
jobNameJob name (determined automatically if omitted)
Returns
Handle to new instance of GAMSJob

◆ AddJobFromTestLib()

GAMSJob GAMS.GAMSWorkspace.AddJobFromTestLib ( string  model,
GAMSCheckpoint  checkpoint = null,
string  jobName = null 
)
inline

Create GAMSJob from model from GAMS Test Library.

Parameters
modelModel name
checkpointGAMSCheckpoint to initialize GAMSJob from
jobNameJob name (determined automatically if omitted)
Returns
Handle to new instance of GAMSJob

◆ AddOptions() [1/2]

GAMSOptions GAMS.GAMSWorkspace.AddOptions ( GAMSOptions  optFrom = null)
inline

Create GAMSOptions.

Parameters
optFromGAMSOptions used to initialize the new object
Returns
Reference to GAMSOptions

◆ AddOptions() [2/2]

GAMSOptions GAMS.GAMSWorkspace.AddOptions ( string  optFile)
inline

Create GAMSOptions.

Parameters
optFileParameter file used to initialize the new object
Returns
Reference to GAMSOptions

◆ ApiLib()

void GAMS.GAMSWorkspace.ApiLib ( string  model)
inline

Retrieves model from GAMS API Library.

Parameters
modelModel name

◆ DataLib()

void GAMS.GAMSWorkspace.DataLib ( string  model)
inline

Retrieves model from GAMS Data Utilities Library.

Parameters
modelModel name

◆ EmpLib()

void GAMS.GAMSWorkspace.EmpLib ( string  model)
inline

Retrieves model from Extended Math Programming Library.

Parameters
modelModel name

◆ FinLib()

void GAMS.GAMSWorkspace.FinLib ( string  model)
inline

Retrieves model from Practical Financial Optimization Library.

Parameters
modelModel name

◆ GamsLib()

void GAMS.GAMSWorkspace.GamsLib ( string  model)
inline

Retrieves model from GAMS Model Library.

Parameters
modelModel name

◆ NoaLib()

void GAMS.GAMSWorkspace.NoaLib ( string  model)
inline

Retrieves model from Nonlinear Optimization Applications Library.

Parameters
modelModel name

◆ PsoptLib()

void GAMS.GAMSWorkspace.PsoptLib ( string  model)
inline

Retrieves model from Power System Optimization Modelling Library.

Parameters
modelModel name

◆ TestLib()

void GAMS.GAMSWorkspace.TestLib ( string  model)
inline

Retrieves model from GAMS Test Library.

Parameters
modelModel name

Member Data Documentation

◆ ScratchFilePrefix

string GAMS.GAMSWorkspace.ScratchFilePrefix = "_gams_net_"

A string used to prefix automatically generated files.

Property Documentation

◆ APIGoldRelNumber

int GAMS.GAMSWorkspace.APIGoldRelNumber
staticget

API GOLD Release Number.

◆ APIMajorRelNumber

int GAMS.GAMSWorkspace.APIMajorRelNumber
staticget

API Major Release Number.

◆ APIMinorRelNumber

int GAMS.GAMSWorkspace.APIMinorRelNumber
staticget

API Minor Release Number.

◆ APIVersion

string GAMS.GAMSWorkspace.APIVersion
staticget

API Version used.

◆ GoldRelNumber

int GAMS.GAMSWorkspace.GoldRelNumber
get

GAMS GOLD Release Number.

◆ MajorRelNumber

int GAMS.GAMSWorkspace.MajorRelNumber
get

GAMS Major Release Number.

◆ MinorRelNumber

int GAMS.GAMSWorkspace.MinorRelNumber
get

GAMS Minor Release Number.

◆ MyEPS

double GAMS.GAMSWorkspace.MyEPS
getset

Reset value to be stored in and read from GAMSDatabase for Epsilon, default is double.Epsilon.

◆ SystemDirectory

string GAMS.GAMSWorkspace.SystemDirectory
get

Get the system directory.

◆ Version

string GAMS.GAMSWorkspace.Version
get

GAMS Version used.

◆ WorkingDirectory

string GAMS.GAMSWorkspace.WorkingDirectory
get

Get the working directory.