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

- File List
- File Members

# /home/coin/SVN-release/Blis-0.91.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 #ifndef CLP_MULTIPLE_FACTORIZATIONS
    00014 #define CLP_MULTIPLE_FACTORIZATIONS 3
    00015 #endif
    00016 #if CLP_MULTIPLE_FACTORIZATIONS == 1
    00017 #include "CoinDenseFactorization.hpp"
    00018 typedef CoinDenseFactorization CoinSmallFactorization;
    00019 #elif CLP_MULTIPLE_FACTORIZATIONS == 2
    00020 #include "CoinSimpFactorization.hpp"
    00021 typedef CoinSimpFactorization CoinSmallFactorization;
    00022 #elif CLP_MULTIPLE_FACTORIZATIONS == 3
    00023 #include "CoinDenseFactorization.hpp"
    00024 #include "CoinSimpFactorization.hpp"
    00025 #endif
    00026
    00031 class ClpFactorization
    00032 #ifndef CLP_MULTIPLE_FACTORIZATIONS
    00033   : public CoinFactorization
    00034 #endif
    00035 {
    00036
    00037   //friend class CoinFactorization;
    00038
    00039 public:
    00051   int factorize (ClpSimplex * model,int solveType, bool valuesPass);
    00053
    00054
    00058    ClpFactorization();
    00060    ~ClpFactorization();
    00062
    00066    ClpFactorization(const CoinFactorization&);
    00068   ClpFactorization(const ClpFactorization&,int denseIfSmaller=0);
    00069 #ifdef CLP_MULTIPLE_FACTORIZATIONS
    00070
    00071    ClpFactorization(const CoinSmallFactorization&);
    00072 #endif
    00073    ClpFactorization& operator=(const ClpFactorization&);
    00075
    00076   /*  **** below here is so can use networkish basis */
    00079
    00087   int replaceColumn ( const ClpSimplex * model,
    00088                       CoinIndexedVector * regionSparse,
    00089                       CoinIndexedVector * tableauColumn,
    00090                       int pivotRow,
    00091                       double pivotCheck ,
    00092                       bool checkBeforeModifying=false);
    00094
    00102   int updateColumnFT ( CoinIndexedVector * regionSparse,
    00103                        CoinIndexedVector * regionSparse2);
    00106   int updateColumn ( CoinIndexedVector * regionSparse,
    00107                      CoinIndexedVector * regionSparse2,
    00108                      bool noPermute=false) const;
    00114   int updateTwoColumnsFT ( CoinIndexedVector * regionSparse1,
    00115                            CoinIndexedVector * regionSparse2,
    00116                            CoinIndexedVector * regionSparse3,
    00117                            bool noPermuteRegion3=false) ;
    00119   int updateColumnForDebug ( CoinIndexedVector * regionSparse,
    00120                      CoinIndexedVector * regionSparse2,
    00121                      bool noPermute=false) const;
    00124   int updateColumnTranspose ( CoinIndexedVector * regionSparse,
    00125                               CoinIndexedVector * regionSparse2) const;
    00127 #ifdef CLP_MULTIPLE_FACTORIZATIONS
    00128
    00130
    00131   inline int numberElements (  ) const {
    00132     if (coinFactorizationA_) return coinFactorizationA_->numberElements(); else return coinFactorizationB_->numberElements() ;
    00133   }
    00135   inline int *permute (  ) const {
    00136     if (coinFactorizationA_) return coinFactorizationA_->permute(); else return coinFactorizationB_->permute() ;
    00137   }
    00139   inline int *pivotColumn (  ) const {
    00140     if (coinFactorizationA_) return coinFactorizationA_->pivotColumn(); else return coinFactorizationB_->permute() ;
    00141   }
    00143   inline int maximumPivots (  ) const {
    00144     if (coinFactorizationA_) return coinFactorizationA_->maximumPivots();  else return coinFactorizationB_->maximumPivots() ;
    00145   }
    00147   inline void maximumPivots (  int value) {
    00148     if (coinFactorizationA_) coinFactorizationA_->maximumPivots(value); else coinFactorizationB_->maximumPivots(value);
    00149   }
    00151   inline int pivots (  ) const {
    00152     if (coinFactorizationA_) return coinFactorizationA_->pivots(); else return coinFactorizationB_->pivots() ;
    00153   }
    00155   inline double areaFactor (  ) const {
    00156     if (coinFactorizationA_) return coinFactorizationA_->areaFactor(); else return 0.0 ;
    00157   }
    00159   inline void areaFactor ( double value) {
    00160     if (coinFactorizationA_) coinFactorizationA_->areaFactor(value);
    00161   }
    00163   inline double zeroTolerance (  ) const {
    00164     if (coinFactorizationA_) return coinFactorizationA_->zeroTolerance();  else return coinFactorizationB_->zeroTolerance() ;
    00165   }
    00167   inline void zeroTolerance (  double value) {
    00168     if (coinFactorizationA_) coinFactorizationA_->zeroTolerance(value); else coinFactorizationB_->zeroTolerance(value);
    00169   }
    00171   void saferTolerances (  double zeroTolerance, double pivotTolerance);
    00173   inline int sparseThreshold ( ) const
    00174   { if (coinFactorizationA_) return coinFactorizationA_->sparseThreshold(); else return 0 ;}
    00176   inline void sparseThreshold ( int value)
    00177   { if (coinFactorizationA_) coinFactorizationA_->sparseThreshold(value); }
    00179   inline int status (  ) const {
    00180     if (coinFactorizationA_) return coinFactorizationA_->status(); else return coinFactorizationB_->status() ;
    00181   }
    00183   inline void setStatus (  int value) {
    00184     if (coinFactorizationA_) coinFactorizationA_->setStatus(value); else coinFactorizationB_->setStatus(value) ;
    00185   }
    00187   inline int numberDense() const
    00188   { if (coinFactorizationA_) return coinFactorizationA_->numberDense(); else return 0 ;}
    00189 #if 1
    00191   inline CoinBigIndex numberElementsU (  ) const {
    00192     if (coinFactorizationA_) return coinFactorizationA_->numberElementsU(); else return -1 ;
    00193   }
    00195   inline CoinBigIndex numberElementsL (  ) const {
    00196     if (coinFactorizationA_) return coinFactorizationA_->numberElementsL(); else return -1 ;
    00197   }
    00199   inline CoinBigIndex numberElementsR (  ) const {
    00200     if (coinFactorizationA_) return coinFactorizationA_->numberElementsR(); else return 0 ;
    00201   }
    00202 #endif
    00203   inline bool timeToRefactorize() const
    00204   {
    00205     if (coinFactorizationA_) {
    00206       return (coinFactorizationA_->pivots()*3>coinFactorizationA_->maximumPivots()*2&&
    00207               coinFactorizationA_->numberElementsR()*3>(coinFactorizationA_->numberElementsL()+
    00208                                                         coinFactorizationA_->numberElementsU())*2+1000&&
    00209               !coinFactorizationA_->numberDense());
    00210     } else {
    00211       return coinFactorizationB_->pivots()>coinFactorizationB_->numberRows()/2.45+20;
    00212     }
    00213   }
    00215   inline int messageLevel (  ) const {
    00216     if (coinFactorizationA_) return coinFactorizationA_->messageLevel();  else return 0 ;
    00217   }
    00219   inline void messageLevel (  int value) {
    00220     if (coinFactorizationA_) coinFactorizationA_->messageLevel(value);
    00221   }
    00223   inline void clearArrays()
    00224   { if (coinFactorizationA_) coinFactorizationA_->clearArrays();}
    00226   inline int numberRows (  ) const {
    00227     if (coinFactorizationA_) return coinFactorizationA_->numberRows(); else return coinFactorizationB_->numberRows() ;
    00228   }
    00230   inline int denseThreshold() const
    00231   { if (coinFactorizationA_) return coinFactorizationA_->denseThreshold(); else return 0 ;}
    00233   inline void setDenseThreshold(int value)
    00234   { if (coinFactorizationA_) coinFactorizationA_->setDenseThreshold(value);}
    00236   inline double pivotTolerance (  ) const {
    00237     if (coinFactorizationA_) return coinFactorizationA_->pivotTolerance();  else return 1.0e-8 ;
    00238   }
    00240   inline void pivotTolerance (  double value) {
    00241     if (coinFactorizationA_) coinFactorizationA_->pivotTolerance(value);
    00242   }
    00244   inline void relaxAccuracyCheck(double value)
    00245   { if (coinFactorizationA_) coinFactorizationA_->relaxAccuracyCheck(value);}
    00251   inline int persistenceFlag() const
    00252   { if (coinFactorizationA_) return coinFactorizationA_->persistenceFlag(); else return 0 ;}
    00253   inline void setPersistenceFlag(int value)
    00254   { if (coinFactorizationA_) coinFactorizationA_->setPersistenceFlag(value);}
    00256   inline void almostDestructor()
    00257   { if (coinFactorizationA_) coinFactorizationA_->almostDestructor(); }
    00259   inline double adjustedAreaFactor() const
    00260   { if (coinFactorizationA_) return coinFactorizationA_->adjustedAreaFactor(); else return 0.0 ; }
    00261   inline void setBiasLU(int value)
    00262   { if (coinFactorizationA_) coinFactorizationA_->setBiasLU(value);}
    00264   inline void setForrestTomlin(bool value)
    00265   { if (coinFactorizationA_) coinFactorizationA_->setForrestTomlin(value);}
    00267   inline void setDefaultValues() {
    00268     if (coinFactorizationA_) {
    00269       // row activities have negative sign
    00270 #ifndef COIN_FAST_CODE
    00271       coinFactorizationA_->slackValue(-1.0);
    00272 #endif
    00273       coinFactorizationA_->zeroTolerance(1.0e-13);
    00274     }
    00275   }
    00277   inline int goDenseThreshold() const
    00278   { return goDenseThreshold_;}
    00280   inline void setGoDenseThreshold(int value)
    00281   { goDenseThreshold_ = value;}
    00283   inline int goSmallThreshold() const
    00284   { return goSmallThreshold_;}
    00286   inline void setGoSmallThreshold(int value)
    00287   { goSmallThreshold_ = value;}
    00289   void goDenseOrSmall(int numberRows) ;
    00291   inline int isDenseOrSmall() const
    00292   { return coinFactorizationB_ ? 1 : 0;}
    00293 #else
    00294   inline bool timeToRefactorize() const
    00295   {
    00296     return (pivots()*3>maximumPivots()*2&&
    00297             numberElementsR()*3>(numberElementsL()+numberElementsU())*2+1000&&
    00298             !numberDense());
    00299   }
    00301   inline void setDefaultValues() {
    00302     // row activities have negative sign
    00303 #ifndef COIN_FAST_CODE
    00304     slackValue(-1.0);
    00305 #endif
    00306     zeroTolerance(1.0e-13);
    00307   }
    00309   inline void goDense() {}
    00310 #endif
    00311
    00312
    00316   void goSparse();
    00318   void cleanUp();
    00320   bool needToReorder() const;
    00321 #ifndef SLIM_CLP
    00323   inline bool networkBasis() const
    00324   { return (networkBasis_!=NULL);}
    00325 #else
    00327   inline bool networkBasis() const
    00328   { return false;}
    00329 #endif
    00331   void getWeights(int * weights) const;
    00332
    00333
    00335 private:
    00336
    00339
    00340 #ifndef SLIM_CLP
    00341   ClpNetworkBasis * networkBasis_;
    00342 #endif
    00343 #ifdef CLP_MULTIPLE_FACTORIZATIONS
    00345   CoinFactorization * coinFactorizationA_;
    00347   CoinSmallFactorization * coinFactorizationB_;
    00349   int goSmallThreshold_;
    00351   int goDenseThreshold_;
    00352 #endif
    00353
    00354 };
    00355
    00356 #endif