Cbc  2.9.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 pivots() const
Returns number of pivots since factorization.
int goOslThreshold_
Switch to osl if number rows <= this.
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.
void setGoOslThreshold(int value)
Set switch to osl if number rows <= this.
void setGoSmallThreshold(int value)
Set switch to small if number rows <= this.
void sparseThreshold(int value)
Set sparse threshold.
double areaFactor() const
Whether larger areas needed.
int numberDense() const
Returns number of dense rows.
int status() const
Returns status.
int denseThreshold() const
Gets dense threshold.
Abstract base class for Clp Matrices.
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...
void setStatus(int value)
Sets status.
int * pivotColumn() const
Returns address of pivotColumn region (also used for permuting)
double shortestAverage_
For guessing when to re-factorize.
Abstract base class which also has some scalars so can be used from Dense or Simp.
void setForrestTomlin(bool value)
int goDenseThreshold() const
Get switch to dense if number rows <= this.
int factorize(ClpSimplex *model, int solveType, bool valuesPass)
When part of LP - given by basic variables.
void setDenseThreshold(int value)
Sets dense threshold.
double pivotTolerance() const
Pivot tolerance.
void almostDestructor()
Delete all stuff (leaves as after CoinFactorization())
void relaxAccuracyCheck(double value)
Allows change of pivot accuracy check 1.0 == none >1.0 relaxed.
void forceOtherFactorization(int which)
If nonzero force use of 1,dense 2,small 3,osl.
int numberRows() const
Number of Rows after factorization.
int * permute() const
Returns address of permute region.
void setFactorization(ClpFactorization &factorization)
Sets factorization.
double areaFactor() const
Whether larger areas needed.
CoinBigIndex numberElementsR() const
Returns number in R area.
int numberElements() const
Total number of elements in factorization.
ClpNetworkBasis * networkBasis_
Pointer to network basis.
void saferTolerances(double zeroTolerance, double pivotTolerance)
Set tolerances to safer of existing and given.
int numberRows() const
Number of Rows after factorization.
void setGoDenseThreshold(int value)
Set switch to dense if number rows <= this.
void setDefaultValues()
Sets default values.
double adjustedAreaFactor() const
Returns areaFactor but adjusted for dense.
int status() const
Returns status.
This deals with Factorization and Updates for network structures.
This just implements CoinFactorization when an ClpMatrixBase object is passed.
void setBiasLU(int value)
CoinBigIndex numberElementsL() const
Returns number in L area.
double zeroTolerance() const
Zero tolerance.
void setPersistenceFlag(int value)
#define CLP_MULTIPLE_FACTORIZATIONS
virtual void clearArrays()
Get rid of all memory.
bool networkBasis() const
Says if a network basis.
int sparseThreshold() const
get sparse threshold
CoinBigIndex numberElementsU() const
Returns number in U area.
int sparseThreshold() const
get sparse threshold
void maximumPivots(int value)
Set maximum number of pivots between factorizations.
void setPersistenceFlag(int value)
int maximumPivots() const
Maximum number of pivots between factorizations.
~ClpFactorization()
Destructor.
int denseThreshold() const
Gets dense threshold.
int messageLevel() const
Level of detail of messages.
void cleanUp()
Cleans up i.e. gets rid of network basis.
double zeroTolerance() const
Zero tolerance.
CoinBigIndex numberElementsL() const
Returns number in L area.
void setBiasLU(int value)
int pivots() const
Returns number of pivots since factorization.
This solves LPs using the simplex method.
Definition: ClpSimplex.hpp:70
int updateColumnTranspose(CoinIndexedVector *regionSparse, CoinIndexedVector *regionSparse2) const
Updates one column (BTRAN) from region2 region1 starts as zero and is zero at end.
Indexed Vector.
void goDenseOrSmall(int numberRows)
Go over to dense or small code if small enough.
void clearArrays()
Get rid of all memory.
CoinFactorization * coinFactorizationA_
Pointer to CoinFactorization.
int goSmallThreshold() const
Get switch to small if number rows <= this.
void almostDestructor()
Delete all stuff (leaves as after CoinFactorization())
ClpFactorization()
Default constructor.
int numberRows() const
Number of Rows after factorization.
void setStatus(int value)
Sets status.
void zeroTolerance(double value)
Set zero tolerance.
int maximumPivots() const
Maximum number of pivots between factorizations.
ClpFactorization & operator=(const ClpFactorization &)
void goSparse()
makes a row copy of L for speed and to allow very sparse problems
int maximumPivots() const
Maximum number of pivots between factorizations.
double zeroTolerance() const
Zero tolerance.
double adjustedAreaFactor() const
Returns areaFactor but adjusted for dense.
void setStatus(int value)
Sets status.
int status() const
Returns status.
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 goSmallThreshold_
Switch to small if number rows <= this.
double slackValue() const
Whether slack value is +1 or -1.
double pivotTolerance() const
Pivot tolerance.
int goOslThreshold() const
Get switch to osl if number rows <= this.
void clearArrays()
Get rid of all memory.
int numberDense() const
Returns number of dense rows.
CoinBigIndex numberElementsU() const
Returns number in U area.
int goDenseThreshold_
Switch to dense if number rows <= this.
int * permute() const
Returns address of permute region.
int CoinBigIndex
void messageLevel(int value)
Set level of detail of messages.
This deals with Factorization and Updates.
int * pivotColumn() const
Returns address of pivotColumn region (also used for permuting)
bool needToReorder() const
Says whether to redo pivot order.
int isDenseOrSmall() const
Return 1 if dense code.
int numberElements() const
Total number of elements in factorization.
bool timeToRefactorize() const
void setDenseThreshold(int value)
Sets dense threshold.
int pivots() const
Returns number of pivots since factorization.
int updateColumnFT(CoinIndexedVector *regionSparse, CoinIndexedVector *regionSparse2)
Updates one column (FTRAN) from region2 Tries to do FT update number returned is negative if no room ...
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...
virtual int * permute() const =0
Returns permute in.
void getWeights(int *weights) const
Fills weighted row list.
int messageLevel() const
Level of detail of messages.
int updateColumnForDebug(CoinIndexedVector *regionSparse, CoinIndexedVector *regionSparse2, bool noPermute=false) const
For debug (no statistics update)
double pivotTolerance() const
Pivot 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...
void pivotTolerance(double value)
Set pivot tolerance.
void setForrestTomlin(bool value)
true if Forrest Tomlin update, false if PFI
int forceB_
If nonzero force use of 1,dense 2,small 3,osl.
void areaFactor(double value)
Set whether larger areas needed.
CoinOtherFactorization * coinFactorizationB_
Pointer to CoinOtherFactorization.
void relaxAccuracyCheck(double value)
Allows change of pivot accuracy check 1.0 == none >1.0 relaxed.
CoinBigIndex numberElementsR() const
Returns number in R area.
virtual int numberElements() const =0
Total number of elements in factorization.