# ClpFactorization.hpp

Go to the documentation of this file.

    00001 /* $Id: ClpFactorization.hpp 2078 2015-01-05 12:39:49Z forrest $ */
    00002 // Copyright (C) 2002, 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 ClpFactorization_H
    00007 #define ClpFactorization_H
    00008
    00009
    00010 #include "CoinPragma.hpp"
    00011
    00012 #include "CoinFactorization.hpp"
    00013 class ClpMatrixBase;
    00014 class ClpSimplex;
    00015 class ClpNetworkBasis;
    00016 class CoinOtherFactorization;
    00017 #ifndef CLP_MULTIPLE_FACTORIZATIONS
    00018 #define CLP_MULTIPLE_FACTORIZATIONS 4
    00019 #endif
    00020 #ifdef CLP_MULTIPLE_FACTORIZATIONS
    00021 #include "CoinDenseFactorization.hpp"
    00022 #include "ClpSimplex.hpp"
    00023 #endif
    00024 #ifndef COIN_FAST_CODE
    00025 #define COIN_FAST_CODE
    00026 #endif
    00027 #ifndef CLP_FACTORIZATION_NEW_TIMING
    00028 #define CLP_FACTORIZATION_NEW_TIMING 1
    00029 #endif
    00030
    00035 class ClpFactorization
    00036 #ifndef CLP_MULTIPLE_FACTORIZATIONS
    00037      : public CoinFactorization
    00038 #endif
    00039 {
    00040
    00041      //friend class CoinFactorization;
    00042
    00043 public:
    00055      int factorize (ClpSimplex * model, int solveType, bool valuesPass);
    00057
    00058
    00062      ClpFactorization();
    00064      ~ClpFactorization();
    00066
    00070      ClpFactorization(const CoinFactorization&);
    00072      ClpFactorization(const ClpFactorization&, int denseIfSmaller = 0);
    00073 #ifdef CLP_MULTIPLE_FACTORIZATIONS
    00074
    00075      ClpFactorization(const CoinOtherFactorization&);
    00076 #endif
    00077      ClpFactorization& operator=(const ClpFactorization&);
    00079
    00080      /*  **** below here is so can use networkish basis */
    00083
    00091      int replaceColumn ( const ClpSimplex * model,
    00092                          CoinIndexedVector * regionSparse,
    00093                          CoinIndexedVector * tableauColumn,
    00094                          int pivotRow,
    00095                          double pivotCheck ,
    00096                          bool checkBeforeModifying = false,
    00097                          double acceptablePivot = 1.0e-8);
    00099
    00107      int updateColumnFT ( CoinIndexedVector * regionSparse,
    00108                           CoinIndexedVector * regionSparse2);
    00111      int updateColumn ( CoinIndexedVector * regionSparse,
    00112                         CoinIndexedVector * regionSparse2,
    00113                         bool noPermute = false) const;
    00119      int updateTwoColumnsFT ( CoinIndexedVector * regionSparse1,
    00120                               CoinIndexedVector * regionSparse2,
    00121                               CoinIndexedVector * regionSparse3,
    00122                               bool noPermuteRegion3 = false) ;
    00124      int updateColumnForDebug ( CoinIndexedVector * regionSparse,
    00125                                 CoinIndexedVector * regionSparse2,
    00126                                 bool noPermute = false) const;
    00129      int updateColumnTranspose ( CoinIndexedVector * regionSparse,
    00130                                  CoinIndexedVector * regionSparse2) const;
    00132 #ifdef CLP_MULTIPLE_FACTORIZATIONS
    00133
    00135
    00136      inline int numberElements (  ) const {
    00137           if (coinFactorizationA_) return coinFactorizationA_->numberElements();
    00138           else return coinFactorizationB_->numberElements() ;
    00139      }
    00141      inline int *permute (  ) const {
    00142           if (coinFactorizationA_) return coinFactorizationA_->permute();
    00143           else return coinFactorizationB_->permute() ;
    00144      }
    00146      inline int *pivotColumn (  ) const {
    00147           if (coinFactorizationA_) return coinFactorizationA_->pivotColumn();
    00148           else return coinFactorizationB_->permute() ;
    00149      }
    00151      inline int maximumPivots (  ) const {
    00152           if (coinFactorizationA_) return coinFactorizationA_->maximumPivots();
    00153           else return coinFactorizationB_->maximumPivots() ;
    00154      }
    00156      inline void maximumPivots (  int value) {
    00157           if (coinFactorizationA_) coinFactorizationA_->maximumPivots(value);
    00158           else coinFactorizationB_->maximumPivots(value);
    00159      }
    00161      inline int pivots (  ) const {
    00162           if (coinFactorizationA_) return coinFactorizationA_->pivots();
    00163           else return coinFactorizationB_->pivots() ;
    00164      }
    00166      inline double areaFactor (  ) const {
    00167           if (coinFactorizationA_) return coinFactorizationA_->areaFactor();
    00168           else return 0.0 ;
    00169      }
    00171      inline void areaFactor ( double value) {
    00172           if (coinFactorizationA_) coinFactorizationA_->areaFactor(value);
    00173      }
    00175      inline double zeroTolerance (  ) const {
    00176           if (coinFactorizationA_) return coinFactorizationA_->zeroTolerance();
    00177           else return coinFactorizationB_->zeroTolerance() ;
    00178      }
    00180      inline void zeroTolerance (  double value) {
    00181           if (coinFactorizationA_) coinFactorizationA_->zeroTolerance(value);
    00182           else coinFactorizationB_->zeroTolerance(value);
    00183      }
    00185      void saferTolerances (  double zeroTolerance, double pivotTolerance);
    00187      inline int sparseThreshold ( ) const {
    00188           if (coinFactorizationA_) return coinFactorizationA_->sparseThreshold();
    00189           else return 0 ;
    00190      }
    00192      inline void sparseThreshold ( int value) {
    00193           if (coinFactorizationA_) coinFactorizationA_->sparseThreshold(value);
    00194      }
    00196      inline int status (  ) const {
    00197           if (coinFactorizationA_) return coinFactorizationA_->status();
    00198           else return coinFactorizationB_->status() ;
    00199      }
    00201      inline void setStatus (  int value) {
    00202           if (coinFactorizationA_) coinFactorizationA_->setStatus(value);
    00203           else coinFactorizationB_->setStatus(value) ;
    00204      }
    00206      inline int numberDense() const {
    00207           if (coinFactorizationA_) return coinFactorizationA_->numberDense();
    00208           else return 0 ;
    00209      }
    00210 #if 1
    00212      inline CoinBigIndex numberElementsU (  ) const {
    00213           if (coinFactorizationA_) return coinFactorizationA_->numberElementsU();
    00214           else return -1 ;
    00215      }
    00217      inline CoinBigIndex numberElementsL (  ) const {
    00218           if (coinFactorizationA_) return coinFactorizationA_->numberElementsL();
    00219           else return -1 ;
    00220      }
    00222      inline CoinBigIndex numberElementsR (  ) const {
    00223           if (coinFactorizationA_) return coinFactorizationA_->numberElementsR();
    00224           else return 0 ;
    00225      }
    00226 #endif
    00227      bool timeToRefactorize() const;
    00228 #if CLP_FACTORIZATION_NEW_TIMING>1
    00229      void statsRefactor(char when) const;
    00230 #endif
    00232      inline int messageLevel (  ) const {
    00233           if (coinFactorizationA_) return coinFactorizationA_->messageLevel();
    00234           else return 1 ;
    00235      }
    00237      inline void messageLevel (  int value) {
    00238           if (coinFactorizationA_) coinFactorizationA_->messageLevel(value);
    00239      }
    00241      inline void clearArrays() {
    00242           if (coinFactorizationA_)
    00243                coinFactorizationA_->clearArrays();
    00244           else if (coinFactorizationB_)
    00245                coinFactorizationB_->clearArrays();
    00246      }
    00248      inline int numberRows (  ) const {
    00249           if (coinFactorizationA_) return coinFactorizationA_->numberRows();
    00250           else return coinFactorizationB_->numberRows() ;
    00251      }
    00253      inline int denseThreshold() const {
    00254           if (coinFactorizationA_) return coinFactorizationA_->denseThreshold();
    00255           else return 0 ;
    00256      }
    00258      inline void setDenseThreshold(int value) {
    00259           if (coinFactorizationA_) coinFactorizationA_->setDenseThreshold(value);
    00260      }
    00262      inline double pivotTolerance (  ) const {
    00263           if (coinFactorizationA_) return coinFactorizationA_->pivotTolerance();
    00264           else if (coinFactorizationB_) return coinFactorizationB_->pivotTolerance();
    00265           return 1.0e-8 ;
    00266      }
    00268      inline void pivotTolerance (  double value) {
    00269           if (coinFactorizationA_) coinFactorizationA_->pivotTolerance(value);
    00270           else if (coinFactorizationB_) coinFactorizationB_->pivotTolerance(value);
    00271      }
    00273      inline void relaxAccuracyCheck(double value) {
    00274           if (coinFactorizationA_) coinFactorizationA_->relaxAccuracyCheck(value);
    00275      }
    00281      inline int persistenceFlag() const {
    00282           if (coinFactorizationA_) return coinFactorizationA_->persistenceFlag();
    00283           else return 0 ;
    00284      }
    00285      inline void setPersistenceFlag(int value) {
    00286           if (coinFactorizationA_) coinFactorizationA_->setPersistenceFlag(value);
    00287      }
    00289      inline void almostDestructor() {
    00290           if (coinFactorizationA_)
    00291                coinFactorizationA_->almostDestructor();
    00292           else if (coinFactorizationB_)
    00293                coinFactorizationB_->clearArrays();
    00294      }
    00296      inline double adjustedAreaFactor() const {
    00297           if (coinFactorizationA_) return coinFactorizationA_->adjustedAreaFactor();
    00298           else return 0.0 ;
    00299      }
    00300      inline void setBiasLU(int value) {
    00301           if (coinFactorizationA_) coinFactorizationA_->setBiasLU(value);
    00302      }
    00304      inline void setForrestTomlin(bool value) {
    00305           if (coinFactorizationA_) coinFactorizationA_->setForrestTomlin(value);
    00306      }
    00308      inline void setDefaultValues() {
    00309           if (coinFactorizationA_) {
    00310                // row activities have negative sign
    00311 #ifndef COIN_FAST_CODE
    00312                coinFactorizationA_->slackValue(-1.0);
    00313 #endif
    00314                coinFactorizationA_->zeroTolerance(1.0e-13);
    00315           }
    00316      }
    00318      void forceOtherFactorization(int which);
    00320      inline int goOslThreshold() const {
    00321           return goOslThreshold_;
    00322      }
    00324      inline void setGoOslThreshold(int value) {
    00325           goOslThreshold_ = value;
    00326      }
    00328      inline int goDenseThreshold() const {
    00329           return goDenseThreshold_;
    00330      }
    00332      inline void setGoDenseThreshold(int value) {
    00333           goDenseThreshold_ = value;
    00334      }
    00336      inline int goSmallThreshold() const {
    00337           return goSmallThreshold_;
    00338      }
    00340      inline void setGoSmallThreshold(int value) {
    00341           goSmallThreshold_ = value;
    00342      }
    00344      void goDenseOrSmall(int numberRows) ;
    00346      void setFactorization(ClpFactorization & factorization);
    00348      inline int isDenseOrSmall() const {
    00349           return coinFactorizationB_ ? 1 : 0;
    00350      }
    00351 #else
    00352      inline bool timeToRefactorize() const {
    00353           return (pivots() * 3 > maximumPivots() * 2 &&
    00354                   numberElementsR() * 3 > (numberElementsL() + numberElementsU()) * 2 + 1000 &&
    00355                   !numberDense());
    00356      }
    00358      inline void setDefaultValues() {
    00359           // row activities have negative sign
    00360 #ifndef COIN_FAST_CODE
    00361           slackValue(-1.0);
    00362 #endif
    00363           zeroTolerance(1.0e-13);
    00364      }
    00366      inline void goDense() {}
    00367 #endif
    00368
    00369
    00373      void goSparse();
    00375      void cleanUp();
    00377      bool needToReorder() const;
    00378 #ifndef SLIM_CLP
    00380      inline bool networkBasis() const {
    00381           return (networkBasis_ != NULL);
    00382      }
    00383 #else
    00385      inline bool networkBasis() const {
    00386           return false;
    00387      }
    00388 #endif
    00390      void getWeights(int * weights) const;
    00391
    00392
    00394 private:
    00395
    00398
    00399 #ifndef SLIM_CLP
    00400      ClpNetworkBasis * networkBasis_;
    00401 #endif
    00402 #ifdef CLP_MULTIPLE_FACTORIZATIONS
    00404      CoinFactorization * coinFactorizationA_;
    00406      CoinOtherFactorization * coinFactorizationB_;
    00407 #ifdef CLP_REUSE_ETAS
    00409      ClpSimplex * model_;
    00410 #endif
    00412      int forceB_;
    00414      int goOslThreshold_;
    00416      int goSmallThreshold_;
    00418      int goDenseThreshold_;
    00419 #endif
    00420 #ifdef CLP_FACTORIZATION_NEW_TIMING
    00422      mutable double shortestAverage_;
    00423      mutable double totalInR_;
    00424      mutable double totalInIncreasingU_;
    00425      mutable int endLengthU_;
    00426      mutable int lastNumberPivots_;
    00427      mutable int effectiveStartNumberU_;
    00428 #endif
    00429
    00430 };
    00431
    00432 #endif

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines