00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __GAMSMODEL_HPP__
00010 #define __GAMSMODEL_HPP__
00011
00012 #include "GAMSlinksConfig.h"
00013
00014 #include "CoinPragma.hpp"
00015
00016 extern "C" struct dictRec;
00017
00021 class GamsModel {
00022 public:
00025 enum BasisStatus {
00026 NonBasicLower = 0,
00027 NonBasicUpper,
00028 Basic,
00029 SuperBasic,
00030 LastBasisStatus
00031 };
00032
00035 enum VariableStatus {
00036 VarNormal = 0,
00037 VarNonOptimal,
00038 VarInfeasible,
00039 VarUnbounded,
00040 VarLastStatus
00041 };
00042
00045 enum RowStatus {
00046 RowNormal = 0,
00047 RowNonOptimal,
00048 RowInfeasible,
00049 RowUnbounded,
00050 RowLastStatus
00051 };
00052
00055 enum SolverStatus {
00056 SolverStatusNotSet = 0,
00057 NormalCompletion = 1,
00058 IterationInterrupt,
00059 ResourceInterrupt,
00060 TerminatedBySolver,
00061 EvaluationErrorLimit,
00062 CapabilityProblems,
00063 LicensingProblems,
00064 UserInterrupt,
00065 ErrorSetupFailure,
00066 ErrorSolverFailure,
00067 ErrorInternalSolverError,
00068 SolveProcessingSkipped,
00069 ErrorSystemFailure,
00070 LastSolverStatus
00071 };
00072
00075 enum ModelStatus {
00076 ModelStatusNotSet = 0,
00077 Optimal,
00078 LocallyOptimal,
00079 Unbounded,
00080 Infeasible,
00081 LocallyInfeasible,
00082 IntermediateInfeasible,
00083 IntermediateNonoptimal,
00084 IntegerSolution,
00085 IntermediateNonInteger,
00086 IntegerInfeasible,
00087 LicensingProblemNoSolution,
00088 ErrorUnknown,
00089 ErrorNoSolution,
00090 NoSolutionReturned,
00091 SolvedUnique,
00092 Solved,
00093 SolvedSingular,
00094 UnboundedNoSolution,
00095 InfeasibleNoSolution,
00096 LastModelStatus
00097 };
00098
00101 enum PrintMask {
00102 LogMask = 0x1,
00103 StatusMask = 0x2,
00104 AllMask = LogMask|StatusMask,
00105 LastPrintMask
00106 };
00107
00108
00114 GamsModel(const char *cntrfile);
00115
00118 ~GamsModel();
00119
00122 void readMatrix();
00123
00133 void PrintOut(PrintMask mask, const char *msg);
00134
00137 int getSysOut();
00144 void TimerStart();
00147 double SecondsSinceStart();
00153 const char* getSystemDir();
00154
00157 double getMInfinity() const;
00160 double getPInfinity() const;
00163 void setInfinity(const double& SolverMInf, const double& SolverPInf);
00164
00167 bool isReformulated() const { return isReform_; }
00168
00174 bool isLP() const;
00177 inline int nCols() const { return nCols_; }
00180 inline int nDCols() const { return nDCols_; }
00183 inline int nSOS1() const { return nSOS1_; }
00186 inline int nSOS2() const { return nSOS2_; }
00189 inline int nSemiContinuous() const { return nSemiCon_; }
00192 inline int nRows() const { return nRows_; }
00195 inline int nNnz() const { return nNnz_; }
00196
00199 inline double *ColLb() { return ColLb_; }
00202 inline double *ColUb() { return ColUb_; }
00205 inline bool *ColDisc() { return ColDisc_; }
00213 inline int *SOSIndicator() { return SOSIndicator_; }
00218 inline bool *ColSemiContinuous() { return ColSemiCon_; }
00221 inline double *ColLevel() { return ColLevel_; }
00224 inline double *ColMargin() { return ColMargin_; }
00227 inline int *ColBasis() { return ColBasis_; }
00232 inline double *ColPriority() { return ColPriority_; }
00236 inline double *ColScale() { return ColScale_; }
00237
00246 inline char *RowSense() { return RowSense_; }
00249 inline double *RowRhs() { return RowRhs_; }
00252 inline double *RowLevel() { return RowLevel_; }
00255 inline double *RowMargin() { return RowMargin_; }
00258 inline int *RowBasis() { return RowBasis_; }
00262 inline double *RowScale() { return RowScale_; }
00263
00266 inline double *ObjCoef() { return ObjCoef_; }
00269 inline double ObjConstant() { return ObjRhs_; }
00273 inline double ObjSense() const { return ObjSense_; }
00278 inline double ObjScale() const { return ObjScale_; }
00279
00282 inline int *matStart() { return matStart_; }
00285 inline int *matRowIdx() { return matRowIdx_; }
00288 inline double *matValue() { return matValue_; }
00294 int matSqueezeZeros();
00301 ModelStatus getModelStatus();
00304 SolverStatus getSolverStatus();
00305
00310 void setStatus(const SolverStatus& newSolverStatus,
00311 const ModelStatus& newModelStatus);
00312
00316 inline void setIterUsed(const int IterUsed) { IterUsed_ = IterUsed; }
00320 inline void setResUsed(const double ResUsed) { ResUsed_ = ResUsed; }
00324 inline void setNodesUsed(const int NodesUsed) { NodeUsed_ = NodesUsed; }
00328 inline void setObjVal(const double ObjVal) { ObjVal_ = ObjVal; }
00332 inline void setObjBound(const double ObjBound) { ObjBound_ = ObjBound; }
00335 inline double getObjVal() { return ObjVal_; }
00338 inline double getResUsed() { return ResUsed_; }
00339
00343 inline int *ColIndicator() { return ColIndicator_; }
00347 inline int *RowIndicator() { return RowIndicator_; }
00348
00354 void setSolution(const double *ColLevel=0, const double *ColMargin=0,
00355 const int *ColBasis=0, const int *ColIndicator=0,
00356 const double *RowLevel=0, const double *RowMargin=0,
00357 const int *RowBasis=0, const int *RowIndicator=0);
00364 double getResLim();
00367 int getIterLim();
00370 int getNodeLim();
00376 int getGamsInteger(int nr);
00383 int getGamsInteger(int intnr, int bitnr);
00386 double getOptCA();
00389 double getOptCR();
00392 double getCheat();
00395 double getCutOff();
00398 bool getScaleOption();
00401 bool getPriorityOption();
00402
00406 const char* getOptionfile();
00411
00412
00413 private:
00414 int nCols_;
00415 int nDCols_;
00416 int nSOS1_;
00417 int nSOS2_;
00418 int nSemiCon_;
00419 int nRows_;
00420 int nNnz_;
00421
00422 double startTime_;
00423
00424 double *ColLb_;
00425 double *ColUb_;
00426 bool *ColDisc_;
00427 int *SOSIndicator_;
00428 bool *ColSemiCon_;
00429 double *ColLevel_;
00430 double *ColMargin_;
00431 int *ColBasis_;
00432 double *ColPriority_;
00433 double *ColScale_;
00434 int *ColIndicator_;
00435
00436 char *RowSense_;
00437 double *RowRhs_;
00438 double *RowScale_;
00439 double *RowLevel_;
00440 double *RowMargin_;
00441 int *RowBasis_;
00442 int *RowIndicator_;
00443
00444 double ObjSense_;
00445 double *ObjCoef_;
00446 double ObjRhs_;
00447 double zCoef_;
00448 double ObjScale_;
00449 int isReform_;
00450
00451 int *matStart_;
00452 int *matRowIdx_;
00453 double *matValue_;
00454
00455 void Allocate();
00456
00457 double ObjVal_;
00458 double ObjBound_;
00459 double ResUsed_;
00460 int IterUsed_;
00461 int DomUsed_;
00462 int NodeUsed_;
00463
00464 SolverStatus SolverStatus_;
00465 ModelStatus ModelStatus_;
00466 };
00467
00468 #endif // __GAMSMODEL_HPP__