#include <GamsModel.hpp>
Public Types | |
NonBasicLower = 0 | |
NonBasicUpper | |
Basic | |
SuperBasic | |
LastBasisStatus | |
VarNormal = 0 | |
VarNonOptimal | |
VarInfeasible | |
VarUnbounded | |
VarLastStatus | |
RowNormal = 0 | |
RowNonOptimal | |
RowInfeasible | |
RowUnbounded | |
RowLastStatus | |
SolverStatusNotSet = 0 | |
NormalCompletion = 1 | |
IterationInterrupt | |
ResourceInterrupt | |
TerminatedBySolver | |
EvaluationErrorLimit | |
CapabilityProblems | |
LicensingProblems | |
UserInterrupt | |
ErrorSetupFailure | |
ErrorSolverFailure | |
ErrorInternalSolverError | |
SolveProcessingSkipped | |
ErrorSystemFailure | |
LastSolverStatus | |
ModelStatusNotSet = 0 | |
Optimal | |
LocallyOptimal | |
Unbounded | |
Infeasible | |
LocallyInfeasible | |
IntermediateInfeasible | |
IntermediateNonoptimal | |
IntegerSolution | |
IntermediateNonInteger | |
IntegerInfeasible | |
LicensingProblemNoSolution | |
ErrorUnknown | |
ErrorNoSolution | |
NoSolutionReturned | |
SolvedUnique | |
Solved | |
SolvedSingular | |
UnboundedNoSolution | |
InfeasibleNoSolution | |
LastModelStatus | |
LogMask = 0x1 | |
StatusMask = 0x2 | |
AllMask = LogMask|StatusMask | |
LastPrintMask | |
enum | BasisStatus { NonBasicLower = 0, NonBasicUpper, Basic, SuperBasic, LastBasisStatus } |
Basis status indicator used in GAMS. More... | |
enum | VariableStatus { VarNormal = 0, VarNonOptimal, VarInfeasible, VarUnbounded, VarLastStatus } |
Column status indicator used in GAMS. More... | |
enum | RowStatus { RowNormal = 0, RowNonOptimal, RowInfeasible, RowUnbounded, RowLastStatus } |
Row status indicator used in GAMS. More... | |
enum | SolverStatus { SolverStatusNotSet = 0, NormalCompletion = 1, IterationInterrupt, ResourceInterrupt, TerminatedBySolver, EvaluationErrorLimit, CapabilityProblems, LicensingProblems, UserInterrupt, ErrorSetupFailure, ErrorSolverFailure, ErrorInternalSolverError, SolveProcessingSkipped, ErrorSystemFailure, LastSolverStatus } |
GAMS Solver status codes. More... | |
enum | ModelStatus { ModelStatusNotSet = 0, Optimal, LocallyOptimal, Unbounded, Infeasible, LocallyInfeasible, IntermediateInfeasible, IntermediateNonoptimal, IntegerSolution, IntermediateNonInteger, IntegerInfeasible, LicensingProblemNoSolution, ErrorUnknown, ErrorNoSolution, NoSolutionReturned, SolvedUnique, Solved, SolvedSingular, UnboundedNoSolution, InfeasibleNoSolution, LastModelStatus } |
GAMS Model status codes. More... | |
enum | PrintMask { LogMask = 0x1, StatusMask = 0x2, AllMask = LogMask|StatusMask, LastPrintMask } |
Distinguishing between message types. More... | |
Public Member Functions | |
GamsModel (const char *cntrfile, const double SolverMInf=0, const double SolverPInf=0) | |
Constructor. | |
~GamsModel () | |
Destructor. | |
const char * | getSystemDir () |
Name of GAMS System directory. | |
Output | |
void | PrintOut (PrintMask mask, const char *msg) |
Log- and Statusfile print function. | |
int | getSysOut () |
If SysOut is set, the solver should give plenty off output. | |
Timing. | |
void | TimerStart () |
Starts the GAMS timer. | |
double | SecondsSinceStart () |
The number of seconds since the GAMS timer was started. | |
Accessing the GAMS model. | |
int | nCols () const |
The number of columns in the model. | |
int | nDCols () const |
The number of discrete columns in the model. | |
int | nSOS1 () const |
The number of special ordered sets of type 1 in the model. | |
int | nSOS2 () const |
The number of special ordered sets of type 2 in the model. | |
int | nRows () const |
The number of rows in the model. | |
int | nNnz () const |
The number of nonzeros in the matrix of the model. | |
double * | ColLb () |
The column lower bounds. | |
double * | ColUb () |
The column upper bounds. | |
int * | ColDisc () |
The indices of the discrete variables. | |
int * | SOSIndicator () |
The special ordered sets indicator. | |
char * | ColName (int colnr, char *buffer, int bufLen) |
The name of a column. | |
char * | RowSense () |
The sense of the rows. | |
double * | RowRhs () |
The right-hand-side of the rows. | |
char * | RowName (int rownr, char *buffer, int bufLen) |
The name of a row. | |
double * | ObjCoef () |
The coefficients of the objective function (dense format). | |
double | ObjConstant () |
A constant term in the objective function. | |
double | ObjSense () const |
The sense of the objective function or optimization, respectively. | |
int * | matStart () |
The column starts for the problem matrix. | |
int * | matRowIdx () |
The row indices for the problem matrix. | |
double * | matValue () |
The values for the problem matrix. | |
int | matSqueezeZeros () |
Removes zero entries in the problem matrix. | |
Setting solution information. | |
ModelStatus | getModelStatus () |
The current GAMS model status. | |
SolverStatus | getSolverStatus () |
The current GAMS solver status. | |
void | setStatus (const SolverStatus &newSolverStatus, const ModelStatus &newModelStatus) |
Sets the GAMS solver and model status. | |
void | setIterUsed (const int IterUsed) |
Sets the number of iterations used. | |
void | setResUsed (const double ResUsed) |
Sets the number of seconds used. | |
void | setObjVal (const double ObjVal) |
Sets the objective function value. | |
double | getObjVal () |
Gives the stored objective function value. | |
double | getResUsed () |
Gives the stored number of seconds used. | |
double * | ColLevel () |
Storage for the solution values of the primal variables. | |
double * | ColMargin () |
Storage for the solution values of the dual variables corresponding to the column bound constraints (reduced costs). | |
int * | ColBasis () |
Storage for the solution basis status of the columns. | |
int * | ColIndicator () |
Storage for column indicators. | |
double * | RowLevel () |
Storage for the solution levels of the rows (row activities). | |
double * | RowMargin () |
Storage for the solution values of the dual variables corresponding to the rows (row prices). | |
int * | RowBasis () |
Storage for the solution basis status of the rows. | |
int * | RowIndicator () |
Storage for row indicators. | |
void | setSolution (const double *ColLevel=0, const double *ColMargin=0, const int *ColBasis=0, const int *ColIndicator=0, const double *RowLevel=0, const double *RowMargin=0, const int *RowBasis=0, const int *RowIndicator=0) |
Sets the solution information and writes the solution file. | |
Options and parameters | |
double | getResLim () |
GAMS Parameter: Time limit for model run in seconds. | |
int | getIterLim () |
GAMS Parameter: Iteration limit for model run. | |
int | getNodeLim () |
GAMS Parameter: Node limit for model run if using a branch-and-bound algorithm. | |
int | getGamsInteger (int nr) |
GAMS Parameter: Integers 1 to 5. | |
int | getGamsInteger (int intnr, int bitnr) |
GAMS Parameter: Integers 1 to 5, bitwise. | |
double | getOptCA () |
GAMS Parameter: Allowed absolute difference between incumbent solution and best bound (for MIPs). | |
double | getOptCR () |
GAMS Parameter: Allowed relative difference between incumbent solution and best bound (for MIPs). | |
double | getCutOff () |
GAMS Parmeter: Implied upper/lower bound on objective function. | |
const char * | getOptionfile () |
The name of the option file. | |
bool | ReadOptionsDefinitions (const char *solvername) |
Initialization of optionfile reading. | |
bool | ReadOptionsFile () |
Reads the options file, if desired. | |
bool | optDefined (const char *optname) |
Check whether the user specified some option. | |
bool | optGetBool (const char *optname) |
Gets the value of a boolean option. | |
int | optGetInteger (const char *optname) |
Gets the value of an integer option. | |
double | optGetDouble (const char *optname) |
Gets the value of a real (double) option. | |
char * | optGetString (const char *optname, char *buffer) |
Gets the value of a string option. | |
void | optSetBool (const char *optname, bool bval) |
Sets the value of a boolean option. | |
void | optSetInteger (const char *optname, int ival) |
Sets the value of an integer option. | |
void | optSetDouble (const char *optname, double dval) |
Sets the value of a double option. | |
void | optSetString (const char *optname, char *sval) |
Sets the value of a string option. | |
Private Member Functions | |
void | Allocate () |
void | ReadMatrix () |
char * | ConstructName (char *buffer, int bufLen, int lSym, int *uelIndices, int nIndices) |
Private Attributes | |
int | nCols_ |
int | nDCols_ |
int | nSOS1_ |
int | nSOS2_ |
int | nRows_ |
int | nNnz_ |
double | startTime_ |
double * | ColLb_ |
double * | ColUb_ |
int * | ColDisc_ |
int * | ColStat_ |
int * | SOSIndicator_ |
char * | RowSense_ |
double * | RowRhs_ |
int * | RowStat_ |
double | ObjSense_ |
double * | ObjCoef_ |
double | ObjRhs_ |
double | zCoef_ |
int | isReform_ |
int * | matStart_ |
int * | matRowIdx_ |
double * | matValue_ |
double * | RowLevel_ |
double * | RowMargin_ |
int * | RowBasis_ |
int * | RowIndicator_ |
double * | ColLevel_ |
double * | ColMargin_ |
int * | ColBasis_ |
int * | ColIndicator_ |
double | ObjVal_ |
double | ResUsed_ |
int | IterUsed_ |
int | DomUsed_ |
SolverStatus | SolverStatus_ |
ModelStatus | ModelStatus_ |
dictRec * | dict |
optRec * | optionshandle |
This class is a layer between the GAMS I/O libraries and the GAMS-interfaces to COIN-OR LP and MIP solvers.
Definition at line 25 of file GamsModel.hpp.
enum GamsModel::RowStatus |
GAMS Solver status codes.
Definition at line 60 of file GamsModel.hpp.
GAMS Model status codes.
Definition at line 80 of file GamsModel.hpp.
enum GamsModel::PrintMask |
GamsModel::GamsModel | ( | const char * | cntrfile, | |
const double | SolverMInf = 0 , |
|||
const double | SolverPInf = 0 | |||
) |
Constructor.
cntrfile | Name of GAMS control file. | |
SolverMInf | If not zero, then the solver value for minus infinity. | |
SolverPInf | If not zero, then the solver value for plus infinity. |
GamsModel::~GamsModel | ( | ) |
Destructor.
void GamsModel::PrintOut | ( | PrintMask | mask, | |
const char * | msg | |||
) |
Log- and Statusfile print function.
If the PrintMask is set to LogMask, the message appears in the logfile, if the PrintMask is set to StatusMask, the message appears in the statusfile, and if the message is set to AllMask, the message appears in both log- and statusfile.
mask | Tell where the message should be printed to. | |
msg | The message to print. It has to be terminated by a zero. |
int GamsModel::getSysOut | ( | ) |
If SysOut is set, the solver should give plenty off output.
void GamsModel::TimerStart | ( | ) |
Starts the GAMS timer.
double GamsModel::SecondsSinceStart | ( | ) |
The number of seconds since the GAMS timer was started.
const char* GamsModel::getSystemDir | ( | ) |
Name of GAMS System directory.
int GamsModel::nCols | ( | ) | const [inline] |
The number of columns in the model.
Definition at line 160 of file GamsModel.hpp.
References nCols_.
int GamsModel::nDCols | ( | ) | const [inline] |
The number of discrete columns in the model.
Definition at line 163 of file GamsModel.hpp.
References nDCols_.
int GamsModel::nSOS1 | ( | ) | const [inline] |
The number of special ordered sets of type 1 in the model.
Definition at line 166 of file GamsModel.hpp.
References nSOS1_.
int GamsModel::nSOS2 | ( | ) | const [inline] |
The number of special ordered sets of type 2 in the model.
Definition at line 169 of file GamsModel.hpp.
References nSOS2_.
int GamsModel::nRows | ( | ) | const [inline] |
int GamsModel::nNnz | ( | ) | const [inline] |
The number of nonzeros in the matrix of the model.
Definition at line 175 of file GamsModel.hpp.
References nNnz_.
double* GamsModel::ColLb | ( | ) | [inline] |
double* GamsModel::ColUb | ( | ) | [inline] |
int* GamsModel::ColDisc | ( | ) | [inline] |
The indices of the discrete variables.
Definition at line 185 of file GamsModel.hpp.
References ColDisc_.
int* GamsModel::SOSIndicator | ( | ) | [inline] |
The special ordered sets indicator.
For each variable, SOSIndicator()[i] tells to which special ordered set from which type it belongs, if any. If SOSIndicator()[i] is
Definition at line 193 of file GamsModel.hpp.
References SOSIndicator_.
char* GamsModel::ColName | ( | int | colnr, | |
char * | buffer, | |||
int | bufLen | |||
) |
The name of a column.
colnr | column index | |
buffer | a buffer for writing the name in | |
bufLen | length of the buffer |
char* GamsModel::RowSense | ( | ) | [inline] |
The sense of the rows.
RowSense[i] is
Definition at line 210 of file GamsModel.hpp.
References RowSense_.
double* GamsModel::RowRhs | ( | ) | [inline] |
char* GamsModel::RowName | ( | int | rownr, | |
char * | buffer, | |||
int | bufLen | |||
) |
The name of a row.
rownr | row index | |
buffer | a buffer for writing the name in | |
bufLen | length of the buffer |
double* GamsModel::ObjCoef | ( | ) | [inline] |
The coefficients of the objective function (dense format).
Definition at line 224 of file GamsModel.hpp.
References ObjCoef_.
double GamsModel::ObjConstant | ( | ) | [inline] |
A constant term in the objective function.
Definition at line 227 of file GamsModel.hpp.
References ObjRhs_.
double GamsModel::ObjSense | ( | ) | const [inline] |
The sense of the objective function or optimization, respectively.
Definition at line 231 of file GamsModel.hpp.
References ObjSense_.
int* GamsModel::matStart | ( | ) | [inline] |
The column starts for the problem matrix.
Definition at line 235 of file GamsModel.hpp.
References matStart_.
int* GamsModel::matRowIdx | ( | ) | [inline] |
The row indices for the problem matrix.
Definition at line 238 of file GamsModel.hpp.
References matRowIdx_.
double* GamsModel::matValue | ( | ) | [inline] |
The values for the problem matrix.
Definition at line 241 of file GamsModel.hpp.
References matValue_.
int GamsModel::matSqueezeZeros | ( | ) |
Removes zero entries in the problem matrix.
In some cases, it might happen that the sparse problem matrix as given by GAMS still contains a few zero elements. This method checks the matrix and shifts elements front to eleminate nonzeros.
ModelStatus GamsModel::getModelStatus | ( | ) |
The current GAMS model status.
SolverStatus GamsModel::getSolverStatus | ( | ) |
The current GAMS solver status.
void GamsModel::setStatus | ( | const SolverStatus & | newSolverStatus, | |
const ModelStatus & | newModelStatus | |||
) |
Sets the GAMS solver and model status.
newSolverStatus | The new solver status. | |
newModelStatus | The new model status. |
void GamsModel::setIterUsed | ( | const int | IterUsed | ) | [inline] |
Sets the number of iterations used.
IterUsed | Number of iterations the solver used. |
Definition at line 269 of file GamsModel.hpp.
References IterUsed_.
void GamsModel::setResUsed | ( | const double | ResUsed | ) | [inline] |
Sets the number of seconds used.
ResUsed | Number of seconds the solver used. |
Definition at line 273 of file GamsModel.hpp.
References ResUsed_.
void GamsModel::setObjVal | ( | const double | ObjVal | ) | [inline] |
Sets the objective function value.
ObjVal | Value of objective function. |
Definition at line 277 of file GamsModel.hpp.
References ObjVal_.
double GamsModel::getObjVal | ( | ) | [inline] |
Gives the stored objective function value.
Definition at line 280 of file GamsModel.hpp.
References ObjVal_.
double GamsModel::getResUsed | ( | ) | [inline] |
Gives the stored number of seconds used.
Definition at line 283 of file GamsModel.hpp.
References ResUsed_.
double* GamsModel::ColLevel | ( | ) | [inline] |
Storage for the solution values of the primal variables.
Definition at line 287 of file GamsModel.hpp.
References ColLevel_.
double* GamsModel::ColMargin | ( | ) | [inline] |
Storage for the solution values of the dual variables corresponding to the column bound constraints (reduced costs).
Definition at line 290 of file GamsModel.hpp.
References ColMargin_.
int* GamsModel::ColBasis | ( | ) | [inline] |
Storage for the solution basis status of the columns.
Definition at line 293 of file GamsModel.hpp.
References ColBasis_.
int* GamsModel::ColIndicator | ( | ) | [inline] |
Storage for column indicators.
Definition at line 297 of file GamsModel.hpp.
References ColIndicator_.
double* GamsModel::RowLevel | ( | ) | [inline] |
Storage for the solution levels of the rows (row activities).
Definition at line 301 of file GamsModel.hpp.
References RowLevel_.
double* GamsModel::RowMargin | ( | ) | [inline] |
Storage for the solution values of the dual variables corresponding to the rows (row prices).
Definition at line 304 of file GamsModel.hpp.
References RowMargin_.
int* GamsModel::RowBasis | ( | ) | [inline] |
Storage for the solution basis status of the rows.
Definition at line 307 of file GamsModel.hpp.
References RowBasis_.
int* GamsModel::RowIndicator | ( | ) | [inline] |
Storage for row indicators.
Definition at line 311 of file GamsModel.hpp.
References RowIndicator_.
void GamsModel::setSolution | ( | const double * | ColLevel = 0 , |
|
const double * | ColMargin = 0 , |
|||
const int * | ColBasis = 0 , |
|||
const int * | ColIndicator = 0 , |
|||
const double * | RowLevel = 0 , |
|||
const double * | RowMargin = 0 , |
|||
const int * | RowBasis = 0 , |
|||
const int * | RowIndicator = 0 | |||
) |
Sets the solution information and writes the solution file.
If the model status is Optimal or IntegerSolution, then for those arrays that are given, the corresponding array in the GamsModel is overwritten and a solution file is written.
double GamsModel::getResLim | ( | ) |
GAMS Parameter: Time limit for model run in seconds.
int GamsModel::getIterLim | ( | ) |
GAMS Parameter: Iteration limit for model run.
int GamsModel::getNodeLim | ( | ) |
GAMS Parameter: Node limit for model run if using a branch-and-bound algorithm.
int GamsModel::getGamsInteger | ( | int | nr | ) |
GAMS Parameter: Integers 1 to 5.
In a GAMS model, 5 integer values can be specified, e.g. model.integer1=value;.
nr | Which integer you want to have, it should be between 0 and 4. |
int GamsModel::getGamsInteger | ( | int | intnr, | |
int | bitnr | |||
) |
GAMS Parameter: Integers 1 to 5, bitwise.
In a GAMS model, 5 integer values can be specified, e.g. model.integer1=value;.
intnr | Which integer you want to have. intnr should be between 0 and 4. | |
bitnr | Which bit of integer intnr you want to have. bitnr should be between 0 and 15. |
double GamsModel::getOptCA | ( | ) |
GAMS Parameter: Allowed absolute difference between incumbent solution and best bound (for MIPs).
double GamsModel::getOptCR | ( | ) |
GAMS Parameter: Allowed relative difference between incumbent solution and best bound (for MIPs).
double GamsModel::getCutOff | ( | ) |
GAMS Parmeter: Implied upper/lower bound on objective function.
const char* GamsModel::getOptionfile | ( | ) |
The name of the option file.
bool GamsModel::ReadOptionsDefinitions | ( | const char * | solvername | ) |
Initialization of optionfile reading.
Initialization of options handle. Reading of the file "<GamsSystemDir>/opt<solvername>.def" to learn which options are supported.
solvername | The name of your solver. |
bool GamsModel::ReadOptionsFile | ( | ) |
Reads the options file, if desired.
bool GamsModel::optDefined | ( | const char * | optname | ) |
Check whether the user specified some option.
optname | The name of the option. |
bool GamsModel::optGetBool | ( | const char * | optname | ) | [inline] |
Gets the value of a boolean option.
optname | The name of the option. |
Definition at line 383 of file GamsModel.hpp.
References optGetInteger().
int GamsModel::optGetInteger | ( | const char * | optname | ) |
Gets the value of an integer option.
optname | The name of the option. |
Referenced by optGetBool().
double GamsModel::optGetDouble | ( | const char * | optname | ) |
Gets the value of a real (double) option.
optname | The name of the option. |
char* GamsModel::optGetString | ( | const char * | optname, | |
char * | buffer | |||
) |
Gets the value of a string option.
optname | The name of the option. | |
buffer | A buffer where the value can be stored (it should be large enough). |
void GamsModel::optSetBool | ( | const char * | optname, | |
bool | bval | |||
) | [inline] |
Sets the value of a boolean option.
optname | The name of the option. | |
bval | The value to set. |
Definition at line 402 of file GamsModel.hpp.
References optSetInteger().
void GamsModel::optSetInteger | ( | const char * | optname, | |
int | ival | |||
) |
Sets the value of an integer option.
optname | The name of the option. | |
ival | The value to set. |
Referenced by optSetBool().
void GamsModel::optSetDouble | ( | const char * | optname, | |
double | dval | |||
) |
Sets the value of a double option.
optname | The name of the option. | |
dval | The value to set. |
void GamsModel::optSetString | ( | const char * | optname, | |
char * | sval | |||
) |
Sets the value of a string option.
optname | The name of the option. | |
sval | The value to set. |
void GamsModel::Allocate | ( | ) | [private] |
void GamsModel::ReadMatrix | ( | ) | [private] |
char* GamsModel::ConstructName | ( | char * | buffer, | |
int | bufLen, | |||
int | lSym, | |||
int * | uelIndices, | |||
int | nIndices | |||
) | [private] |
int GamsModel::nCols_ [private] |
int GamsModel::nDCols_ [private] |
int GamsModel::nSOS1_ [private] |
int GamsModel::nSOS2_ [private] |
int GamsModel::nRows_ [private] |
int GamsModel::nNnz_ [private] |
double GamsModel::startTime_ [private] |
Definition at line 428 of file GamsModel.hpp.
double* GamsModel::ColLb_ [private] |
double* GamsModel::ColUb_ [private] |
int* GamsModel::ColDisc_ [private] |
int* GamsModel::ColStat_ [private] |
Definition at line 433 of file GamsModel.hpp.
int* GamsModel::SOSIndicator_ [private] |
char* GamsModel::RowSense_ [private] |
double* GamsModel::RowRhs_ [private] |
int* GamsModel::RowStat_ [private] |
Definition at line 438 of file GamsModel.hpp.
double GamsModel::ObjSense_ [private] |
double* GamsModel::ObjCoef_ [private] |
double GamsModel::ObjRhs_ [private] |
double GamsModel::zCoef_ [private] |
Definition at line 443 of file GamsModel.hpp.
int GamsModel::isReform_ [private] |
Definition at line 444 of file GamsModel.hpp.
int* GamsModel::matStart_ [private] |
int* GamsModel::matRowIdx_ [private] |
double* GamsModel::matValue_ [private] |
double* GamsModel::RowLevel_ [private] |
double* GamsModel::RowMargin_ [private] |
int* GamsModel::RowBasis_ [private] |
int* GamsModel::RowIndicator_ [private] |
double* GamsModel::ColLevel_ [private] |
double* GamsModel::ColMargin_ [private] |
int* GamsModel::ColBasis_ [private] |
int* GamsModel::ColIndicator_ [private] |
double GamsModel::ObjVal_ [private] |
double GamsModel::ResUsed_ [private] |
int GamsModel::IterUsed_ [private] |
int GamsModel::DomUsed_ [private] |
Definition at line 466 of file GamsModel.hpp.
SolverStatus GamsModel::SolverStatus_ [private] |
Definition at line 468 of file GamsModel.hpp.
ModelStatus GamsModel::ModelStatus_ [private] |
Definition at line 469 of file GamsModel.hpp.
struct dictRec* GamsModel::dict [private] |
Definition at line 471 of file GamsModel.hpp.
struct optRec* GamsModel::optionshandle [private] |
Definition at line 474 of file GamsModel.hpp.