CoinUtils  trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
CoinDenseFactorization.hpp
Go to the documentation of this file.
00001 /* $Id$ */
00002 // Copyright (C) 2008, 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 
00007 /* 
00008    Authors
00009    
00010    John Forrest
00011 
00012  */
00013 #ifndef CoinDenseFactorization_H
00014 #define CoinDenseFactorization_H
00015 
00016 #include <iostream>
00017 #include <string>
00018 #include <cassert>
00019 #include "CoinTypes.hpp"
00020 #include "CoinIndexedVector.hpp"
00021 #include "CoinFactorization.hpp"
00022 class CoinPackedMatrix;
00024 class CoinOtherFactorization {
00025 
00026 public:
00027 
00030 
00031   CoinOtherFactorization (  );
00033   CoinOtherFactorization ( const CoinOtherFactorization &other);
00034   
00036   virtual ~CoinOtherFactorization (  );
00038   CoinOtherFactorization & operator = ( const CoinOtherFactorization & other );
00039  
00041   virtual CoinOtherFactorization * clone() const = 0;
00043 
00046 
00047   inline int status (  ) const {
00048     return status_;
00049   }
00051   inline void setStatus (  int value)
00052   {  status_=value;  }
00054   inline int pivots (  ) const {
00055     return numberPivots_;
00056   }
00058   inline void setPivots (  int value ) 
00059   { numberPivots_=value; }
00061   inline void setNumberRows(int value)
00062   { numberRows_ = value; }
00064   inline int numberRows (  ) const {
00065     return numberRows_;
00066   }
00068   inline int numberColumns (  ) const {
00069     return numberColumns_;
00070   }
00072   inline int numberGoodColumns (  ) const {
00073     return numberGoodU_;
00074   }
00076   inline void relaxAccuracyCheck(double value)
00077   { relaxCheck_ = value;}
00078   inline double getAccuracyCheck() const
00079   { return relaxCheck_;}
00081   inline int maximumPivots (  ) const {
00082     return maximumPivots_ ;
00083   }
00085   virtual void maximumPivots (  int value );
00086 
00088   inline double pivotTolerance (  ) const {
00089     return pivotTolerance_ ;
00090   }
00091   void pivotTolerance (  double value );
00093   inline double zeroTolerance (  ) const {
00094     return zeroTolerance_ ;
00095   }
00096   void zeroTolerance (  double value );
00097 #ifndef COIN_FAST_CODE
00098 
00099   inline double slackValue (  ) const {
00100     return slackValue_ ;
00101   }
00102   void slackValue (  double value );
00103 #endif
00104 
00105   virtual CoinFactorizationDouble * elements() const;
00107   virtual int * pivotRow() const;
00109   virtual CoinFactorizationDouble * workArea() const;
00111   virtual int * intWorkArea() const;
00113   virtual int * numberInRow() const;
00115   virtual int * numberInColumn() const;
00117   virtual CoinBigIndex * starts() const;
00119   virtual int * permuteBack() const;
00124   inline int solveMode() const
00125   { return solveMode_ ;}
00130   inline void setSolveMode(int value)
00131   { solveMode_ = value;}
00133   virtual bool wantsTableauColumn() const;
00138   virtual void setUsefulInformation(const int * info,int whereFrom);
00140   virtual void clearArrays() {}
00142 
00144 
00145   virtual int * indices() const  = 0;
00147   virtual int * permute() const = 0;
00149   virtual int numberElements (  ) const = 0;
00151 
00153 
00154   virtual void getAreas ( int numberRows,
00155                   int numberColumns,
00156                   CoinBigIndex maximumL,
00157                   CoinBigIndex maximumU ) = 0;
00158   
00160   virtual void preProcess ( ) = 0;
00166   virtual int factor ( ) = 0;
00168   virtual void postProcess(const int * sequence, int * pivotVariable) = 0;
00170   virtual void makeNonSingular(int * sequence, int numberColumns) = 0;
00172 
00175 
00183   virtual int replaceColumn ( CoinIndexedVector * regionSparse,
00184                       int pivotRow,
00185                       double pivotCheck ,
00186                               bool checkBeforeModifying=false,
00187                               double acceptablePivot=1.0e-8)=0;
00189 
00199   virtual int updateColumnFT ( CoinIndexedVector * regionSparse,
00200                                CoinIndexedVector * regionSparse2,
00201                                bool noPermute=false) = 0;
00204   virtual int updateColumn ( CoinIndexedVector * regionSparse,
00205                      CoinIndexedVector * regionSparse2,
00206                      bool noPermute=false) const = 0;
00208     virtual int updateTwoColumnsFT(CoinIndexedVector * regionSparse1,
00209                            CoinIndexedVector * regionSparse2,
00210                            CoinIndexedVector * regionSparse3,
00211                            bool noPermute=false) = 0;
00216   virtual int updateColumnTranspose ( CoinIndexedVector * regionSparse,
00217                               CoinIndexedVector * regionSparse2) const = 0;
00219 
00221 protected:
00222 
00225 
00226   double pivotTolerance_;
00228   double zeroTolerance_;
00229 #ifndef COIN_FAST_CODE
00230 
00231   double slackValue_;
00232 #else
00233 #ifndef slackValue_
00234 #define slackValue_ -1.0
00235 #endif
00236 #endif
00237 
00238   double relaxCheck_;
00240   CoinBigIndex factorElements_;
00242   int numberRows_;
00244   int numberColumns_;
00246   int numberGoodU_;
00248   int maximumPivots_;
00250   int numberPivots_;
00252   int status_;
00254   int maximumRows_;
00256   CoinBigIndex maximumSpace_;
00258   int * pivotRow_;
00263   CoinFactorizationDouble * elements_;
00265   CoinFactorizationDouble * workArea_;
00270   int solveMode_;
00272 };
00282 class CoinDenseFactorization : public CoinOtherFactorization {
00283    friend void CoinDenseFactorizationUnitTest( const std::string & mpsDir );
00284 
00285 public:
00286 
00289 
00290   CoinDenseFactorization (  );
00292   CoinDenseFactorization ( const CoinDenseFactorization &other);
00293   
00295   virtual ~CoinDenseFactorization (  );
00297   CoinDenseFactorization & operator = ( const CoinDenseFactorization & other );
00299   virtual CoinOtherFactorization * clone() const ;
00301 
00304 
00305   virtual void getAreas ( int numberRows,
00306                   int numberColumns,
00307                   CoinBigIndex maximumL,
00308                   CoinBigIndex maximumU );
00309   
00311   virtual void preProcess ( );
00317   virtual int factor ( );
00319   virtual void postProcess(const int * sequence, int * pivotVariable);
00321   virtual void makeNonSingular(int * sequence, int numberColumns);
00323 
00326 
00327   virtual inline int numberElements (  ) const {
00328     return numberRows_*(numberColumns_+numberPivots_);
00329   }
00331   double maximumCoefficient() const;
00333 
00336 
00344   virtual int replaceColumn ( CoinIndexedVector * regionSparse,
00345                       int pivotRow,
00346                       double pivotCheck ,
00347                               bool checkBeforeModifying=false,
00348                               double acceptablePivot=1.0e-8);
00350 
00360   virtual inline int updateColumnFT ( CoinIndexedVector * regionSparse,
00361                                       CoinIndexedVector * regionSparse2,
00362                                       bool = false)
00363   { return updateColumn(regionSparse,regionSparse2);}
00366   virtual int updateColumn ( CoinIndexedVector * regionSparse,
00367                      CoinIndexedVector * regionSparse2,
00368                      bool noPermute=false) const;
00370     virtual int updateTwoColumnsFT(CoinIndexedVector * regionSparse1,
00371                            CoinIndexedVector * regionSparse2,
00372                            CoinIndexedVector * regionSparse3,
00373                            bool noPermute=false);
00378   virtual int updateColumnTranspose ( CoinIndexedVector * regionSparse,
00379                               CoinIndexedVector * regionSparse2) const;
00381 
00382 
00386 
00387   inline void clearArrays()
00388   { gutsOfDestructor();}
00390   virtual inline int * indices() const
00391   { return reinterpret_cast<int *> (elements_+numberRows_*numberRows_);}
00393   virtual inline int * permute() const
00394   { return NULL;/*pivotRow_*/;}
00396 
00398   void gutsOfDestructor();
00400   void gutsOfInitialize();
00402   void gutsOfCopy(const CoinDenseFactorization &other);
00403 
00405 protected:
00408   int checkPivot(double saveFromU, double oldPivot) const;
00410 protected:
00411 
00414 
00415 };
00416 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines