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

- File List
- File Members

# /home/coin/svn-release/Alps-1.4.8/Clp/src/ClpFactorization.hpp

Go to the documentation of this file.

    00001 /* $Id: ClpFactorization.hpp 1665 2011-01-04 17:55:54Z lou $ */
    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
    00032 class ClpFactorization
    00033 #ifndef CLP_MULTIPLE_FACTORIZATIONS
    00034      : public CoinFactorization
    00035 #endif
    00036 {
    00037
    00038      //friend class CoinFactorization;
    00039
    00040 public:
    00052      int factorize (ClpSimplex * model, int solveType, bool valuesPass);
    00054
    00055
    00059      ClpFactorization();
    00061      ~ClpFactorization();
    00063
    00067      ClpFactorization(const CoinFactorization&);
    00069      ClpFactorization(const ClpFactorization&, int denseIfSmaller = 0);
    00070 #ifdef CLP_MULTIPLE_FACTORIZATIONS
    00071
    00072      ClpFactorization(const CoinOtherFactorization&);
    00073 #endif
    00074      ClpFactorization& operator=(const ClpFactorization&);
    00076
    00077      /*  **** below here is so can use networkish basis */
    00080
    00088      int replaceColumn ( const ClpSimplex * model,
    00089                          CoinIndexedVector * regionSparse,
    00090                          CoinIndexedVector * tableauColumn,
    00091                          int pivotRow,
    00092                          double pivotCheck ,
    00093                          bool checkBeforeModifying = false,
    00094                          double acceptablePivot = 1.0e-8);
    00096
    00104      int updateColumnFT ( CoinIndexedVector * regionSparse,
    00105                           CoinIndexedVector * regionSparse2);
    00108      int updateColumn ( CoinIndexedVector * regionSparse,
    00109                         CoinIndexedVector * regionSparse2,
    00110                         bool noPermute = false) const;
    00116      int updateTwoColumnsFT ( CoinIndexedVector * regionSparse1,
    00117                               CoinIndexedVector * regionSparse2,
    00118                               CoinIndexedVector * regionSparse3,
    00119                               bool noPermuteRegion3 = false) ;
    00121      int updateColumnForDebug ( CoinIndexedVector * regionSparse,
    00122                                 CoinIndexedVector * regionSparse2,
    00123                                 bool noPermute = false) const;
    00126      int updateColumnTranspose ( CoinIndexedVector * regionSparse,
    00127                                  CoinIndexedVector * regionSparse2) const;
    00129 #ifdef CLP_MULTIPLE_FACTORIZATIONS
    00130
    00132
    00133      inline int numberElements (  ) const {
    00134           if (coinFactorizationA_) return coinFactorizationA_->numberElements();
    00135           else return coinFactorizationB_->numberElements() ;
    00136      }
    00138      inline int *permute (  ) const {
    00139           if (coinFactorizationA_) return coinFactorizationA_->permute();
    00140           else return coinFactorizationB_->permute() ;
    00141      }
    00143      inline int *pivotColumn (  ) const {
    00144           if (coinFactorizationA_) return coinFactorizationA_->pivotColumn();
    00145           else return coinFactorizationB_->permute() ;
    00146      }
    00148      inline int maximumPivots (  ) const {
    00149           if (coinFactorizationA_) return coinFactorizationA_->maximumPivots();
    00150           else return coinFactorizationB_->maximumPivots() ;
    00151      }
    00153      inline void maximumPivots (  int value) {
    00154           if (coinFactorizationA_) coinFactorizationA_->maximumPivots(value);
    00155           else coinFactorizationB_->maximumPivots(value);
    00156      }
    00158      inline int pivots (  ) const {
    00159           if (coinFactorizationA_) return coinFactorizationA_->pivots();
    00160           else return coinFactorizationB_->pivots() ;
    00161      }
    00163      inline double areaFactor (  ) const {
    00164           if (coinFactorizationA_) return coinFactorizationA_->areaFactor();
    00165           else return 0.0 ;
    00166      }
    00168      inline void areaFactor ( double value) {
    00169           if (coinFactorizationA_) coinFactorizationA_->areaFactor(value);
    00170      }
    00172      inline double zeroTolerance (  ) const {
    00173           if (coinFactorizationA_) return coinFactorizationA_->zeroTolerance();
    00174           else return coinFactorizationB_->zeroTolerance() ;
    00175      }
    00177      inline void zeroTolerance (  double value) {
    00178           if (coinFactorizationA_) coinFactorizationA_->zeroTolerance(value);
    00179           else coinFactorizationB_->zeroTolerance(value);
    00180      }
    00182      void saferTolerances (  double zeroTolerance, double pivotTolerance);
    00184      inline int sparseThreshold ( ) const {
    00185           if (coinFactorizationA_) return coinFactorizationA_->sparseThreshold();
    00186           else return 0 ;
    00187      }
    00189      inline void sparseThreshold ( int value) {
    00190           if (coinFactorizationA_) coinFactorizationA_->sparseThreshold(value);
    00191      }
    00193      inline int status (  ) const {
    00194           if (coinFactorizationA_) return coinFactorizationA_->status();
    00195           else return coinFactorizationB_->status() ;
    00196      }
    00198      inline void setStatus (  int value) {
    00199           if (coinFactorizationA_) coinFactorizationA_->setStatus(value);
    00200           else coinFactorizationB_->setStatus(value) ;
    00201      }
    00203      inline int numberDense() const {
    00204           if (coinFactorizationA_) return coinFactorizationA_->numberDense();
    00205           else return 0 ;
    00206      }
    00207 #if 1
    00209      inline CoinBigIndex numberElementsU (  ) const {
    00210           if (coinFactorizationA_) return coinFactorizationA_->numberElementsU();
    00211           else return -1 ;
    00212      }
    00214      inline CoinBigIndex numberElementsL (  ) const {
    00215           if (coinFactorizationA_) return coinFactorizationA_->numberElementsL();
    00216           else return -1 ;
    00217      }
    00219      inline CoinBigIndex numberElementsR (  ) const {
    00220           if (coinFactorizationA_) return coinFactorizationA_->numberElementsR();
    00221           else return 0 ;
    00222      }
    00223 #endif
    00224      inline bool timeToRefactorize() const {
    00225           if (coinFactorizationA_) {
    00226                return (coinFactorizationA_->pivots() * 3 > coinFactorizationA_->maximumPivots() * 2 &&
    00227                        coinFactorizationA_->numberElementsR() * 3 > (coinFactorizationA_->numberElementsL() +
    00228                                  coinFactorizationA_->numberElementsU()) * 2 + 1000 &&
    00229                        !coinFactorizationA_->numberDense());
    00230           } else {
    00231                return coinFactorizationB_->pivots() > coinFactorizationB_->numberRows() / 2.45 + 20;
    00232           }
    00233      }
    00235      inline int messageLevel (  ) const {
    00236           if (coinFactorizationA_) return coinFactorizationA_->messageLevel();
    00237           else return 1 ;
    00238      }
    00240      inline void messageLevel (  int value) {
    00241           if (coinFactorizationA_) coinFactorizationA_->messageLevel(value);
    00242      }
    00244      inline void clearArrays() {
    00245           if (coinFactorizationA_)
    00246                coinFactorizationA_->clearArrays();
    00247           else if (coinFactorizationB_)
    00248                coinFactorizationB_->clearArrays();
    00249      }
    00251      inline int numberRows (  ) const {
    00252           if (coinFactorizationA_) return coinFactorizationA_->numberRows();
    00253           else return coinFactorizationB_->numberRows() ;
    00254      }
    00256      inline int denseThreshold() const {
    00257           if (coinFactorizationA_) return coinFactorizationA_->denseThreshold();
    00258           else return 0 ;
    00259      }
    00261      inline void setDenseThreshold(int value) {
    00262           if (coinFactorizationA_) coinFactorizationA_->setDenseThreshold(value);
    00263      }
    00265      inline double pivotTolerance (  ) const {
    00266           if (coinFactorizationA_) return coinFactorizationA_->pivotTolerance();
    00267           else if (coinFactorizationB_) return coinFactorizationB_->pivotTolerance();
    00268           return 1.0e-8 ;
    00269      }
    00271      inline void pivotTolerance (  double value) {
    00272           if (coinFactorizationA_) coinFactorizationA_->pivotTolerance(value);
    00273           else if (coinFactorizationB_) coinFactorizationB_->pivotTolerance(value);
    00274      }
    00276      inline void relaxAccuracyCheck(double value) {
    00277           if (coinFactorizationA_) coinFactorizationA_->relaxAccuracyCheck(value);
    00278      }
    00284      inline int persistenceFlag() const {
    00285           if (coinFactorizationA_) return coinFactorizationA_->persistenceFlag();
    00286           else return 0 ;
    00287      }
    00288      inline void setPersistenceFlag(int value) {
    00289           if (coinFactorizationA_) coinFactorizationA_->setPersistenceFlag(value);
    00290      }
    00292      inline void almostDestructor() {
    00293           if (coinFactorizationA_)
    00294                coinFactorizationA_->almostDestructor();
    00295           else if (coinFactorizationB_)
    00296                coinFactorizationB_->clearArrays();
    00297      }
    00299      inline double adjustedAreaFactor() const {
    00300           if (coinFactorizationA_) return coinFactorizationA_->adjustedAreaFactor();
    00301           else return 0.0 ;
    00302      }
    00303      inline void setBiasLU(int value) {
    00304           if (coinFactorizationA_) coinFactorizationA_->setBiasLU(value);
    00305      }
    00307      inline void setForrestTomlin(bool value) {
    00308           if (coinFactorizationA_) coinFactorizationA_->setForrestTomlin(value);
    00309      }
    00311      inline void setDefaultValues() {
    00312           if (coinFactorizationA_) {
    00313                // row activities have negative sign
    00314 #ifndef COIN_FAST_CODE
    00315                coinFactorizationA_->slackValue(-1.0);
    00316 #endif
    00317                coinFactorizationA_->zeroTolerance(1.0e-13);
    00318           }
    00319      }
    00321      void forceOtherFactorization(int which);
    00323      inline int goOslThreshold() const {
    00324           return goOslThreshold_;
    00325      }
    00327      inline void setGoOslThreshold(int value) {
    00328           goOslThreshold_ = value;
    00329      }
    00331      inline int goDenseThreshold() const {
    00332           return goDenseThreshold_;
    00333      }
    00335      inline void setGoDenseThreshold(int value) {
    00336           goDenseThreshold_ = value;
    00337      }
    00339      inline int goSmallThreshold() const {
    00340           return goSmallThreshold_;
    00341      }
    00343      inline void setGoSmallThreshold(int value) {
    00344           goSmallThreshold_ = value;
    00345      }
    00347      void goDenseOrSmall(int numberRows) ;
    00349      void setFactorization(ClpFactorization & factorization);
    00351      inline int isDenseOrSmall() const {
    00352           return coinFactorizationB_ ? 1 : 0;
    00353      }
    00354 #else
    00355      inline bool timeToRefactorize() const {
    00356           return (pivots() * 3 > maximumPivots() * 2 &&
    00357                   numberElementsR() * 3 > (numberElementsL() + numberElementsU()) * 2 + 1000 &&
    00358                   !numberDense());
    00359      }
    00361      inline void setDefaultValues() {
    00362           // row activities have negative sign
    00363 #ifndef COIN_FAST_CODE
    00364           slackValue(-1.0);
    00365 #endif
    00366           zeroTolerance(1.0e-13);
    00367      }
    00369      inline void goDense() {}
    00370 #endif
    00371
    00372
    00376      void goSparse();
    00378      void cleanUp();
    00380      bool needToReorder() const;
    00381 #ifndef SLIM_CLP
    00383      inline bool networkBasis() const {
    00384           return (networkBasis_ != NULL);
    00385      }
    00386 #else
    00388      inline bool networkBasis() const {
    00389           return false;
    00390      }
    00391 #endif
    00393      void getWeights(int * weights) const;
    00394
    00395
    00397 private:
    00398
    00401
    00402 #ifndef SLIM_CLP
    00403      ClpNetworkBasis * networkBasis_;
    00404 #endif
    00405 #ifdef CLP_MULTIPLE_FACTORIZATIONS
    00407      CoinFactorization * coinFactorizationA_;
    00409      CoinOtherFactorization * coinFactorizationB_;
    00410 #ifdef CLP_REUSE_ETAS
    00412      ClpSimplex * model_;
    00413 #endif
    00415      int forceB_;
    00417      int goOslThreshold_;
    00419      int goSmallThreshold_;
    00421      int goDenseThreshold_;
    00422 #endif
    00423
    00424 };
    00425
    00426 #endif