GAMSlinks
0.4
|
Representation of a mixed-integer linear GAMS model read in from GAMS iolib. More...
#include <GamsModel.hpp>
Public Member Functions | |
GamsModel (const char *cntrfile) | |
Constructor. More... | |
~GamsModel () | |
Destructor. More... | |
void | readMatrix () |
Reads the LP from the GAMS matrix file and stores it into the data structures of this class. More... | |
const char * | getSystemDir () |
Name of GAMS System directory. More... | |
double | getMInfinity () const |
Value used by GAMS for minus infinity. More... | |
double | getPInfinity () const |
Value used by GAMS for plus infinity. More... | |
void | setInfinity (const double &SolverMInf, const double &SolverPInf) |
Set values that GAMS should use for minus and plus infinity. More... | |
bool | isReformulated () const |
Tells whether the model has been reformulated by moving the objective equation into the objective and eliminating the objective variable. More... | |
Output | |
void | PrintOut (PrintMask mask, const char *msg) |
Log- and Statusfile print function. More... | |
int | getSysOut () |
If SysOut is set, the solver should give plenty off output. More... | |
Timing. | |
void | TimerStart () |
Starts the GAMS timer. More... | |
double | SecondsSinceStart () |
The number of seconds since the GAMS timer was started. More... | |
Accessing the GAMS model. | |
bool | isLP () const |
Indicates whether we represent an LP or not. More... | |
int | nCols () const |
The number of columns in the model. More... | |
int | nDCols () const |
The number of discrete columns in the model. More... | |
int | nSOS1 () const |
The number of special ordered sets of type 1 in the model. More... | |
int | nSOS2 () const |
The number of special ordered sets of type 2 in the model. More... | |
int | nSemiContinuous () const |
The number of semicontinuous variables. More... | |
int | nRows () const |
The number of rows in the model. More... | |
int | nNnz () const |
The number of nonzeros in the matrix of the model. More... | |
double * | ColLb () |
The column lower bounds. More... | |
double * | ColUb () |
The column upper bounds. More... | |
bool * | ColDisc () |
Indicates whether a variable is discrete (true) or not (false). More... | |
int * | SOSIndicator () |
The special ordered sets indicator. More... | |
bool * | ColSemiContinuous () |
Indicates whether a variable is semicontinuous or semiinteger (true) or not (false). More... | |
double * | ColLevel () |
Initial values and storage for the solution values of the primal variables. More... | |
double * | ColMargin () |
Initial marginals and storage for the solution values of the dual variables corresponding to the column bound constraints (reduced costs). More... | |
int * | ColBasis () |
Initial basis status and storage for the solution basis status of the columns. More... | |
double * | ColPriority () |
Branching priorities of columns. More... | |
double * | ColScale () |
Scaling parameters for columns. More... | |
char * | RowSense () |
The sense of the rows. More... | |
double * | RowRhs () |
The right-hand-side of the rows. More... | |
double * | RowLevel () |
Initial values and storage for the solution levels of the rows (row activities). More... | |
double * | RowMargin () |
Initial marginals and storage for the solution values of the dual variables corresponding to the rows (row prices). More... | |
int * | RowBasis () |
Initial basis status and storage for the solution basis status of the rows. More... | |
double * | RowScale () |
Scaling parameters for rows. More... | |
double * | ObjCoef () |
The coefficients of the objective function (dense format). More... | |
double | ObjConstant () |
A constant term in the objective function. More... | |
double | ObjSense () const |
The sense of the objective function or optimization, respectively. More... | |
double | ObjScale () const |
Scaling parameter for objective function. More... | |
int * | matStart () |
The column starts for the problem matrix. More... | |
int * | matRowIdx () |
The row indices for the problem matrix. More... | |
double * | matValue () |
The values for the problem matrix. More... | |
int | matSqueezeZeros () |
Removes zero entries in the problem matrix. More... | |
Setting solution information. | |
ModelStatus | getModelStatus () |
The current GAMS model status. More... | |
SolverStatus | getSolverStatus () |
The current GAMS solver status. More... | |
void | setStatus (const SolverStatus &newSolverStatus, const ModelStatus &newModelStatus) |
Sets the GAMS solver and model status. More... | |
void | setIterUsed (const int IterUsed) |
Sets the number of iterations used. More... | |
void | setResUsed (const double ResUsed) |
Sets the number of seconds used. More... | |
void | setNodesUsed (const int NodesUsed) |
Sets the number of nodes used (in a branch-and-bound algorithm). More... | |
void | setObjVal (const double ObjVal) |
Sets the objective function value in the solution. More... | |
void | setObjBound (const double ObjBound) |
Sets an bound (estimate) on the optimal value. More... | |
double | getObjVal () |
Gives the stored objective function value. More... | |
double | getResUsed () |
Gives the stored number of seconds used. More... | |
int * | ColIndicator () |
Storage for column indicators. More... | |
int * | RowIndicator () |
Storage for row indicators. More... | |
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. More... | |
GAMS specific options and parameters | |
double | getResLim () |
GAMS Parameter: Time limit for model run in seconds. More... | |
int | getIterLim () |
GAMS Parameter: Iteration limit for model run. More... | |
int | getNodeLim () |
GAMS Parameter: Node limit for model run if using a branch-and-bound algorithm. More... | |
int | getGamsInteger (int nr) |
GAMS Parameter: Integers 1 to 5. More... | |
int | getGamsInteger (int intnr, int bitnr) |
GAMS Parameter: Integers 1 to 5, bitwise. More... | |
double | getOptCA () |
GAMS Parameter: Allowed absolute difference between incumbent solution and best bound (for MIPs). More... | |
double | getOptCR () |
GAMS Parameter: Allowed relative difference between incumbent solution and best bound (for MIPs). More... | |
double | getCheat () |
GAMS Parameter: A new valid solution must be at least this much better than incumbent integer solution (for MIPs). More... | |
double | getCutOff () |
GAMS Parmeter: Implied upper/lower bound on objective function. More... | |
bool | getScaleOption () |
GAMS Option: If set, then the solver should use the scaling parameters in ColScale() and RowScale(). More... | |
bool | getPriorityOption () |
GAMS Option: If set, then the solver should use the branching priorities in ColPriority(). More... | |
const char * | getOptionfile () |
The name of the option file. More... | |
Private Member Functions | |
void | Allocate () |
Private Attributes | |
int | nCols_ |
Indicates whether we have column and row names. More... | |
int | nDCols_ |
int | nSOS1_ |
int | nSOS2_ |
int | nSemiCon_ |
int | nRows_ |
int | nNnz_ |
double | startTime_ |
double * | ColLb_ |
double * | ColUb_ |
bool * | ColDisc_ |
int * | SOSIndicator_ |
bool * | ColSemiCon_ |
double * | ColLevel_ |
double * | ColMargin_ |
int * | ColBasis_ |
double * | ColPriority_ |
double * | ColScale_ |
int * | ColIndicator_ |
char * | RowSense_ |
double * | RowRhs_ |
double * | RowScale_ |
double * | RowLevel_ |
double * | RowMargin_ |
int * | RowBasis_ |
int * | RowIndicator_ |
double | ObjSense_ |
double * | ObjCoef_ |
double | ObjRhs_ |
double | zCoef_ |
double | ObjScale_ |
int | isReform_ |
int * | matStart_ |
int * | matRowIdx_ |
double * | matValue_ |
double | ObjVal_ |
double | ObjBound_ |
double | ResUsed_ |
int | IterUsed_ |
int | DomUsed_ |
int | NodeUsed_ |
SolverStatus | SolverStatus_ |
ModelStatus | ModelStatus_ |
Representation of a mixed-integer linear GAMS model read in from GAMS iolib.
This class is a layer between the GAMS I/O libraries and the GAMS-interfaces to (OSI-compatible) LP and MIP solvers.
Definition at line 21 of file GamsModel.hpp.
Basis status indicator used in GAMS.
Enumerator | |
---|---|
NonBasicLower | |
NonBasicUpper | |
Basic | |
SuperBasic | |
LastBasisStatus |
Definition at line 25 of file GamsModel.hpp.
Column status indicator used in GAMS.
Enumerator | |
---|---|
VarNormal | |
VarNonOptimal | |
VarInfeasible | |
VarUnbounded | |
VarLastStatus |
Definition at line 35 of file GamsModel.hpp.
enum GamsModel::RowStatus |
Row status indicator used in GAMS.
Enumerator | |
---|---|
RowNormal | |
RowNonOptimal | |
RowInfeasible | |
RowUnbounded | |
RowLastStatus |
Definition at line 45 of file GamsModel.hpp.
GAMS Solver status codes.
Definition at line 55 of file GamsModel.hpp.
GAMS Model status codes.
Definition at line 75 of file GamsModel.hpp.
enum GamsModel::PrintMask |
Distinguishing between message types.
Enumerator | |
---|---|
LogMask | |
StatusMask | |
AllMask | |
LastPrintMask |
Definition at line 101 of file GamsModel.hpp.
GamsModel::GamsModel | ( | const char * | cntrfile | ) |
Constructor.
Note, that you need to call readMatrix() before you can access the LP. After constructing a GamsModel you have only access to the options file and can, e.g., change the value for infinity.
cntrfile | Name of GAMS control file. |
GamsModel::~GamsModel | ( | ) |
Destructor.
void GamsModel::readMatrix | ( | ) |
Reads the LP from the GAMS matrix file and stores it into the data structures of this class.
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.
double GamsModel::getMInfinity | ( | ) | const |
Value used by GAMS for minus infinity.
double GamsModel::getPInfinity | ( | ) | const |
Value used by GAMS for plus infinity.
void GamsModel::setInfinity | ( | const double & | SolverMInf, |
const double & | SolverPInf | ||
) |
Set values that GAMS should use for minus and plus infinity.
|
inline |
Tells whether the model has been reformulated by moving the objective equation into the objective and eliminating the objective variable.
Definition at line 167 of file GamsModel.hpp.
References isReform_.
bool GamsModel::isLP | ( | ) | const |
Indicates whether we represent an LP or not.
It is an LP, if there are no discrete columns, no SOS, and no semicontinuous variables.
|
inline |
The number of columns in the model.
Definition at line 177 of file GamsModel.hpp.
References nCols_.
|
inline |
The number of discrete columns in the model.
Definition at line 180 of file GamsModel.hpp.
References nDCols_.
|
inline |
The number of special ordered sets of type 1 in the model.
Definition at line 183 of file GamsModel.hpp.
References nSOS1_.
|
inline |
The number of special ordered sets of type 2 in the model.
Definition at line 186 of file GamsModel.hpp.
References nSOS2_.
|
inline |
The number of semicontinuous variables.
Definition at line 189 of file GamsModel.hpp.
References nSemiCon_.
|
inline |
|
inline |
The number of nonzeros in the matrix of the model.
Definition at line 195 of file GamsModel.hpp.
References nNnz_.
|
inline |
|
inline |
|
inline |
Indicates whether a variable is discrete (true) or not (false).
Definition at line 205 of file GamsModel.hpp.
References ColDisc_.
|
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 213 of file GamsModel.hpp.
References SOSIndicator_.
|
inline |
Indicates whether a variable is semicontinuous or semiinteger (true) or not (false).
To distinguish between semicontinious and semiinteger variables, consult the ColDisc() array. That is, a variable is semiinteger if it is semicontinuous and discrete.
Definition at line 218 of file GamsModel.hpp.
References ColSemiCon_.
|
inline |
Initial values and storage for the solution values of the primal variables.
Definition at line 221 of file GamsModel.hpp.
References ColLevel_.
|
inline |
Initial marginals and storage for the solution values of the dual variables corresponding to the column bound constraints (reduced costs).
Definition at line 224 of file GamsModel.hpp.
References ColMargin_.
|
inline |
Initial basis status and storage for the solution basis status of the columns.
Definition at line 227 of file GamsModel.hpp.
References ColBasis_.
|
inline |
Branching priorities of columns.
In GAMS, you can specify branching priorities with the .prior suffix. As lower the value, as higher is the priority.
Definition at line 232 of file GamsModel.hpp.
References ColPriority_.
|
inline |
Scaling parameters for columns.
In GAMS, you can specify scaling parameters with the .scale suffix.
Definition at line 236 of file GamsModel.hpp.
References ColScale_.
|
inline |
The sense of the rows.
RowSense[i] is
Definition at line 246 of file GamsModel.hpp.
References RowSense_.
|
inline |
|
inline |
Initial values and storage for the solution levels of the rows (row activities).
Definition at line 252 of file GamsModel.hpp.
References RowLevel_.
|
inline |
Initial marginals and storage for the solution values of the dual variables corresponding to the rows (row prices).
Definition at line 255 of file GamsModel.hpp.
References RowMargin_.
|
inline |
Initial basis status and storage for the solution basis status of the rows.
Definition at line 258 of file GamsModel.hpp.
References RowBasis_.
|
inline |
Scaling parameters for rows.
In GAMS, you can specify scaling parameters with the .scale suffix.
Definition at line 262 of file GamsModel.hpp.
References RowScale_.
|
inline |
The coefficients of the objective function (dense format).
Definition at line 266 of file GamsModel.hpp.
References ObjCoef_.
|
inline |
A constant term in the objective function.
Definition at line 269 of file GamsModel.hpp.
References ObjRhs_.
|
inline |
The sense of the objective function or optimization, respectively.
Definition at line 273 of file GamsModel.hpp.
References ObjSense_.
|
inline |
Scaling parameter for objective function.
Computing from scaling parameter of objective row and objective variable. Default: 1
Definition at line 278 of file GamsModel.hpp.
References ObjScale_.
|
inline |
The column starts for the problem matrix.
Definition at line 282 of file GamsModel.hpp.
References matStart_.
|
inline |
The row indices for the problem matrix.
Definition at line 285 of file GamsModel.hpp.
References matRowIdx_.
|
inline |
The values for the problem matrix.
Definition at line 288 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. |
|
inline |
Sets the number of iterations used.
IterUsed | Number of iterations the solver used. |
Definition at line 316 of file GamsModel.hpp.
References IterUsed_.
|
inline |
Sets the number of seconds used.
ResUsed | Number of seconds the solver used. |
Definition at line 320 of file GamsModel.hpp.
References ResUsed_.
|
inline |
Sets the number of nodes used (in a branch-and-bound algorithm).
NodesUsed | Number of nodes the solver used. |
Definition at line 324 of file GamsModel.hpp.
References NodeUsed_.
|
inline |
Sets the objective function value in the solution.
ObjVal | Value of objective function. |
Definition at line 328 of file GamsModel.hpp.
References ObjVal_.
|
inline |
Sets an bound (estimate) on the optimal value.
ObjBound | Value of optimal value estimate. |
Definition at line 332 of file GamsModel.hpp.
References ObjBound_.
|
inline |
Gives the stored objective function value.
Definition at line 335 of file GamsModel.hpp.
References ObjVal_.
|
inline |
Gives the stored number of seconds used.
Definition at line 338 of file GamsModel.hpp.
References ResUsed_.
|
inline |
Storage for column indicators.
Definition at line 343 of file GamsModel.hpp.
References ColIndicator_.
|
inline |
Storage for row indicators.
Definition at line 347 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::getCheat | ( | ) |
GAMS Parameter: A new valid solution must be at least this much better than incumbent integer solution (for MIPs).
double GamsModel::getCutOff | ( | ) |
GAMS Parmeter: Implied upper/lower bound on objective function.
bool GamsModel::getScaleOption | ( | ) |
GAMS Option: If set, then the solver should use the scaling parameters in ColScale() and RowScale().
bool GamsModel::getPriorityOption | ( | ) |
GAMS Option: If set, then the solver should use the branching priorities in ColPriority().
const char* GamsModel::getOptionfile | ( | ) |
The name of the option file.
|
private |
|
private |
Indicates whether we have column and row names.
Definition at line 414 of file GamsModel.hpp.
Referenced by nCols().
|
private |
Definition at line 415 of file GamsModel.hpp.
Referenced by nDCols().
|
private |
Definition at line 416 of file GamsModel.hpp.
Referenced by nSOS1().
|
private |
Definition at line 417 of file GamsModel.hpp.
Referenced by nSOS2().
|
private |
Definition at line 418 of file GamsModel.hpp.
Referenced by nSemiContinuous().
|
private |
Definition at line 419 of file GamsModel.hpp.
Referenced by nRows().
|
private |
Definition at line 420 of file GamsModel.hpp.
Referenced by nNnz().
|
private |
Definition at line 422 of file GamsModel.hpp.
|
private |
Definition at line 424 of file GamsModel.hpp.
Referenced by ColLb().
|
private |
Definition at line 425 of file GamsModel.hpp.
Referenced by ColUb().
|
private |
Definition at line 426 of file GamsModel.hpp.
Referenced by ColDisc().
|
private |
Definition at line 427 of file GamsModel.hpp.
Referenced by SOSIndicator().
|
private |
Definition at line 428 of file GamsModel.hpp.
Referenced by ColSemiContinuous().
|
private |
Definition at line 429 of file GamsModel.hpp.
Referenced by ColLevel().
|
private |
Definition at line 430 of file GamsModel.hpp.
Referenced by ColMargin().
|
private |
Definition at line 431 of file GamsModel.hpp.
Referenced by ColBasis().
|
private |
Definition at line 432 of file GamsModel.hpp.
Referenced by ColPriority().
|
private |
Definition at line 433 of file GamsModel.hpp.
Referenced by ColScale().
|
private |
Definition at line 434 of file GamsModel.hpp.
Referenced by ColIndicator().
|
private |
Definition at line 436 of file GamsModel.hpp.
Referenced by RowSense().
|
private |
Definition at line 437 of file GamsModel.hpp.
Referenced by RowRhs().
|
private |
Definition at line 438 of file GamsModel.hpp.
Referenced by RowScale().
|
private |
Definition at line 439 of file GamsModel.hpp.
Referenced by RowLevel().
|
private |
Definition at line 440 of file GamsModel.hpp.
Referenced by RowMargin().
|
private |
Definition at line 441 of file GamsModel.hpp.
Referenced by RowBasis().
|
private |
Definition at line 442 of file GamsModel.hpp.
Referenced by RowIndicator().
|
private |
Definition at line 444 of file GamsModel.hpp.
Referenced by ObjSense().
|
private |
Definition at line 445 of file GamsModel.hpp.
Referenced by ObjCoef().
|
private |
Definition at line 446 of file GamsModel.hpp.
Referenced by ObjConstant().
|
private |
Definition at line 447 of file GamsModel.hpp.
|
private |
Definition at line 448 of file GamsModel.hpp.
Referenced by ObjScale().
|
private |
Definition at line 449 of file GamsModel.hpp.
Referenced by isReformulated().
|
private |
Definition at line 451 of file GamsModel.hpp.
Referenced by matStart().
|
private |
Definition at line 452 of file GamsModel.hpp.
Referenced by matRowIdx().
|
private |
Definition at line 453 of file GamsModel.hpp.
Referenced by matValue().
|
private |
Definition at line 457 of file GamsModel.hpp.
Referenced by getObjVal(), and setObjVal().
|
private |
Definition at line 458 of file GamsModel.hpp.
Referenced by setObjBound().
|
private |
Definition at line 459 of file GamsModel.hpp.
Referenced by getResUsed(), and setResUsed().
|
private |
Definition at line 460 of file GamsModel.hpp.
Referenced by setIterUsed().
|
private |
Definition at line 461 of file GamsModel.hpp.
|
private |
Definition at line 462 of file GamsModel.hpp.
Referenced by setNodesUsed().
|
private |
Definition at line 464 of file GamsModel.hpp.
|
private |
Definition at line 465 of file GamsModel.hpp.