00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef CoinAbcDenseFactorization_H
00014 #define CoinAbcDenseFactorization_H
00015
00016 #include <iostream>
00017 #include <string>
00018 #include <cassert>
00019 #include "CoinTypes.hpp"
00020 #include "CoinAbcCommon.hpp"
00021 #include "CoinIndexedVector.hpp"
00022 class CoinPackedMatrix;
00024 class CoinAbcAnyFactorization {
00025
00026 public:
00027
00030
00031 CoinAbcAnyFactorization ( );
00033 CoinAbcAnyFactorization ( const CoinAbcAnyFactorization &other);
00034
00036 virtual ~CoinAbcAnyFactorization ( );
00038 CoinAbcAnyFactorization & operator = ( const CoinAbcAnyFactorization & other );
00039
00041 virtual CoinAbcAnyFactorization * 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 }
00057 #if ABC_PARALLEL==2
00059 inline void setParallelMode(int value)
00060 {parallelMode_=value;};
00061 #endif
00063 inline void setPivots ( int value )
00064 { numberPivots_=value; }
00066 inline int numberSlacks ( ) const {
00067 return numberSlacks_;
00068 }
00070 inline void setNumberSlacks ( int value )
00071 { numberSlacks_=value; }
00073 inline void setNumberRows(int value)
00074 { numberRows_ = value; }
00076 inline int numberRows ( ) const {
00077 return numberRows_;
00078 }
00080 inline CoinSimplexInt numberDense ( ) const {
00081 return numberDense_;
00082 }
00084 inline int numberGoodColumns ( ) const {
00085 return numberGoodU_;
00086 }
00088 inline void relaxAccuracyCheck(double value)
00089 { relaxCheck_ = value;}
00090 inline double getAccuracyCheck() const
00091 { return relaxCheck_;}
00093 inline int maximumPivots ( ) const {
00094 return maximumPivots_ ;
00095 }
00097 virtual void maximumPivots ( int value );
00098
00100 inline double pivotTolerance ( ) const {
00101 return pivotTolerance_ ;
00102 }
00103 void pivotTolerance ( double value );
00105 inline double minimumPivotTolerance ( ) const {
00106 return minimumPivotTolerance_ ;
00107 }
00108 void minimumPivotTolerance ( double value );
00109 virtual CoinFactorizationDouble * pivotRegion() const
00110 { return NULL;}
00112 inline double areaFactor ( ) const {
00113 return areaFactor_ ;
00114 }
00115 inline void areaFactor ( CoinSimplexDouble value ) {
00116 areaFactor_=value;
00117 }
00119 inline double zeroTolerance ( ) const {
00120 return zeroTolerance_ ;
00121 }
00122 void zeroTolerance ( double value );
00124 virtual CoinFactorizationDouble * elements() const;
00126 virtual int * pivotRow() const;
00128 virtual CoinFactorizationDouble * workArea() const;
00130 virtual int * intWorkArea() const;
00132 virtual int * numberInRow() const;
00134 virtual int * numberInColumn() const;
00136 virtual CoinBigIndex * starts() const;
00138 virtual int * permuteBack() const;
00140 virtual void goSparse() {}
00141 #ifndef NDEBUG
00142 virtual inline void checkMarkArrays() const {}
00143 #endif
00144
00148 inline int solveMode() const
00149 { return solveMode_ ;}
00154 inline void setSolveMode(int value)
00155 { solveMode_ = value;}
00157 virtual bool wantsTableauColumn() const;
00162 virtual void setUsefulInformation(const int * info,int whereFrom);
00164 virtual void clearArrays() {}
00166
00168
00169 virtual int * indices() const = 0;
00171 virtual int * permute() const = 0;
00173 virtual int * pivotColumn() const;
00175 virtual int numberElements ( ) const = 0;
00177
00179
00180 virtual void getAreas ( int numberRows,
00181 int numberColumns,
00182 CoinBigIndex maximumL,
00183 CoinBigIndex maximumU ) = 0;
00184
00186 virtual void preProcess ( ) = 0;
00192 virtual int factor (AbcSimplex * model) = 0;
00193 #ifdef EARLY_FACTORIZE
00195 virtual int factorize (AbcSimplex * , CoinIndexedVector & )
00196 { return -2;}
00197 #endif
00199 virtual void postProcess(const int * sequence, int * pivotVariable) = 0;
00201 virtual void makeNonSingular(int * sequence) = 0;
00202
00203
00206 #if 0
00207
00211 virtual int checkReplace ( CoinIndexedVector * ,
00212 int ,
00213 double & ,
00214 double )
00215 {return 0;}
00220 virtual int replaceColumn ( CoinIndexedVector * regionSparse,
00221 int pivotRow,
00222 double pivotCheck ,
00223 bool skipBtranU=false,
00224 double acceptablePivot=1.0e-8)=0;
00225 #endif
00226 #ifdef EARLY_FACTORIZE
00228 virtual int replaceColumns ( const AbcSimplex * ,
00229 CoinIndexedVector & ,
00230 int ,int ,bool )
00231 { return -1;}
00232 #endif
00233 #ifdef ABC_LONG_FACTORIZATION
00235 virtual void clearHiddenArrays() {}
00236 #endif
00237
00241 virtual
00242 #ifdef ABC_LONG_FACTORIZATION
00243 long
00244 #endif
00245 double checkReplacePart1 ( CoinIndexedVector * ,
00246 int )
00247 {return 0.0;}
00248 virtual
00249 #ifdef ABC_LONG_FACTORIZATION
00250 long
00251 #endif
00252 double checkReplacePart1 ( CoinIndexedVector * ,
00253 CoinIndexedVector * ,
00254 int )
00255 {return 0.0;}
00256 virtual void checkReplacePart1a ( CoinIndexedVector * ,
00257 int )
00258 {}
00259 virtual double checkReplacePart1b (CoinIndexedVector * ,
00260 int )
00261 {return 0.0;}
00264 virtual int checkReplacePart2 ( int pivotRow,
00265 double btranAlpha,
00266 double ftranAlpha,
00267 #ifdef ABC_LONG_FACTORIZATION
00268 long
00269 #endif
00270 double ftAlpha,
00271 double acceptablePivot = 1.0e-8) = 0;
00274 virtual void replaceColumnPart3 ( const AbcSimplex * model,
00275 CoinIndexedVector * regionSparse,
00276 CoinIndexedVector * tableauColumn,
00277 int pivotRow,
00278 #ifdef ABC_LONG_FACTORIZATION
00279 long
00280 #endif
00281 double alpha ) = 0;
00284 virtual void replaceColumnPart3 ( const AbcSimplex * model,
00285 CoinIndexedVector * regionSparse,
00286 CoinIndexedVector * tableauColumn,
00287 CoinIndexedVector * partialUpdate,
00288 int pivotRow,
00289 #ifdef ABC_LONG_FACTORIZATION
00290 long
00291 #endif
00292 double alpha )=0;
00294
00302 virtual int updateColumnFT ( CoinIndexedVector & regionSparse) = 0;
00303 virtual int updateColumnFTPart1 ( CoinIndexedVector & regionSparse) = 0;
00304 virtual void updateColumnFTPart2 ( CoinIndexedVector & regionSparse) = 0;
00305 virtual void updateColumnFT ( CoinIndexedVector & regionSparseFT,
00306 CoinIndexedVector & partialUpdate,
00307 int which)=0;
00310 virtual int updateColumn ( CoinIndexedVector & regionSparse) const = 0;
00312 virtual int updateTwoColumnsFT(CoinIndexedVector & regionFT,
00313 CoinIndexedVector & regionOther) = 0;
00316 virtual int updateColumnTranspose ( CoinIndexedVector & regionSparse) const = 0;
00318 virtual void updateFullColumn ( CoinIndexedVector & regionSparse) const = 0;
00321 virtual void updateFullColumnTranspose ( CoinIndexedVector & regionSparse) const = 0;
00323 virtual void updateWeights ( CoinIndexedVector & regionSparse) const=0;
00325 virtual void updateColumnCpu ( CoinIndexedVector & regionSparse,int whichCpu) const;
00327 virtual void updateColumnTransposeCpu ( CoinIndexedVector & regionSparse,int whichCpu) const;
00329
00331 protected:
00332
00335
00336 double pivotTolerance_;
00338 double minimumPivotTolerance_;
00340 double areaFactor_;
00342 double zeroTolerance_;
00343
00344 #define slackValue2_ 1.0
00345
00347 double relaxCheck_;
00349 CoinBigIndex factorElements_;
00351 int numberRows_;
00353 int numberDense_;
00355 int numberGoodU_;
00357 int maximumPivots_;
00359 int numberPivots_;
00361 int numberSlacks_;
00363 int status_;
00365 int maximumRows_;
00366 #if ABC_PARALLEL==2
00367 int parallelMode_;
00368 #endif
00370 int * pivotRow_;
00371
00375 CoinFactorizationDouble * elements_;
00377 CoinFactorizationDouble * workArea_;
00382 int solveMode_;
00384 };
00394 class CoinAbcDenseFactorization : public CoinAbcAnyFactorization {
00395 friend void CoinAbcDenseFactorizationUnitTest( const std::string & mpsDir );
00396
00397 public:
00398
00401
00402 CoinAbcDenseFactorization ( );
00404 CoinAbcDenseFactorization ( const CoinAbcDenseFactorization &other);
00405
00407 virtual ~CoinAbcDenseFactorization ( );
00409 CoinAbcDenseFactorization & operator = ( const CoinAbcDenseFactorization & other );
00411 virtual CoinAbcAnyFactorization * clone() const ;
00413
00416
00417 virtual void getAreas ( int numberRows,
00418 int numberColumns,
00419 CoinBigIndex maximumL,
00420 CoinBigIndex maximumU );
00421
00423 virtual void preProcess ( );
00429 virtual int factor (AbcSimplex * model);
00431 virtual void postProcess(const int * sequence, int * pivotVariable);
00433 virtual void makeNonSingular(int * sequence);
00435
00438
00439 virtual inline int numberElements ( ) const {
00440 return numberRows_*(numberRows_+numberPivots_);
00441 }
00443 double maximumCoefficient() const;
00445
00448
00453 virtual int replaceColumn ( CoinIndexedVector * regionSparse,
00454 int pivotRow,
00455 double pivotCheck ,
00456 bool skipBtranU=false,
00457 double acceptablePivot=1.0e-8);
00460 virtual int checkReplacePart2 ( int pivotRow,
00461 double btranAlpha,
00462 double ftranAlpha,
00463 #ifdef ABC_LONG_FACTORIZATION
00464 long
00465 #endif
00466 double ftAlpha,
00467 double acceptablePivot = 1.0e-8) ;
00470 virtual void replaceColumnPart3 ( const AbcSimplex * model,
00471 CoinIndexedVector * regionSparse,
00472 CoinIndexedVector * tableauColumn,
00473 int pivotRow,
00474 #ifdef ABC_LONG_FACTORIZATION
00475 long
00476 #endif
00477 double alpha );
00480 virtual void replaceColumnPart3 ( const AbcSimplex * model,
00481 CoinIndexedVector * regionSparse,
00482 CoinIndexedVector * tableauColumn,
00483 CoinIndexedVector * ,
00484 int pivotRow,
00485 #ifdef ABC_LONG_FACTORIZATION
00486 long
00487 #endif
00488 double alpha )
00489 { replaceColumnPart3(model,regionSparse,tableauColumn,pivotRow,alpha);}
00491
00499 virtual int updateColumnFT ( CoinIndexedVector & regionSparse)
00500 {return updateColumn(regionSparse);}
00501 virtual int updateColumnFTPart1 ( CoinIndexedVector & regionSparse)
00502 {return updateColumn(regionSparse);}
00503 virtual void updateColumnFTPart2 ( CoinIndexedVector & )
00504 {}
00505 virtual void updateColumnFT ( CoinIndexedVector & regionSparseFT,CoinIndexedVector & ,int )
00506 { updateColumnFT(regionSparseFT);}
00509 virtual int updateColumn ( CoinIndexedVector & regionSparse) const;
00511 virtual int updateTwoColumnsFT(CoinIndexedVector & regionFT,
00512 CoinIndexedVector & regionOther);
00515 virtual int updateColumnTranspose ( CoinIndexedVector & regionSparse) const;
00517 virtual void updateFullColumn ( CoinIndexedVector & regionSparse) const
00518 {updateColumn(regionSparse);}
00521 virtual void updateFullColumnTranspose ( CoinIndexedVector & regionSparse) const
00522 {updateColumnTranspose(regionSparse);}
00524 virtual void updateWeights ( CoinIndexedVector & regionSparse) const;
00526
00527
00531
00532 inline void clearArrays()
00533 { gutsOfDestructor();}
00535 virtual inline int * indices() const
00536 { return reinterpret_cast<int *> (elements_+numberRows_*numberRows_);}
00538 virtual inline int * permute() const
00539 { return NULL;;}
00541
00543 void gutsOfDestructor();
00545 void gutsOfInitialize();
00547 void gutsOfCopy(const CoinAbcDenseFactorization &other);
00548
00550 protected:
00553 int checkPivot(double saveFromU, double oldPivot) const;
00555 protected:
00557 CoinBigIndex maximumSpace_;
00559 CoinSimplexInt maximumRowsAdjusted_;
00560
00563
00564 };
00565 #endif