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

- File List
- File Members

# /home/coin/SVN-release/Alps-1.2.1/Clp/src/ClpFactorization.hpp

Go to the documentation of this file.

    00001 /* $Id: ClpFactorization.hpp 1616 2010-11-01 13:05:15Z 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 #include "ClpSimplex.hpp"
    00021 #endif
    00022 #ifndef COIN_FAST_CODE
    00023 #define COIN_FAST_CODE
    00024 #endif
    00025
    00030 class ClpFactorization
    00031 #ifndef CLP_MULTIPLE_FACTORIZATIONS
    00032      : public CoinFactorization
    00033 #endif
    00034 {
    00035
    00036      //friend class CoinFactorization;
    00037
    00038 public:
    00050      int factorize (ClpSimplex * model, int solveType, bool valuesPass);
    00052
    00053
    00057      ClpFactorization();
    00059      ~ClpFactorization();
    00061
    00065      ClpFactorization(const CoinFactorization&);
    00067      ClpFactorization(const ClpFactorization&, int denseIfSmaller = 0);
    00068 #ifdef CLP_MULTIPLE_FACTORIZATIONS
    00069
    00070      ClpFactorization(const CoinOtherFactorization&);
    00071 #endif
    00072      ClpFactorization& operator=(const ClpFactorization&);
    00074
    00075      /*  **** below here is so can use networkish basis */
    00078
    00086      int replaceColumn ( const ClpSimplex * model,
    00087                          CoinIndexedVector * regionSparse,
    00088                          CoinIndexedVector * tableauColumn,
    00089                          int pivotRow,
    00090                          double pivotCheck ,
    00091                          bool checkBeforeModifying = false,
    00092                          double acceptablePivot = 1.0e-8);
    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();
    00133           else return coinFactorizationB_->numberElements() ;
    00134      }
    00136      inline int *permute (  ) const {
    00137           if (coinFactorizationA_) return coinFactorizationA_->permute();
    00138           else return coinFactorizationB_->permute() ;
    00139      }
    00141      inline int *pivotColumn (  ) const {
    00142           if (coinFactorizationA_) return coinFactorizationA_->pivotColumn();
    00143           else return coinFactorizationB_->permute() ;
    00144      }
    00146      inline int maximumPivots (  ) const {
    00147           if (coinFactorizationA_) return coinFactorizationA_->maximumPivots();
    00148           else return coinFactorizationB_->maximumPivots() ;
    00149      }
    00151      inline void maximumPivots (  int value) {
    00152           if (coinFactorizationA_) coinFactorizationA_->maximumPivots(value);
    00153           else coinFactorizationB_->maximumPivots(value);
    00154      }
    00156      inline int pivots (  ) const {
    00157           if (coinFactorizationA_) return coinFactorizationA_->pivots();
    00158           else return coinFactorizationB_->pivots() ;
    00159      }
    00161      inline double areaFactor (  ) const {
    00162           if (coinFactorizationA_) return coinFactorizationA_->areaFactor();
    00163           else return 0.0 ;
    00164      }
    00166      inline void areaFactor ( double value) {
    00167           if (coinFactorizationA_) coinFactorizationA_->areaFactor(value);
    00168      }
    00170      inline double zeroTolerance (  ) const {
    00171           if (coinFactorizationA_) return coinFactorizationA_->zeroTolerance();
    00172           else return coinFactorizationB_->zeroTolerance() ;
    00173      }
    00175      inline void zeroTolerance (  double value) {
    00176           if (coinFactorizationA_) coinFactorizationA_->zeroTolerance(value);
    00177           else coinFactorizationB_->zeroTolerance(value);
    00178      }
    00180      void saferTolerances (  double zeroTolerance, double pivotTolerance);
    00182      inline int sparseThreshold ( ) const {
    00183           if (coinFactorizationA_) return coinFactorizationA_->sparseThreshold();
    00184           else return 0 ;
    00185      }
    00187      inline void sparseThreshold ( int value) {
    00188           if (coinFactorizationA_) coinFactorizationA_->sparseThreshold(value);
    00189      }
    00191      inline int status (  ) const {
    00192           if (coinFactorizationA_) return coinFactorizationA_->status();
    00193           else return coinFactorizationB_->status() ;
    00194      }
    00196      inline void setStatus (  int value) {
    00197           if (coinFactorizationA_) coinFactorizationA_->setStatus(value);
    00198           else coinFactorizationB_->setStatus(value) ;
    00199      }
    00201      inline int numberDense() const {
    00202           if (coinFactorizationA_) return coinFactorizationA_->numberDense();
    00203           else return 0 ;
    00204      }
    00205 #if 1
    00207      inline CoinBigIndex numberElementsU (  ) const {
    00208           if (coinFactorizationA_) return coinFactorizationA_->numberElementsU();
    00209           else return -1 ;
    00210      }
    00212      inline CoinBigIndex numberElementsL (  ) const {
    00213           if (coinFactorizationA_) return coinFactorizationA_->numberElementsL();
    00214           else return -1 ;
    00215      }
    00217      inline CoinBigIndex numberElementsR (  ) const {
    00218           if (coinFactorizationA_) return coinFactorizationA_->numberElementsR();
    00219           else return 0 ;
    00220      }
    00221 #endif
    00222      inline bool timeToRefactorize() const {
    00223           if (coinFactorizationA_) {
    00224                return (coinFactorizationA_->pivots() * 3 > coinFactorizationA_->maximumPivots() * 2 &&
    00225                        coinFactorizationA_->numberElementsR() * 3 > (coinFactorizationA_->numberElementsL() +
    00226                                  coinFactorizationA_->numberElementsU()) * 2 + 1000 &&
    00227                        !coinFactorizationA_->numberDense());
    00228           } else {
    00229                return coinFactorizationB_->pivots() > coinFactorizationB_->numberRows() / 2.45 + 20;
    00230           }
    00231      }
    00233      inline int messageLevel (  ) const {
    00234           if (coinFactorizationA_) return coinFactorizationA_->messageLevel();
    00235           else return 1 ;
    00236      }
    00238      inline void messageLevel (  int value) {
    00239           if (coinFactorizationA_) coinFactorizationA_->messageLevel(value);
    00240      }
    00242      inline void clearArrays() {
    00243           if (coinFactorizationA_)
    00244                coinFactorizationA_->clearArrays();
    00245           else if (coinFactorizationB_)
    00246                coinFactorizationB_->clearArrays();
    00247      }
    00249      inline int numberRows (  ) const {
    00250           if (coinFactorizationA_) return coinFactorizationA_->numberRows();
    00251           else return coinFactorizationB_->numberRows() ;
    00252      }
    00254      inline int denseThreshold() const {
    00255           if (coinFactorizationA_) return coinFactorizationA_->denseThreshold();
    00256           else return 0 ;
    00257      }
    00259      inline void setDenseThreshold(int value) {
    00260           if (coinFactorizationA_) coinFactorizationA_->setDenseThreshold(value);
    00261      }
    00263      inline double pivotTolerance (  ) const {
    00264           if (coinFactorizationA_) return coinFactorizationA_->pivotTolerance();
    00265           else if (coinFactorizationB_) return coinFactorizationB_->pivotTolerance();
    00266           return 1.0e-8 ;
    00267      }
    00269      inline void pivotTolerance (  double value) {
    00270           if (coinFactorizationA_) coinFactorizationA_->pivotTolerance(value);
    00271           else if (coinFactorizationB_) coinFactorizationB_->pivotTolerance(value);
    00272      }
    00274      inline void relaxAccuracyCheck(double value) {
    00275           if (coinFactorizationA_) coinFactorizationA_->relaxAccuracyCheck(value);
    00276      }
    00282      inline int persistenceFlag() const {
    00283           if (coinFactorizationA_) return coinFactorizationA_->persistenceFlag();
    00284           else return 0 ;
    00285      }
    00286      inline void setPersistenceFlag(int value) {
    00287           if (coinFactorizationA_) coinFactorizationA_->setPersistenceFlag(value);
    00288      }
    00290      inline void almostDestructor() {
    00291           if (coinFactorizationA_)
    00292                coinFactorizationA_->almostDestructor();
    00293           else if (coinFactorizationB_)
    00294                coinFactorizationB_->clearArrays();
    00295      }
    00297      inline double adjustedAreaFactor() const {
    00298           if (coinFactorizationA_) return coinFactorizationA_->adjustedAreaFactor();
    00299           else return 0.0 ;
    00300      }
    00301      inline void setBiasLU(int value) {
    00302           if (coinFactorizationA_) coinFactorizationA_->setBiasLU(value);
    00303      }
    00305      inline void setForrestTomlin(bool value) {
    00306           if (coinFactorizationA_) coinFactorizationA_->setForrestTomlin(value);
    00307      }
    00309      inline void setDefaultValues() {
    00310           if (coinFactorizationA_) {
    00311                // row activities have negative sign
    00312 #ifndef COIN_FAST_CODE
    00313                coinFactorizationA_->slackValue(-1.0);
    00314 #endif
    00315                coinFactorizationA_->zeroTolerance(1.0e-13);
    00316           }
    00317      }
    00319      void forceOtherFactorization(int which);
    00321      inline int goOslThreshold() const {
    00322           return goOslThreshold_;
    00323      }
    00325      inline void setGoOslThreshold(int value) {
    00326           goOslThreshold_ = value;
    00327      }
    00329      inline int goDenseThreshold() const {
    00330           return goDenseThreshold_;
    00331      }
    00333      inline void setGoDenseThreshold(int value) {
    00334           goDenseThreshold_ = value;
    00335      }
    00337      inline int goSmallThreshold() const {
    00338           return goSmallThreshold_;
    00339      }
    00341      inline void setGoSmallThreshold(int value) {
    00342           goSmallThreshold_ = value;
    00343      }
    00345      void goDenseOrSmall(int numberRows) ;
    00347      void setFactorization(ClpFactorization & factorization);
    00349      inline int isDenseOrSmall() const {
    00350           return coinFactorizationB_ ? 1 : 0;
    00351      }
    00352 #else
    00353      inline bool timeToRefactorize() const {
    00354           return (pivots() * 3 > maximumPivots() * 2 &&
    00355                   numberElementsR() * 3 > (numberElementsL() + numberElementsU()) * 2 + 1000 &&
    00356                   !numberDense());
    00357      }
    00359      inline void setDefaultValues() {
    00360           // row activities have negative sign
    00361 #ifndef COIN_FAST_CODE
    00362           slackValue(-1.0);
    00363 #endif
    00364           zeroTolerance(1.0e-13);
    00365      }
    00367      inline void goDense() {}
    00368 #endif
    00369
    00370
    00374      void goSparse();
    00376      void cleanUp();
    00378      bool needToReorder() const;
    00379 #ifndef SLIM_CLP
    00381      inline bool networkBasis() const {
    00382           return (networkBasis_ != NULL);
    00383      }
    00384 #else
    00386      inline bool networkBasis() const {
    00387           return false;
    00388      }
    00389 #endif
    00391      void getWeights(int * weights) const;
    00392
    00393
    00395 private:
    00396
    00399
    00400 #ifndef SLIM_CLP
    00401      ClpNetworkBasis * networkBasis_;
    00402 #endif
    00403 #ifdef CLP_MULTIPLE_FACTORIZATIONS
    00405      CoinFactorization * coinFactorizationA_;
    00407      CoinOtherFactorization * coinFactorizationB_;
    00408 #ifdef CLP_REUSE_ETAS
    00410      ClpSimplex * model_;
    00411 #endif
    00413      int forceB_;
    00415      int goOslThreshold_;
    00417      int goSmallThreshold_;
    00419      int goDenseThreshold_;
    00420 #endif
    00421
    00422 };
    00423
    00424 #endif