- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# /home/coin/SVN-release/Cgl-0.52.0/Clp/src/ClpFactorization.hpp

Go to the documentation of this file.

    00001 // Copyright (C) 2002, International Business Machines
    00002 // Corporation and others.  All Rights Reserved.
    00003 #ifndef ClpFactorization_H
    00004 #define ClpFactorization_H
    00005
    00006
    00007 #include "CoinPragma.hpp"
    00008
    00009 #include "CoinFactorization.hpp"
    00010 class ClpMatrixBase;
    00011 class ClpSimplex;
    00012 class ClpNetworkBasis;
    00013 //#define CLP_MULTIPLE_FACTORIZATIONS
    00014 #ifdef CLP_MULTIPLE_FACTORIZATIONS
    00015 #include "CoinDenseFactorization.hpp"
    00016 #endif
    00017
    00022 class ClpFactorization
    00023 #ifndef CLP_MULTIPLE_FACTORIZATIONS
    00024   : public CoinFactorization
    00025 #endif
    00026 {
    00027
    00028   //friend class CoinFactorization;
    00029
    00030 public:
    00042   int factorize (ClpSimplex * model,int solveType, bool valuesPass);
    00044
    00045
    00049    ClpFactorization();
    00051    ~ClpFactorization();
    00053
    00057    ClpFactorization(const ClpFactorization&);
    00059    ClpFactorization(const CoinFactorization&);
    00060 #ifdef CLP_MULTIPLE_FACTORIZATIONS
    00061
    00062    ClpFactorization(const CoinDenseFactorization&);
    00063 #endif
    00064    ClpFactorization& operator=(const ClpFactorization&);
    00066
    00067   /*  **** below here is so can use networkish basis */
    00070
    00078   int replaceColumn ( const ClpSimplex * model,
    00079                       CoinIndexedVector * regionSparse,
    00080                       CoinIndexedVector * tableauColumn,
    00081                       int pivotRow,
    00082                       double pivotCheck ,
    00083                       bool checkBeforeModifying=false);
    00085
    00093   int updateColumnFT ( CoinIndexedVector * regionSparse,
    00094                        CoinIndexedVector * regionSparse2);
    00095   int updateColumn ( CoinIndexedVector * regionSparse,
    00096                      CoinIndexedVector * regionSparse2,
    00097                      bool noPermute=false) const;
    00099   int updateColumnForDebug ( CoinIndexedVector * regionSparse,
    00100                      CoinIndexedVector * regionSparse2,
    00101                      bool noPermute=false) const;
    00104   int updateColumnTranspose ( CoinIndexedVector * regionSparse,
    00105                               CoinIndexedVector * regionSparse2) const;
    00107 #ifdef CLP_MULTIPLE_FACTORIZATIONS
    00108
    00110
    00111   inline int numberElements (  ) const {
    00112     if (coinFactorizationA_) return coinFactorizationA_->numberElements(); else return coinFactorizationB_->numberElements() ;
    00113   }
    00115   inline int *permute (  ) const {
    00116     if (coinFactorizationA_) return coinFactorizationA_->permute(); else return coinFactorizationB_->permute() ;
    00117   }
    00119   inline int *pivotColumn (  ) const {
    00120     if (coinFactorizationA_) return coinFactorizationA_->pivotColumn(); else return coinFactorizationB_->permute() ;
    00121   }
    00123   inline int maximumPivots (  ) const {
    00124     if (coinFactorizationA_) return coinFactorizationA_->maximumPivots();  else return coinFactorizationB_->maximumPivots() ;
    00125   }
    00127   inline void maximumPivots (  int value) {
    00128     if (coinFactorizationA_) coinFactorizationA_->maximumPivots(value); else coinFactorizationB_->maximumPivots(value);
    00129   }
    00131   inline int pivots (  ) const {
    00132     if (coinFactorizationA_) return coinFactorizationA_->pivots(); else return coinFactorizationB_->pivots() ;
    00133   }
    00135   inline double areaFactor (  ) const {
    00136     if (coinFactorizationA_) return coinFactorizationA_->areaFactor(); else return 0.0 ;
    00137   }
    00139   inline void areaFactor ( double value) {
    00140     if (coinFactorizationA_) coinFactorizationA_->areaFactor(value);
    00141   }
    00143   inline double zeroTolerance (  ) const {
    00144     if (coinFactorizationA_) return coinFactorizationA_->zeroTolerance();  else return coinFactorizationB_->zeroTolerance() ;
    00145   }
    00147   inline void zeroTolerance (  double value) {
    00148     if (coinFactorizationA_) coinFactorizationA_->zeroTolerance(value); else coinFactorizationB_->zeroTolerance(value);
    00149   }
    00151   inline int sparseThreshold ( ) const
    00152   { if (coinFactorizationA_) return coinFactorizationA_->sparseThreshold(); else return 0 ;}
    00154   inline void sparseThreshold ( int value)
    00155   { if (coinFactorizationA_) coinFactorizationA_->sparseThreshold(value); }
    00157   inline int status (  ) const {
    00158     if (coinFactorizationA_) return coinFactorizationA_->status(); else return coinFactorizationB_->status() ;
    00159   }
    00161   inline void setStatus (  int value) {
    00162     if (coinFactorizationA_) coinFactorizationA_->setStatus(value); else coinFactorizationB_->setStatus(value) ;
    00163   }
    00165   inline int numberDense() const
    00166   { if (coinFactorizationA_) return coinFactorizationA_->numberDense(); else return 0 ;}
    00167 #if 0
    00169   inline CoinBigIndex numberElementsU (  ) const {
    00170     if (coinFactorizationA_) return coinFactorizationA_->numberElementsU(); else return 0 ;
    00171   }
    00173   inline CoinBigIndex numberElementsL (  ) const {
    00174     if (coinFactorizationA_) return coinFactorizationA_->numberElementsL(); else return 0 ;
    00175   }
    00177   inline CoinBigIndex numberElementsR (  ) const {
    00178     if (coinFactorizationA_) return coinFactorizationA_->numberElementsR(); else return 0 ;
    00179   }
    00180 #endif
    00181   inline bool timeToRefactorize() const
    00182   {
    00183     if (coinFactorizationA_) {
    00184       return (coinFactorizationA_->pivots()*3>coinFactorizationA_->maximumPivots()*2&&
    00185               coinFactorizationA_->numberElementsR()*3>(coinFactorizationA_->numberElementsL()+
    00186                                                         coinFactorizationA_->numberElementsU())*2+1000&&
    00187               !coinFactorizationA_->numberDense());
    00188     } else {
    00189       return coinFactorizationB_->pivots()>coinFactorizationB_->numberRows()/2.45+20;
    00190     }
    00191   }
    00193   inline int messageLevel (  ) const {
    00194     if (coinFactorizationA_) return coinFactorizationA_->messageLevel();  else return 0 ;
    00195   }
    00197   inline void messageLevel (  int value) {
    00198     if (coinFactorizationA_) coinFactorizationA_->messageLevel(value);
    00199   }
    00201   inline void clearArrays()
    00202   { if (coinFactorizationA_) coinFactorizationA_->clearArrays();}
    00204   inline int numberRows (  ) const {
    00205     if (coinFactorizationA_) return coinFactorizationA_->numberRows(); else return coinFactorizationB_->numberRows() ;
    00206   }
    00208   inline int denseThreshold() const
    00209   { if (coinFactorizationA_) return coinFactorizationA_->denseThreshold(); else return 0 ;}
    00211   inline void setDenseThreshold(int value)
    00212   { if (coinFactorizationA_) coinFactorizationA_->setDenseThreshold(value);}
    00214   inline double pivotTolerance (  ) const {
    00215     if (coinFactorizationA_) return coinFactorizationA_->pivotTolerance();  else return 1.0e-8 ;
    00216   }
    00218   inline void pivotTolerance (  double value) {
    00219     if (coinFactorizationA_) coinFactorizationA_->pivotTolerance(value);
    00220   }
    00222   inline void relaxAccuracyCheck(double value)
    00223   { if (coinFactorizationA_) coinFactorizationA_->relaxAccuracyCheck(value);}
    00229   inline int persistenceFlag() const
    00230   { if (coinFactorizationA_) return coinFactorizationA_->persistenceFlag(); else return 0 ;}
    00231   inline void setPersistenceFlag(int value)
    00232   { if (coinFactorizationA_) coinFactorizationA_->setPersistenceFlag(value);}
    00234   inline void almostDestructor()
    00235   { if (coinFactorizationA_) coinFactorizationA_->almostDestructor(); }
    00237   inline double adjustedAreaFactor() const
    00238   { if (coinFactorizationA_) return coinFactorizationA_->adjustedAreaFactor(); else return 0.0 ; }
    00239   inline void setBiasLU(int value)
    00240   { if (coinFactorizationA_) coinFactorizationA_->setBiasLU(value);}
    00242   inline void setForrestTomlin(bool value)
    00243   { if (coinFactorizationA_) coinFactorizationA_->setForrestTomlin(value);}
    00245   inline void setDefaultValues() {
    00246     if (coinFactorizationA_) {
    00247       coinFactorizationA_->increasingRows(2);
    00248       // row activities have negative sign
    00249       coinFactorizationA_->slackValue(-1.0);
    00250       coinFactorizationA_->zeroTolerance(1.0e-13);
    00251     }
    00252   }
    00254   void goDense() ;
    00255 #else
    00256   inline bool timeToRefactorize() const
    00257   {
    00258     return (pivots()*3>maximumPivots()*2&&
    00259             numberElementsR()*3>(numberElementsL()+numberElementsU())*2+1000&&
    00260             !numberDense());
    00261   }
    00263   inline void setDefaultValues() {
    00264     increasingRows(2);
    00265     // row activities have negative sign
    00266     slackValue(-1.0);
    00267     zeroTolerance(1.0e-13);
    00268   }
    00270   inline void goDense() {}
    00271 #endif
    00272
    00273
    00277   void goSparse();
    00279   void cleanUp();
    00281   bool needToReorder() const;
    00282 #ifndef SLIM_CLP
    00284   inline bool networkBasis() const
    00285   { return (networkBasis_!=NULL);}
    00286 #else
    00288   inline bool networkBasis() const
    00289   { return false;}
    00290 #endif
    00292   void getWeights(int * weights) const;
    00293
    00294
    00296 private:
    00297
    00300
    00301 #ifndef SLIM_CLP
    00302   ClpNetworkBasis * networkBasis_;
    00303 #endif
    00304 #ifdef CLP_MULTIPLE_FACTORIZATIONS
    00306   CoinFactorization * coinFactorizationA_;
    00308   CoinDenseFactorization * coinFactorizationB_;
    00309 #endif
    00310
    00311 };
    00312
    00313 #endif