Cbc  2.9.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AbcSimplexFactorization.hpp
Go to the documentation of this file.
1 /* $Id: AbcSimplexFactorization.hpp 2078 2015-01-05 12:39:49Z forrest $ */
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 #ifndef ABC_USE_COIN_FACTORIZATION
18 class ClpFactorization;
19 class CoinFactorization;
20 #else
21 #include "ClpFactorization.hpp"
22 #include "CoinFactorization.hpp"
23 #endif
24 
28 {
29 
30 public:
42  int factorize (AbcSimplex * model, int solveType, bool valuesPass);
43 #ifdef EARLY_FACTORIZE
44  inline int factorize (AbcSimplex * model, CoinIndexedVector & stuff)
46  { return coinAbcFactorization_->factorize(model,stuff);}
47 #endif
48 
49 
50 
58 
62  AbcSimplexFactorization(const AbcSimplexFactorization&, int denseIfSmaller = 0);
67 
68  /* **** below here is so can use networkish basis */
71 
76  inline
77 #ifdef ABC_LONG_FACTORIZATION
78  long
79 #endif
80  double checkReplacePart1 ( CoinIndexedVector * regionSparse,
81  int pivotRow)
82  {return coinAbcFactorization_->checkReplacePart1(regionSparse,pivotRow);}
87  inline
88 #ifdef ABC_LONG_FACTORIZATION
89  long
90 #endif
91  double checkReplacePart1 ( CoinIndexedVector * regionSparse,
92  CoinIndexedVector * partialUpdate,
93  int pivotRow)
94  {return coinAbcFactorization_->checkReplacePart1(regionSparse,partialUpdate,pivotRow);}
95 #ifdef MOVE_REPLACE_PART1A
96 
100  inline void checkReplacePart1a ( CoinIndexedVector * regionSparse,
101  int pivotRow)
102  {coinAbcFactorization_->checkReplacePart1a(regionSparse,pivotRow);}
103  inline double checkReplacePart1b (CoinIndexedVector * regionSparse,
104  int pivotRow)
105  {return coinAbcFactorization_->checkReplacePart1b(regionSparse,pivotRow);}
106 #endif
107 
109  inline int checkReplacePart2 ( int pivotRow,
110  double btranAlpha,
111  double ftranAlpha,
112 #ifdef ABC_LONG_FACTORIZATION
113  long
114 #endif
115  double ftAlpha)
116  {return coinAbcFactorization_->checkReplacePart2(pivotRow,btranAlpha,ftranAlpha,ftAlpha);}
117 #ifdef ABC_LONG_FACTORIZATION
118  inline void clearHiddenArrays()
120  { coinAbcFactorization_->clearHiddenArrays();}
121 #endif
122 
124  void replaceColumnPart3 ( const AbcSimplex * model,
125  CoinIndexedVector * regionSparse,
126  CoinIndexedVector * tableauColumn,
127  int pivotRow,
128 #ifdef ABC_LONG_FACTORIZATION
129  long
130 #endif
131  double alpha );
134  void replaceColumnPart3 ( const AbcSimplex * model,
135  CoinIndexedVector * regionSparse,
136  CoinIndexedVector * tableauColumn,
137  CoinIndexedVector * partialUpdate,
138  int pivotRow,
139 #ifdef ABC_LONG_FACTORIZATION
140  long
141 #endif
142  double alpha );
143 #ifdef EARLY_FACTORIZE
144  inline int replaceColumns ( const AbcSimplex * model,
146  CoinIndexedVector & stuff,
147  int firstPivot,int lastPivot,bool cleanUp)
148  { return coinAbcFactorization_->replaceColumns(model,stuff,firstPivot,lastPivot,cleanUp);}
149 #endif
150 
151 
155 #if 0
156 
160  int updateColumnFT ( CoinIndexedVector * regionSparse,
161  CoinIndexedVector * regionSparse2);
164  int updateColumn ( CoinIndexedVector * regionSparse,
165  CoinIndexedVector * regionSparse2) const;
171  int updateTwoColumnsFT ( CoinIndexedVector * regionSparse1,
172  CoinIndexedVector * regionSparse2,
173  CoinIndexedVector * regionSparse3) ;
176  int updateColumnTranspose ( CoinIndexedVector * regionSparse,
177  CoinIndexedVector * regionSparse2) const;
178 #endif
179 
182  inline int updateColumnFT ( CoinIndexedVector & regionSparseFT)
183  { return coinAbcFactorization_->updateColumnFT(regionSparseFT);}
184  inline int updateColumnFTPart1 ( CoinIndexedVector & regionSparseFT)
185  { return coinAbcFactorization_->updateColumnFTPart1(regionSparseFT);}
186  inline void updateColumnFTPart2 ( CoinIndexedVector & regionSparseFT)
187  { coinAbcFactorization_->updateColumnFTPart2(regionSparseFT);}
191  inline void updateColumnFT ( CoinIndexedVector & regionSparseFT,
192  CoinIndexedVector & partialUpdate,
193  int which)
194  { coinAbcFactorization_->updateColumnFT(regionSparseFT,partialUpdate,which);}
196  inline int updateColumn ( CoinIndexedVector & regionSparse) const
197  { return coinAbcFactorization_->updateColumn(regionSparse);}
202  inline int updateTwoColumnsFT ( CoinIndexedVector & regionSparseFT,
203  CoinIndexedVector & regionSparseOther)
204  { return coinAbcFactorization_->updateTwoColumnsFT(regionSparseFT,regionSparseOther);}
206  inline int updateColumnTranspose ( CoinIndexedVector & regionSparse) const
207  { return coinAbcFactorization_->updateColumnTranspose(regionSparse);}
209  inline void updateColumnCpu ( CoinIndexedVector & regionSparse,int whichCpu) const
210 #ifndef ABC_USE_COIN_FACTORIZATION
211  { coinAbcFactorization_->updateColumnCpu(regionSparse,whichCpu);}
212 #else
213  { coinAbcFactorization_->updateColumn(regionSparse);}
214 #endif
215 
216  inline void updateColumnTransposeCpu ( CoinIndexedVector & regionSparse,int whichCpu) const
217 #ifndef ABC_USE_COIN_FACTORIZATION
218  { coinAbcFactorization_->updateColumnTransposeCpu(regionSparse,whichCpu);}
219 #else
221 #endif
222 
223  inline void updateFullColumn ( CoinIndexedVector & regionSparse) const
224  { coinAbcFactorization_->updateFullColumn(regionSparse);}
226  inline void updateFullColumnTranspose ( CoinIndexedVector & regionSparse) const
229  void updateWeights ( CoinIndexedVector & regionSparse) const
230 #ifndef ABC_USE_COIN_FACTORIZATION
231  { coinAbcFactorization_->updateWeights(regionSparse);}
232 #else
233  { coinAbcFactorization_->updateColumn(regionSparse);}
234 #endif
235 
236 
238  inline int numberElements ( ) const {
241  }
243  inline int maximumPivots ( ) const {
245  }
247  inline void maximumPivots ( int value) {
249  }
251  inline bool usingFT() const
254  inline int pivots ( ) const {
255  return coinAbcFactorization_->pivots() ;
256  }
258  inline void setModel(AbcSimplex * model)
259  {model_ = model;}
261  inline void setPivots ( int value ) const {
263  }
265  inline double areaFactor ( ) const {
267  }
269  inline void areaFactor ( double value) {
271  }
273  inline double zeroTolerance ( ) const {
275  }
277  inline void zeroTolerance ( double value) {
279  }
281  void saferTolerances ( double zeroTolerance, double pivotTolerance);
283  inline int status ( ) const {
284  return coinAbcFactorization_->status() ;
285  }
287  inline void setStatus ( int value) {
289  }
290 #if ABC_PARALLEL==2
291  inline void setParallelMode(int value)
293  {coinAbcFactorization_->setParallelMode(value);};
294 #endif
295  inline int numberDense() const {
298  }
299  bool timeToRefactorize() const;
300 #if CLP_FACTORIZATION_NEW_TIMING>1
301  void statsRefactor(char when) const;
302 #endif
303  inline void clearArrays() {
306  }
308  inline int numberRows ( ) const {
310  }
312  inline int numberSlacks() const
313  { return numberSlacks_;}
315  inline double pivotTolerance ( ) const {
317  }
319  inline void pivotTolerance ( double value) {
321  }
323  inline double minimumPivotTolerance ( ) const {
325  }
327  inline void minimumPivotTolerance ( double value) {
329  }
331  inline double * pivotRegion() const
332  { return coinAbcFactorization_->pivotRegion();}
334  //inline void relaxAccuracyCheck(double /*value*/) {
335  //abort();
336  //}
338  inline void almostDestructor() {
340  }
342  void setDenseThreshold(int number);
343  int getDenseThreshold() const;
345  void forceOtherFactorization(int which);
347  void goDenseOrSmall(int numberRows);
349  inline int goDenseThreshold() const {
350  return goDenseThreshold_;
351  }
353  inline void setGoDenseThreshold(int value) {
354  goDenseThreshold_ = value;
355  }
357  inline int goSmallThreshold() const {
358  return goSmallThreshold_;
359  }
361  inline void setGoSmallThreshold(int value) {
362  goSmallThreshold_ = value;
363  }
365  inline int goLongThreshold() const {
366  return goLongThreshold_;
367  }
369  inline void setGoLongThreshold(int value) {
370  goLongThreshold_ = value;
371  }
373  inline int typeOfFactorization() const
374  { return forceB_;}
376  void synchronize(const ClpFactorization * otherFactorization,const AbcSimplex * model);
378 
382  void goSparse();
383 #ifndef NDEBUG
384 #ifndef ABC_USE_COIN_FACTORIZATION
385  inline void checkMarkArrays() const
387 #else
388  inline void checkMarkArrays() const
389  { }
390 #endif
391 #endif
392  inline bool needToReorder() const {abort();return true;}
395 #ifndef ABC_USE_COIN_FACTORIZATION
397  { return coinAbcFactorization_;}
398 #else
400  { return coinAbcFactorization_;}
401 #endif
402 
403 
405 private:
406 
409  AbcSimplex * model_;
412 #ifndef ABC_USE_COIN_FACTORIZATION
414 #else
416 #endif
417 #ifdef CLP_FACTORIZATION_NEW_TIMING
418  mutable double shortestAverage_;
420  mutable double totalInR_;
421  mutable double totalInIncreasingU_;
422  mutable int endLengthU_;
423  mutable int lastNumberPivots_;
424  mutable int effectiveStartNumberU_;
425 #endif
426  int forceB_;
437 };
438 
439 #endif
bool timeToRefactorize() const
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
int goLongThreshold_
Switch to long/ordered if number rows >= this.
int numberSlacks_
Number of slacks at last factorization.
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 &)
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 updateFullColumn(CoinIndexedVector &regionSparse) const
Updates one full column (FTRAN)
Indexed Vector.
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 setModel(AbcSimplex *model)
Sets model.
int forceB_
If nonzero force use of 1,dense 2,small 3,long.
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.
int goSmallThreshold_
Switch to small if number rows <= this.
void setGoSmallThreshold(int value)
Set switch to small if number rows <= this.
This deals with Factorization and Updates.
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 goDenseThreshold_
Switch to dense if number rows <= this.
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.
CoinAbcAnyFactorization * coinAbcFactorization_
Pointer to factorization.
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
AbcSimplex * model_
Pointer to model.