ClpFactorization.hpp
Go to the documentation of this file.
1 /* $Id: ClpFactorization.hpp 2078 2015-01-05 12:39:49Z forrest $ */
2 // Copyright (C) 2002, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 // This code is licensed under the terms of the Eclipse Public License (EPL).
5 
6 #ifndef ClpFactorization_H
7 #define ClpFactorization_H
8 
9 
10 #include "CoinPragma.hpp"
11 
12 #include "CoinFactorization.hpp"
13 class ClpMatrixBase;
14 class ClpSimplex;
15 class ClpNetworkBasis;
17 #ifndef CLP_MULTIPLE_FACTORIZATIONS
18 #define CLP_MULTIPLE_FACTORIZATIONS 4
19 #endif
20 #ifdef CLP_MULTIPLE_FACTORIZATIONS
22 #include "ClpSimplex.hpp"
23 #endif
24 #ifndef COIN_FAST_CODE
25 #define COIN_FAST_CODE
26 #endif
27 #ifndef CLP_FACTORIZATION_NEW_TIMING
28 #define CLP_FACTORIZATION_NEW_TIMING 1
29 #endif
30 
37  : public CoinFactorization
38 #endif
39 {
40 
41  //friend class CoinFactorization;
42 
43 public:
55  int factorize (ClpSimplex * model, int solveType, bool valuesPass);
57 
58 
66 
72  ClpFactorization(const ClpFactorization&, int denseIfSmaller = 0);
73 #ifdef CLP_MULTIPLE_FACTORIZATIONS
74 
76 #endif
79 
80  /* **** below here is so can use networkish basis */
83 
91  int replaceColumn ( const ClpSimplex * model,
92  CoinIndexedVector * regionSparse,
93  CoinIndexedVector * tableauColumn,
94  int pivotRow,
95  double pivotCheck ,
96  bool checkBeforeModifying = false,
97  double acceptablePivot = 1.0e-8);
99 
107  int updateColumnFT ( CoinIndexedVector * regionSparse,
108  CoinIndexedVector * regionSparse2);
111  int updateColumn ( CoinIndexedVector * regionSparse,
112  CoinIndexedVector * regionSparse2,
113  bool noPermute = false) const;
119  int updateTwoColumnsFT ( CoinIndexedVector * regionSparse1,
120  CoinIndexedVector * regionSparse2,
121  CoinIndexedVector * regionSparse3,
122  bool noPermuteRegion3 = false) ;
124  int updateColumnForDebug ( CoinIndexedVector * regionSparse,
125  CoinIndexedVector * regionSparse2,
126  bool noPermute = false) const;
129  int updateColumnTranspose ( CoinIndexedVector * regionSparse,
130  CoinIndexedVector * regionSparse2) const;
132 #ifdef CLP_MULTIPLE_FACTORIZATIONS
133 
135  inline int numberElements ( ) const {
138  else return coinFactorizationB_->numberElements() ;
139  }
141  inline int *permute ( ) const {
143  else return coinFactorizationB_->permute() ;
144  }
146  inline int *pivotColumn ( ) const {
148  else return coinFactorizationB_->permute() ;
149  }
151  inline int maximumPivots ( ) const {
153  else return coinFactorizationB_->maximumPivots() ;
154  }
156  inline void maximumPivots ( int value) {
158  else coinFactorizationB_->maximumPivots(value);
159  }
161  inline int pivots ( ) const {
163  else return coinFactorizationB_->pivots() ;
164  }
166  inline double areaFactor ( ) const {
168  else return 0.0 ;
169  }
171  inline void areaFactor ( double value) {
173  }
175  inline double zeroTolerance ( ) const {
177  else return coinFactorizationB_->zeroTolerance() ;
178  }
180  inline void zeroTolerance ( double value) {
182  else coinFactorizationB_->zeroTolerance(value);
183  }
185  void saferTolerances ( double zeroTolerance, double pivotTolerance);
187  inline int sparseThreshold ( ) const {
189  else return 0 ;
190  }
192  inline void sparseThreshold ( int value) {
194  }
196  inline int status ( ) const {
198  else return coinFactorizationB_->status() ;
199  }
201  inline void setStatus ( int value) {
203  else coinFactorizationB_->setStatus(value) ;
204  }
206  inline int numberDense() const {
208  else return 0 ;
209  }
210 #if 1
211  inline CoinBigIndex numberElementsU ( ) const {
214  else return -1 ;
215  }
217  inline CoinBigIndex numberElementsL ( ) const {
219  else return -1 ;
220  }
222  inline CoinBigIndex numberElementsR ( ) const {
224  else return 0 ;
225  }
226 #endif
227  bool timeToRefactorize() const;
228 #if CLP_FACTORIZATION_NEW_TIMING>1
229  void statsRefactor(char when) const;
230 #endif
231  inline int messageLevel ( ) const {
234  else return 1 ;
235  }
237  inline void messageLevel ( int value) {
239  }
241  inline void clearArrays() {
244  else if (coinFactorizationB_)
246  }
248  inline int numberRows ( ) const {
250  else return coinFactorizationB_->numberRows() ;
251  }
253  inline int denseThreshold() const {
255  else return 0 ;
256  }
258  inline void setDenseThreshold(int value) {
260  }
262  inline double pivotTolerance ( ) const {
265  return 1.0e-8 ;
266  }
268  inline void pivotTolerance ( double value) {
271  }
273  inline void relaxAccuracyCheck(double value) {
275  }
281  inline int persistenceFlag() const {
283  else return 0 ;
284  }
285  inline void setPersistenceFlag(int value) {
287  }
289  inline void almostDestructor() {
292  else if (coinFactorizationB_)
294  }
296  inline double adjustedAreaFactor() const {
298  else return 0.0 ;
299  }
300  inline void setBiasLU(int value) {
302  }
304  inline void setForrestTomlin(bool value) {
306  }
308  inline void setDefaultValues() {
309  if (coinFactorizationA_) {
310  // row activities have negative sign
311 #ifndef COIN_FAST_CODE
313 #endif
315  }
316  }
318  void forceOtherFactorization(int which);
320  inline int goOslThreshold() const {
321  return goOslThreshold_;
322  }
324  inline void setGoOslThreshold(int value) {
325  goOslThreshold_ = value;
326  }
328  inline int goDenseThreshold() const {
329  return goDenseThreshold_;
330  }
332  inline void setGoDenseThreshold(int value) {
333  goDenseThreshold_ = value;
334  }
336  inline int goSmallThreshold() const {
337  return goSmallThreshold_;
338  }
340  inline void setGoSmallThreshold(int value) {
341  goSmallThreshold_ = value;
342  }
344  void goDenseOrSmall(int numberRows) ;
346  void setFactorization(ClpFactorization & factorization);
348  inline int isDenseOrSmall() const {
349  return coinFactorizationB_ ? 1 : 0;
350  }
351 #else
352  inline bool timeToRefactorize() const {
353  return (pivots() * 3 > maximumPivots() * 2 &&
354  numberElementsR() * 3 > (numberElementsL() + numberElementsU()) * 2 + 1000 &&
355  !numberDense());
356  }
358  inline void setDefaultValues() {
359  // row activities have negative sign
360 #ifndef COIN_FAST_CODE
361  slackValue(-1.0);
362 #endif
363  zeroTolerance(1.0e-13);
364  }
366  inline void goDense() {}
367 #endif
368 
369 
373  void goSparse();
375  void cleanUp();
377  bool needToReorder() const;
378 #ifndef SLIM_CLP
379  inline bool networkBasis() const {
381  return (networkBasis_ != NULL);
382  }
383 #else
384  inline bool networkBasis() const {
386  return false;
387  }
388 #endif
389  void getWeights(int * weights) const;
392 
394 private:
395 
398 #ifndef SLIM_CLP
401 #endif
402 #ifdef CLP_MULTIPLE_FACTORIZATIONS
407 #ifdef CLP_REUSE_ETAS
408  ClpSimplex * model_;
410 #endif
411  int forceB_;
419 #endif
420 #ifdef CLP_FACTORIZATION_NEW_TIMING
421  mutable double shortestAverage_;
423  mutable double totalInR_;
424  mutable double totalInIncreasingU_;
425  mutable int endLengthU_;
426  mutable int lastNumberPivots_;
428 #endif
429 
430 };
431 
432 #endif
int CoinBigIndex
double slackValue() const
Whether slack value is +1 or -1.
void forceOtherFactorization(int which)
If nonzero force use of 1,dense 2,small 3,osl.
virtual int * permute() const =0
Returns permute in.
int pivots() const
Returns number of pivots since factorization.
double totalInIncreasingU_
Pointer to network basis.
int numberDense() const
Returns number of dense rows.
int updateColumnTranspose(CoinIndexedVector *regionSparse, CoinIndexedVector *regionSparse2) const
Updates one column (BTRAN) from region2 region1 starts as zero and is zero at end.
CoinBigIndex numberElementsU() const
Returns number in U area.
int goSmallThreshold() const
Get switch to small if number rows <= this.
int factorize(ClpSimplex *model, int solveType, bool valuesPass)
When part of LP - given by basic variables.
bool networkBasis() const
Says if a network basis.
void almostDestructor()
Delete all stuff (leaves as after CoinFactorization())
void setBiasLU(int value)
Returns number of dense rows.
~ClpFactorization()
Destructor.
bool needToReorder() const
Says whether to redo pivot order.
int persistenceFlag() const
Array persistence flag If 0 then as now (delete/new) 1 then only do arrays if bigger needed 2 as 1 bu...
void clearArrays()
Get rid of all memory.
int * pivotColumn() const
Returns address of pivotColumn region (also used for permuting)
int updateColumn(CoinIndexedVector *regionSparse, CoinIndexedVector *regionSparse2, bool noPermute=false) const
Updates one column (FTRAN) from region2 region1 starts as zero and is zero at end.
int numberElements() const
Total number of elements in factorization.
void setStatus(int value)
Sets status.
int updateColumnForDebug(CoinIndexedVector *regionSparse, CoinIndexedVector *regionSparse2, bool noPermute=false) const
For debug (no statistics update)
double adjustedAreaFactor() const
Returns areaFactor but adjusted for dense.
void setPersistenceFlag(int value)
Total number of elements in factorization.
Abstract base class which also has some scalars so can be used from Dense or Simp.
void zeroTolerance(double value)
Set zero tolerance.
int sparseThreshold() const
get sparse threshold
ClpNetworkBasis * networkBasis_
Pointer to network basis.
int status() const
Returns status.
void setPersistenceFlag(int value)
Returns number of dense rows.
CoinBigIndex numberElementsL() const
Returns number in L area.
void setStatus(int value)
Sets status.
CoinBigIndex numberElementsR() const
Returns number in R area.
CoinBigIndex numberElementsR() const
Returns number in R area.
#define CLP_MULTIPLE_FACTORIZATIONS
double adjustedAreaFactor() const
Returns areaFactor but adjusted for dense.
ClpFactorization()
Default constructor.
This deals with Factorization and Updates for network structures.
CoinOtherFactorization * coinFactorizationB_
Pointer to CoinOtherFactorization.
bool timeToRefactorize() const
Total number of elements in factorization.
int * permute() const
Returns address of permute region.
CoinBigIndex numberElementsU() const
Returns number in U area.
int maximumPivots() const
Maximum number of pivots between factorizations.
int goDenseThreshold() const
Get switch to dense if number rows <= this.
int numberRows() const
Number of Rows after factorization.
double zeroTolerance() const
Zero tolerance.
int persistenceFlag() const
Array persistence flag If 0 then as now (delete/new) 1 then only do arrays if bigger needed 2 as 1 bu...
ClpFactorization & operator=(const ClpFactorization &)
The copy constructor from an CoinFactorization.
int denseThreshold() const
Gets dense threshold.
void setFactorization(ClpFactorization &factorization)
Sets factorization.
double pivotTolerance() const
Pivot tolerance.
int maximumPivots() const
Maximum number of pivots between factorizations.
double zeroTolerance() const
Zero tolerance.
int endLengthU_
Pointer to network basis.
void clearArrays()
Get rid of all memory.
void saferTolerances(double zeroTolerance, double pivotTolerance)
Set tolerances to safer of existing and given.
double pivotTolerance() const
Pivot tolerance.
void cleanUp()
Cleans up i.e. gets rid of network basis.
double shortestAverage_
For guessing when to re-factorize.
void pivotTolerance(double value)
Set pivot tolerance.
double areaFactor() const
Whether larger areas needed.
void setForrestTomlin(bool value)
true if Forrest Tomlin update, false if PFI
int * permute() const
Returns address of permute region.
int goSmallThreshold_
Switch to small if number rows <= this.
Indexed Vector.
void setGoOslThreshold(int value)
Set switch to osl if number rows <= this.
int numberElements() const
Total number of elements in factorization.
void setGoSmallThreshold(int value)
Set switch to small if number rows <= this.
This solves LPs using the simplex method.
Definition: ClpSimplex.hpp:70
void sparseThreshold(int value)
Set sparse threshold.
int updateTwoColumnsFT(CoinIndexedVector *regionSparse1, CoinIndexedVector *regionSparse2, CoinIndexedVector *regionSparse3, bool noPermuteRegion3=false)
Updates one column (FTRAN) from region2 Tries to do FT update number returned is negative if no room...
int goOslThreshold() const
Get switch to osl if number rows <= this.
int maximumPivots() const
Maximum number of pivots between factorizations.
void setGoDenseThreshold(int value)
Set switch to dense if number rows <= this.
int updateColumnFT(CoinIndexedVector *regionSparse, CoinIndexedVector *regionSparse2)
Updates one column (FTRAN) from region2 Tries to do FT update number returned is negative if no room ...
Abstract base class for Clp Matrices.
double totalInR_
Pointer to network basis.
int numberDense() const
Returns number of dense rows.
void setDefaultValues()
Sets default values.
int replaceColumn(const ClpSimplex *model, CoinIndexedVector *regionSparse, CoinIndexedVector *tableauColumn, int pivotRow, double pivotCheck, bool checkBeforeModifying=false, double acceptablePivot=1.0e-8)
Replaces one Column to basis, returns 0=OK, 1=Probably OK, 2=singular, 3=no room If checkBeforeModify...
int numberRows() const
Number of Rows after factorization.
int pivots() const
Returns number of pivots since factorization.
int * pivotColumn() const
Returns address of pivotColumn region (also used for permuting)
void areaFactor(double value)
Set whether larger areas needed.
void getWeights(int *weights) const
Fills weighted row list.
int forceB_
If nonzero force use of 1,dense 2,small 3,osl.
int status() const
Returns status.
int status() const
Returns status.
void setDenseThreshold(int value)
Sets dense threshold.
int numberRows() const
Number of Rows after factorization.
double areaFactor() const
Whether larger areas needed.
int lastNumberPivots_
Pointer to network basis.
This deals with Factorization and Updates.
void goDenseOrSmall(int numberRows)
Go over to dense or small code if small enough.
CoinFactorization * coinFactorizationA_
Pointer to CoinFactorization.
double pivotTolerance() const
Pivot tolerance.
int goDenseThreshold_
Switch to dense if number rows <= this.
CoinBigIndex numberElementsL() const
Returns number in L area.
void messageLevel(int value)
Set level of detail of messages.
int denseThreshold() const
Gets dense threshold.
virtual void clearArrays()
Get rid of all memory.
void almostDestructor()
Delete all stuff (leaves as after CoinFactorization())
void setStatus(int value)
Sets status.
int sparseThreshold() const
get sparse threshold
void relaxAccuracyCheck(double value)
Allows change of pivot accuracy check 1.0 == none >1.0 relaxed.
void goSparse()
makes a row copy of L for speed and to allow very sparse problems
void maximumPivots(int value)
Set maximum number of pivots between factorizations.
void setDenseThreshold(int value)
Sets dense threshold.
double zeroTolerance() const
Zero tolerance.
int messageLevel() const
Level of detail of messages.
void relaxAccuracyCheck(double value)
Allows change of pivot accuracy check 1.0 == none >1.0 relaxed.
int isDenseOrSmall() const
Return 1 if dense code.
int messageLevel() const
Level of detail of messages.
int effectiveStartNumberU_
Pointer to network basis.
void setBiasLU(int value)
Total number of elements in factorization.
virtual int numberElements() const =0
Total number of elements in factorization.
This just implements CoinFactorization when an ClpMatrixBase object is passed.
int goOslThreshold_
Switch to osl if number rows <= this.
int pivots() const
Returns number of pivots since factorization.
void setForrestTomlin(bool value)
Returns status.