GamsModel.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2006-2008 GAMS Development and others
00002 // All Rights Reserved.
00003 // This code is published under the Common Public License.
00004 //
00005 // $Id: GamsModel.hpp 510 2008-08-16 19:31:27Z stefan $
00006 //
00007 // Authors: Michael Bussieck, Stefan Vigerske
00008 
00009 #ifndef __GAMSMODEL_HPP__
00010 #define __GAMSMODEL_HPP__
00011 
00012 #include "GAMSlinksConfig.h"
00013 // from CoinUtils
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(); // Iteration limit for model run
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 //      inline bool haveNames() { return dict; }
00412         
00413 private:
00414   int nCols_;  // # columns
00415   int nDCols_; // # discrete columns
00416   int nSOS1_;  // # SOS type 1
00417   int nSOS2_;  // # SOS type 2
00418   int nSemiCon_; // # semicontinuous or semicont. integer columns
00419   int nRows_;  // # rows
00420   int nNnz_;   // # non zeros
00421 
00422   double startTime_; // Start time
00423 
00424   double *ColLb_;   // lower bound for columns
00425   double *ColUb_;   // upper bound for columns
00426   bool   *ColDisc_; // indicator for discrete columns: discrete (true) or not (false)
00427   int    *SOSIndicator_;  // indicator for SOS of type 1 and 2
00428   bool   *ColSemiCon_;  // indicator for semicontinuous columns: semicon. (true) or not (false)
00429   double *ColLevel_; // values of column variables
00430   double *ColMargin_; // marginal values = duals
00431   int    *ColBasis_; // column basis status
00432   double *ColPriority_; // branching priority
00433   double *ColScale_; // scaling parameter
00434   int    *ColIndicator_; // indicator for feasibility
00435 
00436   char   *RowSense_; // sense of row
00437   double *RowRhs_;   // right hand side
00438   double *RowScale_; // scaling parameters
00439   double *RowLevel_; // values of rows = row activity
00440   double *RowMargin_; // marginal values = duals
00441   int    *RowBasis_; // Row basis status
00442   int    *RowIndicator_; // indicator for feasibility
00443 
00444   double ObjSense_; // objective sense 1=min, -1=max
00445   double *ObjCoef_;  // Dense objective function
00446   double  ObjRhs_;   // constant in objective function
00447   double  zCoef_;    // coefficient of objective variable
00448   double ObjScale_;  // scale value of objective variable
00449   int     isReform_; // reformulated objective function
00450 
00451   int    *matStart_;  // matrix start of column
00452   int    *matRowIdx_; // matrix row index
00453   double *matValue_;  // matrix values
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__

Generated on Tue Dec 30 03:01:24 2008 for GAMSlinks by  doxygen 1.4.7