CoinUtils
trunk
|
00001 /* $Id$ */ 00002 // Copyright (C) 2006, International Business Machines 00003 // Corporation and others. All Rights Reserved. 00004 // This code is licensed under the terms of the Eclipse Public License (EPL). 00005 00006 #ifndef CoinSnapshot_H 00007 #define CoinSnapshot_H 00008 00009 class CoinPackedMatrix; 00010 #include "CoinTypes.hpp" 00011 00012 //############################################################################# 00013 00025 class CoinSnapshot { 00026 00027 public: 00028 00029 //--------------------------------------------------------------------------- 00035 00036 inline int getNumCols() const 00037 { return numCols_;} 00038 00040 inline int getNumRows() const 00041 { return numRows_;} 00042 00044 inline int getNumElements() const 00045 { return numElements_;} 00046 00048 inline int getNumIntegers() const 00049 { return numIntegers_;} 00050 00052 inline const double * getColLower() const 00053 { return colLower_;} 00054 00056 inline const double * getColUpper() const 00057 { return colUpper_;} 00058 00060 inline const double * getRowLower() const 00061 { return rowLower_;} 00062 00064 inline const double * getRowUpper() const 00065 { return rowUpper_;} 00066 00074 inline const double * getRightHandSide() const 00075 { return rightHandSide_;} 00076 00078 inline const double * getObjCoefficients() const 00079 { return objCoefficients_;} 00080 00082 inline double getObjSense() const 00083 { return objSense_;} 00084 00086 inline bool isContinuous(int colIndex) const 00087 { return colType_[colIndex]=='C';} 00088 00090 inline bool isBinary(int colIndex) const 00091 { return colType_[colIndex]=='B';} 00092 00094 inline bool isInteger(int colIndex) const 00095 { return colType_[colIndex]=='B'||colType_[colIndex]=='I';} 00096 00098 inline bool isIntegerNonBinary(int colIndex) const 00099 { return colType_[colIndex]=='I';} 00100 00102 inline bool isFreeBinary(int colIndex) const 00103 { return colType_[colIndex]=='B'&&colUpper_[colIndex]>colLower_[colIndex];} 00104 00106 inline const char * getColType() const 00107 { return colType_;} 00108 00110 inline const CoinPackedMatrix * getMatrixByRow() const 00111 { return matrixByRow_;} 00112 00114 inline const CoinPackedMatrix * getMatrixByCol() const 00115 { return matrixByCol_;} 00116 00118 inline const CoinPackedMatrix * getOriginalMatrixByRow() const 00119 { return originalMatrixByRow_;} 00120 00122 inline const CoinPackedMatrix * getOriginalMatrixByCol() const 00123 { return originalMatrixByCol_;} 00125 00128 00129 inline const double * getColSolution() const 00130 { return colSolution_;} 00131 00133 inline const double * getRowPrice() const 00134 { return rowPrice_;} 00135 00137 inline const double * getReducedCost() const 00138 { return reducedCost_;} 00139 00141 inline const double * getRowActivity() const 00142 { return rowActivity_;} 00143 00145 inline const double * getDoNotSeparateThis() const 00146 { return doNotSeparateThis_;} 00148 00151 00152 inline double getInfinity() const 00153 { return infinity_;} 00154 00157 inline double getObjValue() const 00158 { return objValue_;} 00159 00161 inline double getObjOffset() const 00162 { return objOffset_;} 00163 00165 inline double getDualTolerance() const 00166 { return dualTolerance_;} 00167 00169 inline double getPrimalTolerance() const 00170 { return primalTolerance_;} 00171 00173 inline double getIntegerTolerance() const 00174 { return integerTolerance_;} 00175 00177 inline double getIntegerUpperBound() const 00178 { return integerUpperBound_;} 00179 00181 inline double getIntegerLowerBound() const 00182 { return integerLowerBound_;} 00184 00185 //--------------------------------------------------------------------------- 00186 00201 void loadProblem(const CoinPackedMatrix& matrix, 00202 const double* collb, const double* colub, 00203 const double* obj, 00204 const double* rowlb, const double* rowub, 00205 bool makeRowCopy=false); 00206 00208 00209 //--------------------------------------------------------------------------- 00210 00213 00214 inline void setNumCols(int value) 00215 { numCols_ = value;} 00216 00218 inline void setNumRows(int value) 00219 { numRows_ = value;} 00220 00222 inline void setNumElements(int value) 00223 { numElements_ = value;} 00224 00226 inline void setNumIntegers(int value) 00227 { numIntegers_ = value;} 00228 00230 void setColLower(const double * array, bool copyIn=true); 00231 00233 void setColUpper(const double * array, bool copyIn=true); 00234 00236 void setRowLower(const double * array, bool copyIn=true); 00237 00239 void setRowUpper(const double * array, bool copyIn=true); 00240 00248 void setRightHandSide(const double * array, bool copyIn=true); 00249 00258 void createRightHandSide(); 00259 00261 void setObjCoefficients(const double * array, bool copyIn=true); 00262 00264 inline void setObjSense(double value) 00265 { objSense_ = value;} 00266 00268 void setColType(const char *array, bool copyIn=true); 00269 00271 void setMatrixByRow(const CoinPackedMatrix * matrix, bool copyIn=true); 00272 00274 void createMatrixByRow(); 00275 00277 void setMatrixByCol(const CoinPackedMatrix * matrix, bool copyIn=true); 00278 00280 void setOriginalMatrixByRow(const CoinPackedMatrix * matrix, bool copyIn=true); 00281 00283 void setOriginalMatrixByCol(const CoinPackedMatrix * matrix, bool copyIn=true); 00284 00286 void setColSolution(const double * array, bool copyIn=true); 00287 00289 void setRowPrice(const double * array, bool copyIn=true); 00290 00292 void setReducedCost(const double * array, bool copyIn=true); 00293 00295 void setRowActivity(const double * array, bool copyIn=true); 00296 00298 void setDoNotSeparateThis(const double * array, bool copyIn=true); 00299 00301 inline void setInfinity(double value) 00302 { infinity_ = value;} 00303 00305 inline void setObjValue(double value) 00306 { objValue_ = value;} 00307 00309 inline void setObjOffset(double value) 00310 { objOffset_ = value;} 00311 00313 inline void setDualTolerance(double value) 00314 { dualTolerance_ = value;} 00315 00317 inline void setPrimalTolerance(double value) 00318 { primalTolerance_ = value;} 00319 00321 inline void setIntegerTolerance(double value) 00322 { integerTolerance_ = value;} 00323 00325 inline void setIntegerUpperBound(double value) 00326 { integerUpperBound_ = value;} 00327 00329 inline void setIntegerLowerBound(double value) 00330 { integerLowerBound_ = value;} 00332 00333 //--------------------------------------------------------------------------- 00334 00336 00337 00338 CoinSnapshot(); 00339 00341 CoinSnapshot(const CoinSnapshot &); 00342 00344 CoinSnapshot & operator=(const CoinSnapshot& rhs); 00345 00347 virtual ~CoinSnapshot (); 00348 00350 00351 private: 00353 00354 00360 void gutsOfDestructor(int type); 00362 void gutsOfCopy(const CoinSnapshot & rhs); 00364 00366 00368 double objSense_; 00369 00371 double infinity_; 00372 00374 double objValue_; 00375 00377 double objOffset_; 00378 00380 double dualTolerance_; 00381 00383 double primalTolerance_; 00384 00386 double integerTolerance_; 00387 00389 double integerUpperBound_; 00390 00392 double integerLowerBound_; 00393 00395 const double * colLower_; 00396 00398 const double * colUpper_; 00399 00401 const double * rowLower_; 00402 00404 const double * rowUpper_; 00405 00407 const double * rightHandSide_; 00408 00410 const double * objCoefficients_; 00411 00413 const char * colType_; 00414 00416 const CoinPackedMatrix * matrixByRow_; 00417 00419 const CoinPackedMatrix * matrixByCol_; 00420 00422 const CoinPackedMatrix * originalMatrixByRow_; 00423 00425 const CoinPackedMatrix * originalMatrixByCol_; 00426 00428 const double * colSolution_; 00429 00431 const double * rowPrice_; 00432 00434 const double * reducedCost_; 00435 00437 const double * rowActivity_; 00438 00440 const double * doNotSeparateThis_; 00441 00443 int numCols_; 00444 00446 int numRows_; 00447 00449 int numElements_; 00450 00452 int numIntegers_; 00453 00455 typedef struct { 00456 unsigned int colLower:1; 00457 unsigned int colUpper:1; 00458 unsigned int rowLower:1; 00459 unsigned int rowUpper:1; 00460 unsigned int rightHandSide:1; 00461 unsigned int objCoefficients:1; 00462 unsigned int colType:1; 00463 unsigned int matrixByRow:1; 00464 unsigned int matrixByCol:1; 00465 unsigned int originalMatrixByRow:1; 00466 unsigned int originalMatrixByCol:1; 00467 unsigned int colSolution:1; 00468 unsigned int rowPrice:1; 00469 unsigned int reducedCost:1; 00470 unsigned int rowActivity:1; 00471 unsigned int doNotSeparateThis:1; 00472 } coinOwned; 00473 coinOwned owned_; 00475 }; 00476 #endif