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

- File List
- File Members

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

Go to the documentation of this file.

    00001 /* $Id: ClpFactorization.hpp 1458 2009-11-05 12:34:07Z forrest $ */
    00002 // Copyright (C) 2002, International Business Machines
    00003 // Corporation and others.  All Rights Reserved.
    00004 #ifndef ClpFactorization_H
    00005 #define ClpFactorization_H
    00006
    00007
    00008 #include "CoinPragma.hpp"
    00009
    00010 #include "CoinFactorization.hpp"
    00011 class ClpMatrixBase;
    00012 class ClpSimplex;
    00013 class ClpNetworkBasis;
    00014 class CoinOtherFactorization;
    00015 #ifndef CLP_MULTIPLE_FACTORIZATIONS
    00016 #define CLP_MULTIPLE_FACTORIZATIONS 4
    00017 #endif
    00018 #ifdef CLP_MULTIPLE_FACTORIZATIONS
    00019 #include "CoinDenseFactorization.hpp"
    00020 #endif
    00021 #ifndef COIN_FAST_CODE
    00022 #define COIN_FAST_CODE
    00023 #endif
    00024
    00029 class ClpFactorization
    00030 #ifndef CLP_MULTIPLE_FACTORIZATIONS
    00031   : public CoinFactorization
    00032 #endif
    00033 {
    00034
    00035   //friend class CoinFactorization;
    00036
    00037 public:
    00049   int factorize (ClpSimplex * model,int solveType, bool valuesPass);
    00051
    00052
    00056    ClpFactorization();
    00058    ~ClpFactorization();
    00060
    00064    ClpFactorization(const CoinFactorization&);
    00066   ClpFactorization(const ClpFactorization&,int denseIfSmaller=0);
    00067 #ifdef CLP_MULTIPLE_FACTORIZATIONS
    00068
    00069    ClpFactorization(const CoinOtherFactorization&);
    00070 #endif
    00071    ClpFactorization& operator=(const ClpFactorization&);
    00073
    00074   /*  **** below here is so can use networkish basis */
    00077
    00085   int replaceColumn ( const ClpSimplex * model,
    00086                       CoinIndexedVector * regionSparse,
    00087                       CoinIndexedVector * tableauColumn,
    00088                       int pivotRow,
    00089                       double pivotCheck ,
    00090                       bool checkBeforeModifying=false,
    00091                       double acceptablePivot=1.0e-8);
    00093
    00101   int updateColumnFT ( CoinIndexedVector * regionSparse,
    00102                        CoinIndexedVector * regionSparse2);
    00105   int updateColumn ( CoinIndexedVector * regionSparse,
    00106                      CoinIndexedVector * regionSparse2,
    00107                      bool noPermute=false) const;
    00113   int updateTwoColumnsFT ( CoinIndexedVector * regionSparse1,
    00114                            CoinIndexedVector * regionSparse2,
    00115                            CoinIndexedVector * regionSparse3,
    00116                            bool noPermuteRegion3=false) ;
    00118   int updateColumnForDebug ( CoinIndexedVector * regionSparse,
    00119                      CoinIndexedVector * regionSparse2,
    00120                      bool noPermute=false) const;
    00123   int updateColumnTranspose ( CoinIndexedVector * regionSparse,
    00124                               CoinIndexedVector * regionSparse2) const;
    00126 #ifdef CLP_MULTIPLE_FACTORIZATIONS
    00127
    00129
    00130   inline int numberElements (  ) const {
    00131     if (coinFactorizationA_) return coinFactorizationA_->numberElements(); else return coinFactorizationB_->numberElements() ;
    00132   }
    00134   inline int *permute (  ) const {
    00135     if (coinFactorizationA_) return coinFactorizationA_->permute(); else return coinFactorizationB_->permute() ;
    00136   }
    00138   inline int *pivotColumn (  ) const {
    00139     if (coinFactorizationA_) return coinFactorizationA_->pivotColumn(); else return coinFactorizationB_->permute() ;
    00140   }
    00142   inline int maximumPivots (  ) const {
    00143     if (coinFactorizationA_) return coinFactorizationA_->maximumPivots();  else return coinFactorizationB_->maximumPivots() ;
    00144   }
    00146   inline void maximumPivots (  int value) {
    00147     if (coinFactorizationA_) coinFactorizationA_->maximumPivots(value); else coinFactorizationB_->maximumPivots(value);
    00148   }
    00150   inline int pivots (  ) const {
    00151     if (coinFactorizationA_) return coinFactorizationA_->pivots(); else return coinFactorizationB_->pivots() ;
    00152   }
    00154   inline double areaFactor (  ) const {
    00155     if (coinFactorizationA_) return coinFactorizationA_->areaFactor(); else return 0.0 ;
    00156   }
    00158   inline void areaFactor ( double value) {
    00159     if (coinFactorizationA_) coinFactorizationA_->areaFactor(value);
    00160   }
    00162   inline double zeroTolerance (  ) const {
    00163     if (coinFactorizationA_) return coinFactorizationA_->zeroTolerance();  else return coinFactorizationB_->zeroTolerance() ;
    00164   }
    00166   inline void zeroTolerance (  double value) {
    00167     if (coinFactorizationA_) coinFactorizationA_->zeroTolerance(value); else coinFactorizationB_->zeroTolerance(value);
    00168   }
    00170   void saferTolerances (  double zeroTolerance, double pivotTolerance);
    00172   inline int sparseThreshold ( ) const
    00173   { if (coinFactorizationA_) return coinFactorizationA_->sparseThreshold(); else return 0 ;}
    00175   inline void sparseThreshold ( int value)
    00176   { if (coinFactorizationA_) coinFactorizationA_->sparseThreshold(value); }
    00178   inline int status (  ) const {
    00179     if (coinFactorizationA_) return coinFactorizationA_->status(); else return coinFactorizationB_->status() ;
    00180   }
    00182   inline void setStatus (  int value) {
    00183     if (coinFactorizationA_) coinFactorizationA_->setStatus(value); else coinFactorizationB_->setStatus(value) ;
    00184   }
    00186   inline int numberDense() const
    00187   { if (coinFactorizationA_) return coinFactorizationA_->numberDense(); else return 0 ;}
    00188 #if 1
    00190   inline CoinBigIndex numberElementsU (  ) const {
    00191     if (coinFactorizationA_) return coinFactorizationA_->numberElementsU(); else return -1 ;
    00192   }
    00194   inline CoinBigIndex numberElementsL (  ) const {
    00195     if (coinFactorizationA_) return coinFactorizationA_->numberElementsL(); else return -1 ;
    00196   }
    00198   inline CoinBigIndex numberElementsR (  ) const {
    00199     if (coinFactorizationA_) return coinFactorizationA_->numberElementsR(); else return 0 ;
    00200   }
    00201 #endif
    00202   inline bool timeToRefactorize() const
    00203   {
    00204     if (coinFactorizationA_) {
    00205       return (coinFactorizationA_->pivots()*3>coinFactorizationA_->maximumPivots()*2&&
    00206               coinFactorizationA_->numberElementsR()*3>(coinFactorizationA_->numberElementsL()+
    00207                                                         coinFactorizationA_->numberElementsU())*2+1000&&
    00208               !coinFactorizationA_->numberDense());
    00209     } else {
    00210       return coinFactorizationB_->pivots()>coinFactorizationB_->numberRows()/2.45+20;
    00211     }
    00212   }
    00214   inline int messageLevel (  ) const {
    00215     if (coinFactorizationA_) return coinFactorizationA_->messageLevel();  else return 1 ;
    00216   }
    00218   inline void messageLevel (  int value) {
    00219     if (coinFactorizationA_) coinFactorizationA_->messageLevel(value);
    00220   }
    00222   inline void clearArrays()
    00223   { if (coinFactorizationA_)
    00224       coinFactorizationA_->clearArrays();
    00225     else if (coinFactorizationB_)
    00226       coinFactorizationB_->clearArrays();
    00227   }
    00229   inline int numberRows (  ) const {
    00230     if (coinFactorizationA_) return coinFactorizationA_->numberRows(); else return coinFactorizationB_->numberRows() ;
    00231   }
    00233   inline int denseThreshold() const
    00234   { if (coinFactorizationA_) return coinFactorizationA_->denseThreshold(); else return 0 ;}
    00236   inline void setDenseThreshold(int value)
    00237   { if (coinFactorizationA_) coinFactorizationA_->setDenseThreshold(value);}
    00239   inline double pivotTolerance (  ) const {
    00240     if (coinFactorizationA_) return coinFactorizationA_->pivotTolerance();  else if (coinFactorizationB_) return coinFactorizationB_->pivotTolerance();return 1.0e-8 ;
    00241   }
    00243   inline void pivotTolerance (  double value) {
    00244     if (coinFactorizationA_) coinFactorizationA_->pivotTolerance(value);
    00245     else if (coinFactorizationB_) coinFactorizationB_->pivotTolerance(value);
    00246   }
    00248   inline void relaxAccuracyCheck(double value)
    00249   { if (coinFactorizationA_) coinFactorizationA_->relaxAccuracyCheck(value);}
    00255   inline int persistenceFlag() const
    00256   { if (coinFactorizationA_) return coinFactorizationA_->persistenceFlag(); else return 0 ;}
    00257   inline void setPersistenceFlag(int value)
    00258   { if (coinFactorizationA_) coinFactorizationA_->setPersistenceFlag(value);}
    00260   inline void almostDestructor()
    00261   { if (coinFactorizationA_)
    00262       coinFactorizationA_->almostDestructor();
    00263     else if (coinFactorizationB_)
    00264       coinFactorizationB_->clearArrays();
    00265   }
    00267   inline double adjustedAreaFactor() const
    00268   { if (coinFactorizationA_) return coinFactorizationA_->adjustedAreaFactor(); else return 0.0 ; }
    00269   inline void setBiasLU(int value)
    00270   { if (coinFactorizationA_) coinFactorizationA_->setBiasLU(value);}
    00272   inline void setForrestTomlin(bool value)
    00273   { if (coinFactorizationA_) coinFactorizationA_->setForrestTomlin(value);}
    00275   inline void setDefaultValues() {
    00276     if (coinFactorizationA_) {
    00277       // row activities have negative sign
    00278 #ifndef COIN_FAST_CODE
    00279       coinFactorizationA_->slackValue(-1.0);
    00280 #endif
    00281       coinFactorizationA_->zeroTolerance(1.0e-13);
    00282     }
    00283   }
    00285   void forceOtherFactorization(int which);
    00287   inline int goOslThreshold() const
    00288   { return goOslThreshold_;}
    00290   inline void setGoOslThreshold(int value)
    00291   { goOslThreshold_ = value;}
    00293   inline int goDenseThreshold() const
    00294   { return goDenseThreshold_;}
    00296   inline void setGoDenseThreshold(int value)
    00297   { goDenseThreshold_ = value;}
    00299   inline int goSmallThreshold() const
    00300   { return goSmallThreshold_;}
    00302   inline void setGoSmallThreshold(int value)
    00303   { goSmallThreshold_ = value;}
    00305   void goDenseOrSmall(int numberRows) ;
    00307   void setFactorization(ClpFactorization & factorization);
    00309   inline int isDenseOrSmall() const
    00310   { return coinFactorizationB_ ? 1 : 0;}
    00311 #else
    00312   inline bool timeToRefactorize() const
    00313   {
    00314     return (pivots()*3>maximumPivots()*2&&
    00315             numberElementsR()*3>(numberElementsL()+numberElementsU())*2+1000&&
    00316             !numberDense());
    00317   }
    00319   inline void setDefaultValues() {
    00320     // row activities have negative sign
    00321 #ifndef COIN_FAST_CODE
    00322     slackValue(-1.0);
    00323 #endif
    00324     zeroTolerance(1.0e-13);
    00325   }
    00327   inline void goDense() {}
    00328 #endif
    00329
    00330
    00334   void goSparse();
    00336   void cleanUp();
    00338   bool needToReorder() const;
    00339 #ifndef SLIM_CLP
    00341   inline bool networkBasis() const
    00342   { return (networkBasis_!=NULL);}
    00343 #else
    00345   inline bool networkBasis() const
    00346   { return false;}
    00347 #endif
    00349   void getWeights(int * weights) const;
    00350
    00351
    00353 private:
    00354
    00357
    00358 #ifndef SLIM_CLP
    00359   ClpNetworkBasis * networkBasis_;
    00360 #endif
    00361 #ifdef CLP_MULTIPLE_FACTORIZATIONS
    00363   CoinFactorization * coinFactorizationA_;
    00365   CoinOtherFactorization * coinFactorizationB_;
    00367   int forceB_;
    00369   int goOslThreshold_;
    00371   int goSmallThreshold_;
    00373   int goDenseThreshold_;
    00374 #endif
    00375
    00376 };
    00377
    00378 #endif