Clp  1.15.10
AbcSimplexFactorization.hpp
Go to the documentation of this file.
1 /* $Id: AbcSimplexFactorization.hpp 1910 2013-01-27 02:00:13Z stefan $ */
2 // Copyright (C) 2002, International Business Machines
3 // Corporation and others, Copyright (C) 2012, FasterCoin. All Rights Reserved.
4 // This code is licensed under the terms of the Eclipse Public License (EPL).
5 
6 #ifndef AbcSimplexFactorization_H
7 #define AbcSimplexFactorization_H
8 
9 
10 #include "CoinPragma.hpp"
11 
12 #include "CoinAbcCommon.hpp"
13 #include "CoinAbcFactorization.hpp"
14 #include "AbcMatrix.hpp"
15 //#include "CoinAbcAnyFactorization.hpp"
16 #include "AbcSimplex.hpp"
17 class ClpFactorization;
18 
23 {
24 
25 public:
37  int factorize (AbcSimplex * model, int solveType, bool valuesPass);
38 #ifdef EARLY_FACTORIZE
39  inline int factorize (AbcSimplex * model, CoinIndexedVector & stuff)
41  { return coinAbcFactorization_->factorize(model,stuff);}
42 #endif
43 
44 
45 
53 
57  AbcSimplexFactorization(const AbcSimplexFactorization&, int denseIfSmaller = 0);
62 
63  /* **** below here is so can use networkish basis */
66 
71  inline
72 #ifdef ABC_LONG_FACTORIZATION
73  long
74 #endif
75  double checkReplacePart1 ( CoinIndexedVector * regionSparse,
76  int pivotRow)
77  {return coinAbcFactorization_->checkReplacePart1(regionSparse,pivotRow);}
82  inline
83 #ifdef ABC_LONG_FACTORIZATION
84  long
85 #endif
86  double checkReplacePart1 ( CoinIndexedVector * regionSparse,
87  CoinIndexedVector * partialUpdate,
88  int pivotRow)
89  {return coinAbcFactorization_->checkReplacePart1(regionSparse,partialUpdate,pivotRow);}
94  inline void checkReplacePart1a ( CoinIndexedVector * regionSparse,
95  int pivotRow)
96  {coinAbcFactorization_->checkReplacePart1a(regionSparse,pivotRow);}
97  inline double checkReplacePart1b (CoinIndexedVector * regionSparse,
98  int pivotRow)
99  {return coinAbcFactorization_->checkReplacePart1b(regionSparse,pivotRow);}
102  inline int checkReplacePart2 ( int pivotRow,
103  double btranAlpha,
104  double ftranAlpha,
105 #ifdef ABC_LONG_FACTORIZATION
106  long
107 #endif
108  double ftAlpha)
109  {return coinAbcFactorization_->checkReplacePart2(pivotRow,btranAlpha,ftranAlpha,ftAlpha);}
110 #ifdef ABC_LONG_FACTORIZATION
111  inline void clearHiddenArrays()
113  { coinAbcFactorization_->clearHiddenArrays();}
114 #endif
115 
117  void replaceColumnPart3 ( const AbcSimplex * model,
118  CoinIndexedVector * regionSparse,
119  CoinIndexedVector * tableauColumn,
120  int pivotRow,
121 #ifdef ABC_LONG_FACTORIZATION
122  long
123 #endif
124  double alpha );
127  void replaceColumnPart3 ( const AbcSimplex * model,
128  CoinIndexedVector * regionSparse,
129  CoinIndexedVector * tableauColumn,
130  CoinIndexedVector * partialUpdate,
131  int pivotRow,
132 #ifdef ABC_LONG_FACTORIZATION
133  long
134 #endif
135  double alpha );
136 #ifdef EARLY_FACTORIZE
137  inline int replaceColumns ( const AbcSimplex * model,
139  CoinIndexedVector & stuff,
140  int firstPivot,int lastPivot,bool cleanUp)
141  { return coinAbcFactorization_->replaceColumns(model,stuff,firstPivot,lastPivot,cleanUp);}
142 #endif
143 
144 
148 #if 0
149 
153  int updateColumnFT ( CoinIndexedVector * regionSparse,
154  CoinIndexedVector * regionSparse2);
157  int updateColumn ( CoinIndexedVector * regionSparse,
158  CoinIndexedVector * regionSparse2) const;
164  int updateTwoColumnsFT ( CoinIndexedVector * regionSparse1,
165  CoinIndexedVector * regionSparse2,
166  CoinIndexedVector * regionSparse3) ;
169  int updateColumnTranspose ( CoinIndexedVector * regionSparse,
170  CoinIndexedVector * regionSparse2) const;
171 #endif
172 
175  inline int updateColumnFT ( CoinIndexedVector & regionSparseFT)
176  { return coinAbcFactorization_->updateColumnFT(regionSparseFT);}
177  inline int updateColumnFTPart1 ( CoinIndexedVector & regionSparseFT)
178  { return coinAbcFactorization_->updateColumnFTPart1(regionSparseFT);}
179  inline void updateColumnFTPart2 ( CoinIndexedVector & regionSparseFT)
180  { coinAbcFactorization_->updateColumnFTPart2(regionSparseFT);}
184  inline void updateColumnFT ( CoinIndexedVector & regionSparseFT,
185  CoinIndexedVector & partialUpdate,
186  int which)
187  { coinAbcFactorization_->updateColumnFT(regionSparseFT,partialUpdate,which);}
189  inline int updateColumn ( CoinIndexedVector & regionSparse) const
190  { return coinAbcFactorization_->updateColumn(regionSparse);}
195  inline int updateTwoColumnsFT ( CoinIndexedVector & regionSparseFT,
196  CoinIndexedVector & regionSparseOther)
197  { return coinAbcFactorization_->updateTwoColumnsFT(regionSparseFT,regionSparseOther);}
199  inline int updateColumnTranspose ( CoinIndexedVector & regionSparse) const
200  { return coinAbcFactorization_->updateColumnTranspose(regionSparse);}
202  inline void updateColumnCpu ( CoinIndexedVector & regionSparse,int whichCpu) const
203  { coinAbcFactorization_->updateColumnCpu(regionSparse,whichCpu);}
205  inline void updateColumnTransposeCpu ( CoinIndexedVector & regionSparse,int whichCpu) const
206  { coinAbcFactorization_->updateColumnTransposeCpu(regionSparse,whichCpu);}
208  inline void updateFullColumn ( CoinIndexedVector & regionSparse) const
209  { coinAbcFactorization_->updateFullColumn(regionSparse);}
211  inline void updateFullColumnTranspose ( CoinIndexedVector & regionSparse) const
212  { coinAbcFactorization_->updateFullColumnTranspose(regionSparse);}
214  void updateWeights ( CoinIndexedVector & regionSparse) const
215  { coinAbcFactorization_->updateWeights(regionSparse);}
217 
219  inline int numberElements ( ) const {
221  return coinAbcFactorization_->numberElements() ;
222  }
224  inline int maximumPivots ( ) const {
225  return coinAbcFactorization_->maximumPivots() ;
226  }
228  inline void maximumPivots ( int value) {
229  coinAbcFactorization_->maximumPivots(value);
230  }
232  inline bool usingFT() const
233  { return !coinAbcFactorization_->wantsTableauColumn();}
235  inline int pivots ( ) const {
236  return coinAbcFactorization_->pivots() ;
237  }
239  inline void setPivots ( int value ) const {
240  coinAbcFactorization_->setPivots(value) ;
241  }
243  inline double areaFactor ( ) const {
244  return coinAbcFactorization_->areaFactor() ;
245  }
247  inline void areaFactor ( double value) {
248  coinAbcFactorization_->areaFactor(value);
249  }
251  inline double zeroTolerance ( ) const {
252  return coinAbcFactorization_->zeroTolerance() ;
253  }
255  inline void zeroTolerance ( double value) {
256  coinAbcFactorization_->zeroTolerance(value);
257  }
259  void saferTolerances ( double zeroTolerance, double pivotTolerance);
261  inline int status ( ) const {
262  return coinAbcFactorization_->status() ;
263  }
265  inline void setStatus ( int value) {
266  coinAbcFactorization_->setStatus(value) ;
267  }
268 #if ABC_PARALLEL==2
269  inline void setParallelMode(int value)
271  {coinAbcFactorization_->setParallelMode(value);};
272 #endif
273  inline int numberDense() const {
275  return coinAbcFactorization_->numberDense() ;
276  }
277  inline bool timeToRefactorize() const {
278  return coinAbcFactorization_->pivots() > coinAbcFactorization_->numberRows() / 2.45 + 20;
279  }
281  inline void clearArrays() {
282  coinAbcFactorization_->clearArrays();
283  }
285  inline int numberRows ( ) const {
286  return coinAbcFactorization_->numberRows() ;
287  }
289  inline int numberSlacks() const
290  { return numberSlacks_;}
292  inline double pivotTolerance ( ) const {
293  return coinAbcFactorization_->pivotTolerance();
294  }
296  inline void pivotTolerance ( double value) {
297  coinAbcFactorization_->pivotTolerance(value);
298  }
300  inline double minimumPivotTolerance ( ) const {
301  return coinAbcFactorization_->minimumPivotTolerance();
302  }
304  inline void minimumPivotTolerance ( double value) {
305  coinAbcFactorization_->minimumPivotTolerance(value);
306  }
308  inline double * pivotRegion() const
309  { return coinAbcFactorization_->pivotRegion();}
311  //inline void relaxAccuracyCheck(double /*value*/) {
312  //abort();
313  //}
315  inline void almostDestructor() {
316  coinAbcFactorization_->clearArrays();
317  }
319  void setDenseThreshold(int number);
320  int getDenseThreshold() const;
322  void forceOtherFactorization(int which);
324  void goDenseOrSmall(int numberRows);
326  inline int goDenseThreshold() const {
327  return goDenseThreshold_;
328  }
330  inline void setGoDenseThreshold(int value) {
331  goDenseThreshold_ = value;
332  }
334  inline int goSmallThreshold() const {
335  return goSmallThreshold_;
336  }
338  inline void setGoSmallThreshold(int value) {
339  goSmallThreshold_ = value;
340  }
342  inline int goLongThreshold() const {
343  return goLongThreshold_;
344  }
346  inline void setGoLongThreshold(int value) {
347  goLongThreshold_ = value;
348  }
350  inline int typeOfFactorization() const
351  { return forceB_;}
353  void synchronize(const ClpFactorization * otherFactorization,const AbcSimplex * model);
355 
359  void goSparse();
360 #ifndef NDEBUG
361  inline void checkMarkArrays() const
362  { coinAbcFactorization_->checkMarkArrays();}
363 #endif
364  inline bool needToReorder() const {abort();return true;}
368  { return coinAbcFactorization_;}
370 
372 private:
373 
376  AbcSimplex * model_;
379  CoinAbcAnyFactorization * coinAbcFactorization_;
381  int forceB_;
383  int goDenseThreshold_;
385  int goSmallThreshold_;
387  int goLongThreshold_;
389  int numberSlacks_;
391 };
392 
393 #endif
double zeroTolerance() const
Zero tolerance.
int numberDense() const
Returns number of dense rows.
void setGoLongThreshold(int value)
Set switch to long/ordered if number rows >= this.
void updateColumnFT(CoinIndexedVector &regionSparseFT, CoinIndexedVector &partialUpdate, int which)
Updates one column (FTRAN) Tries to do FT update puts partial update in vector.
void areaFactor(double value)
Set whether larger areas needed.
This just implements AbcFactorization when an AbcMatrix object is passed.
void setPivots(int value) const
Sets number of pivots since factorization.
virtual double checkReplacePart1(CoinIndexedVector *, int)
Checks if can replace one Column to basis, returns update alpha Fills in region for use later partial...
int updateColumn(CoinIndexedVector &regionSparse) const
Updates one column (FTRAN)
void synchronize(const ClpFactorization *otherFactorization, const AbcSimplex *model)
Synchronize stuff.
double * pivotRegion() const
pivot region
Abstract base class which also has some scalars so can be used from Dense or Simp.
~AbcSimplexFactorization()
Destructor.
void updateColumnTransposeCpu(CoinIndexedVector &regionSparse, int whichCpu) const
Updates one column (BTRAN)
virtual void updateFullColumnTranspose(CoinIndexedVector &regionSparse) const =0
Updates one column (BTRAN) from unpacked regionSparse.
virtual int updateColumnFTPart1(CoinIndexedVector &regionSparse)=0
void saferTolerances(double zeroTolerance, double pivotTolerance)
Set tolerances to safer of existing and given.
virtual int updateColumnTranspose(CoinIndexedVector &regionSparse) const =0
Updates one column (BTRAN) from unpacked regionSparse.
double areaFactor() const
Area factor.
int factorize(AbcSimplex *model, int solveType, bool valuesPass)
When part of LP - given by basic variables.
virtual void updateFullColumn(CoinIndexedVector &regionSparse) const =0
This version does FTRAN on array when indices not set up.
AbcSimplexFactorization & operator=(const AbcSimplexFactorization &)
double checkReplacePart1b(CoinIndexedVector *regionSparse, int pivotRow)
int goSmallThreshold() const
Get switch to small if number rows <= this.
This just implements CoinFactorization when an ClpMatrixBase object is passed.
virtual int updateTwoColumnsFT(CoinIndexedVector &regionFT, CoinIndexedVector &regionOther)=0
does FTRAN on two unpacked columns
int updateTwoColumnsFT(CoinIndexedVector &regionSparseFT, CoinIndexedVector &regionSparseOther)
Updates one column (FTRAN) from regionFT Tries to do FT update number returned is negative if no room...
int numberRows() const
Number of Rows after factorization.
int updateColumnFTPart1(CoinIndexedVector &regionSparseFT)
virtual CoinFactorizationDouble * pivotRegion() const
AbcSimplexFactorization(int numberRows=0)
Default constructor.
void setStatus(int value)
Sets status.
int status() const
Returns status.
double checkReplacePart1(CoinIndexedVector *regionSparse, CoinIndexedVector *partialUpdate, int pivotRow)
Checks if can replace one Column to basis, returns update alpha Fills in region for use later partial...
int updateColumnFT(CoinIndexedVector &regionSparseFT)
Updates one column (FTRAN) Tries to do FT update number returned is negative if no room...
virtual void updateColumnCpu(CoinIndexedVector &regionSparse, int whichCpu) const
Updates one column (FTRAN)
double pivotTolerance() const
Pivot tolerance.
void zeroTolerance(double value)
Set zero tolerance.
virtual int updateColumnFT(CoinIndexedVector &regionSparse)=0
Updates one column (FTRAN) from unpacked regionSparse Tries to do FT update number returned is negati...
void pivotTolerance(double value)
Set pivot tolerance.
double pivotTolerance() const
Pivot tolerance.
int goLongThreshold() const
Get switch to long/ordered if number rows >= this.
void checkReplacePart1a(CoinIndexedVector *regionSparse, int pivotRow)
Checks if can replace one Column to basis, returns update alpha Fills in region for use later partial...
void updateFullColumn(CoinIndexedVector &regionSparse) const
Updates one full column (FTRAN)
int checkReplacePart2(int pivotRow, double btranAlpha, double ftranAlpha, double ftAlpha)
Checks if can replace one Column to basis, returns 0=OK, 1=Probably OK, 2=singular, 3=no room, 5 max pivots.
int numberSlacks() const
Number of slacks at last factorization.
CoinSimplexInt numberDense() const
Number of dense rows after factorization.
void updateWeights(CoinIndexedVector &regionSparse) const
Updates one column for dual steepest edge weights (FTRAN)
int pivots() const
Returns number of pivots since factorization.
void clearArrays()
Get rid of all memory.
double zeroTolerance() const
Zero tolerance.
void updateFullColumnTranspose(CoinIndexedVector &regionSparse) const
Updates one full column (BTRAN)
int goDenseThreshold() const
Get switch to dense if number rows <= this.
void setFactorization(AbcSimplexFactorization &rhs)
Sets factorization.
void maximumPivots(int value)
Set maximum number of pivots between factorizations.
void goSparse()
makes a row copy of L for speed and to allow very sparse problems
void setStatus(int value)
Sets status.
virtual void updateColumnTransposeCpu(CoinIndexedVector &regionSparse, int whichCpu) const
Updates one column (BTRAN)
void forceOtherFactorization(int which)
If nonzero force use of 1,dense 2,small 3,long.
void updateColumnCpu(CoinIndexedVector &regionSparse, int whichCpu) const
Updates one column (FTRAN)
CoinAbcAnyFactorization * factorization() const
Pointer to factorization.
virtual int updateColumn(CoinIndexedVector &regionSparse) const =0
This version has same effect as above with FTUpdate==false so number returned is always >=0...
virtual void checkReplacePart1a(CoinIndexedVector *, int)
virtual int numberElements() const =0
Total number of elements in factorization.
void replaceColumnPart3(const AbcSimplex *model, CoinIndexedVector *regionSparse, CoinIndexedVector *tableauColumn, int pivotRow, double alpha)
Replaces one Column to basis, partial update already in U.
int typeOfFactorization() const
Returns type.
void setPivots(int value)
Sets number of pivots since factorization.
double minimumPivotTolerance() const
Minimum pivot tolerance.
virtual bool wantsTableauColumn() const
Returns true if wants tableauColumn in replaceColumn.
double areaFactor() const
Whether larger areas needed.
double minimumPivotTolerance() const
Minimum pivot tolerance.
int getDenseThreshold() const
int numberRows() const
Number of Rows after factorization.
void setGoSmallThreshold(int value)
Set switch to small if number rows <= this.
virtual double checkReplacePart1b(CoinIndexedVector *, int)
virtual void updateWeights(CoinIndexedVector &regionSparse) const =0
Updates one column for dual steepest edge weights (FTRAN)
void almostDestructor()
Allows change of pivot accuracy check 1.0 == none >1.0 relaxed.
virtual int checkReplacePart2(int pivotRow, double btranAlpha, double ftranAlpha, double ftAlpha, double acceptablePivot=1.0e-8)=0
Checks if can replace one Column to basis, returns 0=OK, 1=Probably OK, 2=singular, 3=no room, 5 max pivots.
bool usingFT() const
Returns true if doing FT.
int pivots() const
Returns number of pivots since factorization.
int updateColumnTranspose(CoinIndexedVector &regionSparse) const
Updates one column (BTRAN)
double checkReplacePart1(CoinIndexedVector *regionSparse, int pivotRow)
Checks if can replace one Column to basis, returns update alpha Fills in region for use later partial...
void setGoDenseThreshold(int value)
Set switch to dense if number rows <= this.
void setDenseThreshold(int number)
So we can temporarily switch off dense.
int numberElements() const
Total number of elements in factorization.
int status() const
Returns status.
int maximumPivots() const
Maximum number of pivots between factorizations.
void minimumPivotTolerance(double value)
Set minimum pivot tolerance.
void goDenseOrSmall(int numberRows)
Go over to dense code.
virtual void checkMarkArrays() const
virtual void clearArrays()
Get rid of all memory.
int maximumPivots() const
Maximum number of pivots between factorizations.
void updateColumnFTPart2(CoinIndexedVector &regionSparseFT)
bool needToReorder() const
Says whether to redo pivot order.
virtual void updateColumnFTPart2(CoinIndexedVector &regionSparse)=0