GAMS utility and performance functions

Top  Previous  Next

A number of functions can be used to withdraw information on GAMS internal matters.  These are addressed as

scalar=functionname;

 

In the following table the Endogenous Classification (second column) specifies in which models the function can legally appear. In order of least to most restrictive, the choices are any, NLP, DNLP or none. Note that constant arguments are required.

 

Function

Endogenous

Classification

Description

errorLevel

none

error code of the most recently used command

execError

none

number of execution errors, may either be read or assigned to

gamsRelease

none

returns the version number of the current GAMS release, for example 23.8

gamsVersion

none

returns the current gams version, for example 238

handleCollect(HANDLE)

none

tests if the solve of the problem identified by the argument HANDLE is done and if so loads the solution into GAMS. In particular it returns:

0 if the model associated with HANDLE had not yet finished solution or could not     be loaded
1 if the solution has been loaded

handleDelete(HANDLE)

none

deletes the grid computing problem identified by the HANDLE argument and returns a numerical indicator of the status of the deletion as follows:

0 if the the model instance has been removed
1 if the argument HANDLE is not a legal handle
2 if the model instance is not known to the system
3 if the deletion of the model instance encountered errors

 

A nonzero return indicates a failure in the deletion and causes an execution error.

handleStatus(HANDLE)

none

tests if the solve of the problem identified by the calling argument HANDLE is done and if so loads the solution into a GDX file. A numerical indication of the result is returned as follows:

0 if a model associated with HANDLE is not known to the system
1 if the model associaed with HANDLE exists but the solution process is                incomplete
2 if the solution process has terminated and the solution is ready for retrieval
3 if the solution process signaled completion but the solution cannot be retrieved

 

An execution error is triggered if GAMS cannot retrieve the status of the handle.

handleSubmit(HANDLE)

none

resubmits a previously created instance of the model identified by the HANDLE for solution. A numerical indication of the result is returned as follows:

0 if the model instance has been resubmitted for solution
1 if the argument HANDLE is not a legal handle
2 if a model associated with the HANDLE is not known to the system
3 if the completion signal could not be removed
4 if the resubmit procedure could not be found
5 if the resubmit process could not be started

 

In case of a nonzero return an execution error is triggered.

heapFree

none

allocated memory which is no more in use but not freed yet

heapLimit

none

interrogates the current heap limit (maximum allowable memory use) in Mb and allows it to be reset

heapSize

none

returns the current heap size in Mb

jobHandle

none

returns the Process ID (PID) of the last job started

jobKill(PID)

none

sends a kill signal to the running job with Process ID PID; returns 1 if this was succesful, otherwise 0

jobStatus(PID)

none

checks for the status of the job with the Process ID PID, possible return values are:

0: error (input is not a valid PID or access is denied)
1: process is still running
2: process is finished with return code which could be accessed by errorlevel
3: process not running anymore or was never running, no return code available

jobTerminate(PID)

none

sends an interrupt signal to the running job with Process ID PID; returns 1 if this was succesful, otherwise 0

licenseLevel

any

returns an indicator of the type of license:

0: demo license, limited to small models
1: full unlimited developer license
2: run time license, no new variables or equations can be introduced besides            those inherited in a work file
3: application license, only works with a specific work file which is locked to the        license file

licenseStatus

any

returns a non zero when a license error is incurred

maxExecError

none

maximum number of execution errors, may either be read or assigned to

sleep(SEC)

none

execution pauses for SEC seconds

timeClose

none

returns the model closing time

timeComp

none

returns the compilation time in seconds

timeElapsed

none

returns the elapsed time in seconds since the start of a GAMS run

timeExec

none

returns the execution time in seconds

timeStart

none

returns the model start time since last restart

function.gms illustrates the use of assorted functions