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

- File List
- File Members

# /home/coin/SVN-release/Cgl-0.53.1/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);
    00097   int updateColumn ( CoinIndexedVector * regionSparse,
    00098                      CoinIndexedVector * regionSparse2,
    00099                      bool noPermute=false) const;
    00105   int updateTwoColumnsFT ( CoinIndexedVector * regionSparse1,
    00106                            CoinIndexedVector * regionSparse2,
    00107                            CoinIndexedVector * regionSparse3,
    00108                            bool noPermuteRegion3=false) ;
    00110   int updateColumnForDebug ( CoinIndexedVector * regionSparse,
    00111                      CoinIndexedVector * regionSparse2,
    00112                      bool noPermute=false) const;
    00115   int updateColumnTranspose ( CoinIndexedVector * regionSparse,
    00116                               CoinIndexedVector * regionSparse2) const;
    00118 #ifdef CLP_MULTIPLE_FACTORIZATIONS
    00119
    00121
    00122   inline int numberElements (  ) const {
    00123     if (coinFactorizationA_) return coinFactorizationA_->numberElements(); else return coinFactorizationB_->numberElements() ;
    00124   }
    00126   inline int *permute (  ) const {
    00127     if (coinFactorizationA_) return coinFactorizationA_->permute(); else return coinFactorizationB_->permute() ;
    00128   }
    00130   inline int *pivotColumn (  ) const {
    00131     if (coinFactorizationA_) return coinFactorizationA_->pivotColumn(); else return coinFactorizationB_->permute() ;
    00132   }
    00134   inline int maximumPivots (  ) const {
    00135     if (coinFactorizationA_) return coinFactorizationA_->maximumPivots();  else return coinFactorizationB_->maximumPivots() ;
    00136   }
    00138   inline void maximumPivots (  int value) {
    00139     if (coinFactorizationA_) coinFactorizationA_->maximumPivots(value); else coinFactorizationB_->maximumPivots(value);
    00140   }
    00142   inline int pivots (  ) const {
    00143     if (coinFactorizationA_) return coinFactorizationA_->pivots(); else return coinFactorizationB_->pivots() ;
    00144   }
    00146   inline double areaFactor (  ) const {
    00147     if (coinFactorizationA_) return coinFactorizationA_->areaFactor(); else return 0.0 ;
    00148   }
    00150   inline void areaFactor ( double value) {
    00151     if (coinFactorizationA_) coinFactorizationA_->areaFactor(value);
    00152   }
    00154   inline double zeroTolerance (  ) const {
    00155     if (coinFactorizationA_) return coinFactorizationA_->zeroTolerance();  else return coinFactorizationB_->zeroTolerance() ;
    00156   }
    00158   inline void zeroTolerance (  double value) {
    00159     if (coinFactorizationA_) coinFactorizationA_->zeroTolerance(value); else coinFactorizationB_->zeroTolerance(value);
    00160   }
    00162   inline int sparseThreshold ( ) const
    00163   { if (coinFactorizationA_) return coinFactorizationA_->sparseThreshold(); else return 0 ;}
    00165   inline void sparseThreshold ( int value)
    00166   { if (coinFactorizationA_) coinFactorizationA_->sparseThreshold(value); }
    00168   inline int status (  ) const {
    00169     if (coinFactorizationA_) return coinFactorizationA_->status(); else return coinFactorizationB_->status() ;
    00170   }
    00172   inline void setStatus (  int value) {
    00173     if (coinFactorizationA_) coinFactorizationA_->setStatus(value); else coinFactorizationB_->setStatus(value) ;
    00174   }
    00176   inline int numberDense() const
    00177   { if (coinFactorizationA_) return coinFactorizationA_->numberDense(); else return 0 ;}
    00178 #if 0
    00180   inline CoinBigIndex numberElementsU (  ) const {
    00181     if (coinFactorizationA_) return coinFactorizationA_->numberElementsU(); else return 0 ;
    00182   }
    00184   inline CoinBigIndex numberElementsL (  ) const {
    00185     if (coinFactorizationA_) return coinFactorizationA_->numberElementsL(); else return 0 ;
    00186   }
    00188   inline CoinBigIndex numberElementsR (  ) const {
    00189     if (coinFactorizationA_) return coinFactorizationA_->numberElementsR(); else return 0 ;
    00190   }
    00191 #endif
    00192   inline bool timeToRefactorize() const
    00193   {
    00194     if (coinFactorizationA_) {
    00195       return (coinFactorizationA_->pivots()*3>coinFactorizationA_->maximumPivots()*2&&
    00196               coinFactorizationA_->numberElementsR()*3>(coinFactorizationA_->numberElementsL()+
    00197                                                         coinFactorizationA_->numberElementsU())*2+1000&&
    00198               !coinFactorizationA_->numberDense());
    00199     } else {
    00200       return coinFactorizationB_->pivots()>coinFactorizationB_->numberRows()/2.45+20;
    00201     }
    00202   }
    00204   inline int messageLevel (  ) const {
    00205     if (coinFactorizationA_) return coinFactorizationA_->messageLevel();  else return 0 ;
    00206   }
    00208   inline void messageLevel (  int value) {
    00209     if (coinFactorizationA_) coinFactorizationA_->messageLevel(value);
    00210   }
    00212   inline void clearArrays()
    00213   { if (coinFactorizationA_) coinFactorizationA_->clearArrays();}
    00215   inline int numberRows (  ) const {
    00216     if (coinFactorizationA_) return coinFactorizationA_->numberRows(); else return coinFactorizationB_->numberRows() ;
    00217   }
    00219   inline int denseThreshold() const
    00220   { if (coinFactorizationA_) return coinFactorizationA_->denseThreshold(); else return 0 ;}
    00222   inline void setDenseThreshold(int value)
    00223   { if (coinFactorizationA_) coinFactorizationA_->setDenseThreshold(value);}
    00225   inline double pivotTolerance (  ) const {
    00226     if (coinFactorizationA_) return coinFactorizationA_->pivotTolerance();  else return 1.0e-8 ;
    00227   }
    00229   inline void pivotTolerance (  double value) {
    00230     if (coinFactorizationA_) coinFactorizationA_->pivotTolerance(value);
    00231   }
    00233   inline void relaxAccuracyCheck(double value)
    00234   { if (coinFactorizationA_) coinFactorizationA_->relaxAccuracyCheck(value);}
    00240   inline int persistenceFlag() const
    00241   { if (coinFactorizationA_) return coinFactorizationA_->persistenceFlag(); else return 0 ;}
    00242   inline void setPersistenceFlag(int value)
    00243   { if (coinFactorizationA_) coinFactorizationA_->setPersistenceFlag(value);}
    00245   inline void almostDestructor()
    00246   { if (coinFactorizationA_) coinFactorizationA_->almostDestructor(); }
    00248   inline double adjustedAreaFactor() const
    00249   { if (coinFactorizationA_) return coinFactorizationA_->adjustedAreaFactor(); else return 0.0 ; }
    00250   inline void setBiasLU(int value)
    00251   { if (coinFactorizationA_) coinFactorizationA_->setBiasLU(value);}
    00253   inline void setForrestTomlin(bool value)
    00254   { if (coinFactorizationA_) coinFactorizationA_->setForrestTomlin(value);}
    00256   inline void setDefaultValues() {
    00257     if (coinFactorizationA_) {
    00258       // row activities have negative sign
    00259 #ifndef COIN_FAST_CODE
    00260       coinFactorizationA_->slackValue(-1.0);
    00261 #endif
    00262       coinFactorizationA_->zeroTolerance(1.0e-13);
    00263     }
    00264   }
    00266   inline int goDenseThreshold() const
    00267   { return goDenseThreshold_;}
    00269   inline void setGoDenseThreshold(int value)
    00270   { goDenseThreshold_ = value;}
    00272   void goDense() ;
    00274   inline int isDense() const
    00275   { return coinFactorizationB_ ? 1 : 0;}
    00276 #else
    00277   inline bool timeToRefactorize() const
    00278   {
    00279     return (pivots()*3>maximumPivots()*2&&
    00280             numberElementsR()*3>(numberElementsL()+numberElementsU())*2+1000&&
    00281             !numberDense());
    00282   }
    00284   inline void setDefaultValues() {
    00285     // row activities have negative sign
    00286 #ifndef COIN_FAST_CODE
    00287     slackValue(-1.0);
    00288 #endif
    00289     zeroTolerance(1.0e-13);
    00290   }
    00292   inline void goDense() {}
    00293 #endif
    00294
    00295
    00299   void goSparse();
    00301   void cleanUp();
    00303   bool needToReorder() const;
    00304 #ifndef SLIM_CLP
    00306   inline bool networkBasis() const
    00307   { return (networkBasis_!=NULL);}
    00308 #else
    00310   inline bool networkBasis() const
    00311   { return false;}
    00312 #endif
    00314   void getWeights(int * weights) const;
    00315
    00316
    00318 private:
    00319
    00322
    00323 #ifndef SLIM_CLP
    00324   ClpNetworkBasis * networkBasis_;
    00325 #endif
    00326 #ifdef CLP_MULTIPLE_FACTORIZATIONS
    00328   CoinFactorization * coinFactorizationA_;
    00330   CoinDenseFactorization * coinFactorizationB_;
    00332   int goDenseThreshold_;
    00333 #endif
    00334
    00335 };
    00336
    00337 #endif