Clp trunk
|
00001 /* $Id$ */ 00002 // Copyright (C) 2003, 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 ClpGubMatrix_H 00007 #define ClpGubMatrix_H 00008 00009 00010 #include "CoinPragma.hpp" 00011 00012 #include "ClpPackedMatrix.hpp" 00013 class ClpSimplex; 00022 class ClpGubMatrix : public ClpPackedMatrix { 00023 00024 public: 00028 virtual ClpMatrixBase * reverseOrderedCopy() const; 00030 virtual CoinBigIndex countBasis(const int * whichColumn, 00031 int & numberColumnBasic); 00033 virtual void fillBasis(ClpSimplex * model, 00034 const int * whichColumn, 00035 int & numberColumnBasic, 00036 int * row, int * start, 00037 int * rowCount, int * columnCount, 00038 CoinFactorizationDouble * element); 00041 virtual void unpack(const ClpSimplex * model, CoinIndexedVector * rowArray, 00042 int column) const ; 00047 virtual void unpackPacked(ClpSimplex * model, 00048 CoinIndexedVector * rowArray, 00049 int column) const; 00052 virtual void add(const ClpSimplex * model, CoinIndexedVector * rowArray, 00053 int column, double multiplier) const ; 00055 virtual void add(const ClpSimplex * model, double * array, 00056 int column, double multiplier) const; 00058 virtual void partialPricing(ClpSimplex * model, double start, double end, 00059 int & bestSequence, int & numberWanted); 00061 virtual int hiddenRows() const; 00063 00066 00067 using ClpPackedMatrix::transposeTimes ; 00072 virtual void transposeTimes(const ClpSimplex * model, double scalar, 00073 const CoinIndexedVector * x, 00074 CoinIndexedVector * y, 00075 CoinIndexedVector * z) const; 00081 virtual void transposeTimesByRow(const ClpSimplex * model, double scalar, 00082 const CoinIndexedVector * x, 00083 CoinIndexedVector * y, 00084 CoinIndexedVector * z) const; 00088 virtual void subsetTransposeTimes(const ClpSimplex * model, 00089 const CoinIndexedVector * x, 00090 const CoinIndexedVector * y, 00091 CoinIndexedVector * z) const; 00098 virtual int extendUpdated(ClpSimplex * model, CoinIndexedVector * update, int mode); 00104 virtual void primalExpanded(ClpSimplex * model, int mode); 00113 virtual void dualExpanded(ClpSimplex * model, CoinIndexedVector * array, 00114 double * other, int mode); 00132 virtual int generalExpanded(ClpSimplex * model, int mode, int & number); 00136 virtual int updatePivot(ClpSimplex * model, double oldInValue, double oldOutValue); 00138 virtual void useEffectiveRhs(ClpSimplex * model, bool cheapest = true); 00142 virtual double * rhsOffset(ClpSimplex * model, bool forceRefresh = false, 00143 bool check = false); 00156 virtual int synchronize(ClpSimplex * model, int mode); 00158 virtual void correctSequence(const ClpSimplex * model, int & sequenceIn, int & sequenceOut) ; 00160 00161 00162 00166 ClpGubMatrix(); 00168 virtual ~ClpGubMatrix(); 00170 00174 ClpGubMatrix(const ClpGubMatrix&); 00176 ClpGubMatrix(const CoinPackedMatrix&); 00179 ClpGubMatrix (const ClpGubMatrix & wholeModel, 00180 int numberRows, const int * whichRows, 00181 int numberColumns, const int * whichColumns); 00182 ClpGubMatrix (const CoinPackedMatrix & wholeModel, 00183 int numberRows, const int * whichRows, 00184 int numberColumns, const int * whichColumns); 00185 00187 ClpGubMatrix(CoinPackedMatrix * matrix); 00188 00191 ClpGubMatrix(ClpPackedMatrix * matrix, int numberSets, 00192 const int * start, const int * end, 00193 const double * lower, const double * upper, 00194 const unsigned char * status = NULL); 00195 00196 ClpGubMatrix& operator=(const ClpGubMatrix&); 00198 virtual ClpMatrixBase * clone() const ; 00201 virtual ClpMatrixBase * subsetClone ( 00202 int numberRows, const int * whichRows, 00203 int numberColumns, const int * whichColumns) const ; 00205 void redoSet(ClpSimplex * model, int newKey, int oldKey, int iSet); 00207 00209 00210 inline ClpSimplex::Status getStatus(int sequence) const { 00211 return static_cast<ClpSimplex::Status> (status_[sequence] & 7); 00212 } 00213 inline void setStatus(int sequence, ClpSimplex::Status status) { 00214 unsigned char & st_byte = status_[sequence]; 00215 st_byte = static_cast<unsigned char>(st_byte & ~7); 00216 st_byte = static_cast<unsigned char>(st_byte | status); 00217 } 00219 inline void setFlagged( int sequence) { 00220 status_[sequence] = static_cast<unsigned char>(status_[sequence] | 64); 00221 } 00222 inline void clearFlagged( int sequence) { 00223 status_[sequence] = static_cast<unsigned char>(status_[sequence] & ~64); 00224 } 00225 inline bool flagged(int sequence) const { 00226 return ((status_[sequence] & 64) != 0); 00227 } 00229 inline void setAbove( int sequence) { 00230 unsigned char iStat = status_[sequence]; 00231 iStat = static_cast<unsigned char>(iStat & ~24); 00232 status_[sequence] = static_cast<unsigned char>(iStat | 16); 00233 } 00235 inline void setFeasible( int sequence) { 00236 unsigned char iStat = status_[sequence]; 00237 iStat = static_cast<unsigned char>(iStat & ~24); 00238 status_[sequence] = static_cast<unsigned char>(iStat | 8); 00239 } 00241 inline void setBelow( int sequence) { 00242 unsigned char iStat = status_[sequence]; 00243 iStat = static_cast<unsigned char>(iStat & ~24); 00244 status_[sequence] = iStat; 00245 } 00246 inline double weight( int sequence) const { 00247 int iStat = status_[sequence] & 31; 00248 iStat = iStat >> 3; 00249 return static_cast<double> (iStat - 1); 00250 } 00252 inline int * start() const { 00253 return start_; 00254 } 00256 inline int * end() const { 00257 return end_; 00258 } 00260 inline double * lower() const { 00261 return lower_; 00262 } 00264 inline double * upper() const { 00265 return upper_; 00266 } 00268 inline int * keyVariable() const { 00269 return keyVariable_; 00270 } 00272 inline int * backward() const { 00273 return backward_; 00274 } 00276 inline int numberSets() const { 00277 return numberSets_; 00278 } 00280 void switchOffCheck(); 00282 00283 00284 protected: 00288 00289 double sumDualInfeasibilities_; 00291 double sumPrimalInfeasibilities_; 00293 double sumOfRelaxedDualInfeasibilities_; 00295 double sumOfRelaxedPrimalInfeasibilities_; 00297 double infeasibilityWeight_; 00299 int * start_; 00301 int * end_; 00303 double * lower_; 00305 double * upper_; 00307 mutable unsigned char * status_; 00309 unsigned char * saveStatus_; 00311 int * savedKeyVariable_; 00313 int * backward_; 00315 int * backToPivotRow_; 00317 double * changeCost_; 00319 mutable int * keyVariable_; 00323 mutable int * next_; 00325 int * toIndex_; 00326 // Reverse pointer from index to set 00327 int * fromIndex_; 00329 ClpSimplex * model_; 00331 int numberDualInfeasibilities_; 00333 int numberPrimalInfeasibilities_; 00339 int noCheck_; 00341 int numberSets_; 00343 int saveNumber_; 00345 int possiblePivotKey_; 00347 int gubSlackIn_; 00349 int firstGub_; 00351 int lastGub_; 00354 int gubType_; 00356 }; 00357 00358 #endif