Clp  1.17.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CoinDenseFactorization.hpp
Go to the documentation of this file.
1 /* $Id: CoinDenseFactorization.hpp 2083 2019-01-06 19:38:09Z unxusr $ */
2 // Copyright (C) 2008, 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 /*
7  Authors
8 
9  John Forrest
10 
11  */
12 #ifndef CoinDenseFactorization_H
13 #define CoinDenseFactorization_H
14 
15 #include <iostream>
16 #include <string>
17 #include <cassert>
18 #include "CoinTypes.hpp"
19 #include "CoinIndexedVector.hpp"
20 #include "CoinFactorization.hpp"
21 #if COIN_FACTORIZATION_DENSE_CODE == 2
22 #undef COIN_FACTORIZATION_DENSE_CODE
23 #endif
24 class CoinPackedMatrix;
27 
28 public:
35 
37  virtual ~CoinOtherFactorization();
40 
42  virtual CoinOtherFactorization *clone() const = 0;
44 
47  inline int status() const
49  {
50  return status_;
51  }
53  inline void setStatus(int value)
54  {
55  status_ = value;
56  }
58  inline int pivots() const
59  {
60  return numberPivots_;
61  }
63  inline void setPivots(int value)
64  {
65  numberPivots_ = value;
66  }
68  inline void setNumberRows(int value)
69  {
70  numberRows_ = value;
71  }
73  inline int numberRows() const
74  {
75  return numberRows_;
76  }
78  inline int numberColumns() const
79  {
80  return numberColumns_;
81  }
83  inline int numberGoodColumns() const
84  {
85  return numberGoodU_;
86  }
88  inline void relaxAccuracyCheck(double value)
89  {
90  relaxCheck_ = value;
91  }
92  inline double getAccuracyCheck() const
93  {
94  return relaxCheck_;
95  }
97  inline int maximumPivots() const
98  {
99  return maximumPivots_;
100  }
102  virtual void maximumPivots(int value);
103 
105  inline double pivotTolerance() const
106  {
107  return pivotTolerance_;
108  }
109  void pivotTolerance(double value);
111  inline double zeroTolerance() const
112  {
113  return zeroTolerance_;
114  }
115  void zeroTolerance(double value);
116 #ifndef COIN_FAST_CODE
117  inline double slackValue() const
119  {
120  return slackValue_;
121  }
122  void slackValue(double value);
123 #endif
124  virtual CoinFactorizationDouble *elements() const;
127  virtual int *pivotRow() const;
129  virtual CoinFactorizationDouble *workArea() const;
131  virtual int *intWorkArea() const;
133  virtual int *numberInRow() const;
135  virtual int *numberInColumn() const;
137  virtual int *starts() const;
139  virtual int *permuteBack() const;
144  inline int solveMode() const
145  {
146  return solveMode_;
147  }
152  inline void setSolveMode(int value)
153  {
154  solveMode_ = value;
155  }
157  virtual bool wantsTableauColumn() const;
162  virtual void setUsefulInformation(const int *info, int whereFrom);
164  virtual void clearArrays() {}
166 
168  virtual int *indices() const = 0;
171  virtual int *permute() const = 0;
173  virtual int numberElements() const = 0;
175 
177  virtual void getAreas(int numberRows,
179  int numberColumns,
180  int maximumL,
181  int maximumU)
182  = 0;
183 
185  virtual void preProcess() = 0;
191  virtual int factor() = 0;
193  virtual void postProcess(const int *sequence, int *pivotVariable) = 0;
195  virtual void makeNonSingular(int *sequence, int numberColumns) = 0;
197 
200 
208  virtual int replaceColumn(CoinIndexedVector *regionSparse,
209  int pivotRow,
210  double pivotCheck,
211  bool checkBeforeModifying = false,
212  double acceptablePivot = 1.0e-8)
213  = 0;
215 
225  virtual int updateColumnFT(CoinIndexedVector *regionSparse,
226  CoinIndexedVector *regionSparse2,
227  bool noPermute = false)
228  = 0;
231  virtual int updateColumn(CoinIndexedVector *regionSparse,
232  CoinIndexedVector *regionSparse2,
233  bool noPermute = false) const = 0;
235  virtual int updateTwoColumnsFT(CoinIndexedVector *regionSparse1,
236  CoinIndexedVector *regionSparse2,
237  CoinIndexedVector *regionSparse3,
238  bool noPermute = false)
239  = 0;
244  virtual int updateColumnTranspose(CoinIndexedVector *regionSparse,
245  CoinIndexedVector *regionSparse2) const = 0;
247 
249 protected:
252  double pivotTolerance_;
256 #ifndef COIN_FAST_CODE
257  double slackValue_;
259 #else
260 #ifndef slackValue_
261 #define slackValue_ -1.0
262 #endif
263 #endif
264  double relaxCheck_;
279  int status_;
285  int *pivotRow_;
299 };
308  friend void CoinDenseFactorizationUnitTest(const std::string &mpsDir);
309 
310 public:
317 
319  virtual ~CoinDenseFactorization();
323  virtual CoinOtherFactorization *clone() const;
325 
328  virtual void getAreas(int numberRows,
330  int numberColumns,
331  int maximumL,
332  int maximumU);
333 
335  virtual void preProcess();
341  virtual int factor();
343  virtual void postProcess(const int *sequence, int *pivotVariable);
345  virtual void makeNonSingular(int *sequence, int numberColumns);
347 
350  virtual inline int numberElements() const
352  {
354  }
356  double maximumCoefficient() const;
358 
361 
369  virtual int replaceColumn(CoinIndexedVector *regionSparse,
370  int pivotRow,
371  double pivotCheck,
372  bool checkBeforeModifying = false,
373  double acceptablePivot = 1.0e-8);
375 
385  virtual inline int updateColumnFT(CoinIndexedVector *regionSparse,
386  CoinIndexedVector *regionSparse2,
387  bool = false)
388  {
389  return updateColumn(regionSparse, regionSparse2);
390  }
393  virtual int updateColumn(CoinIndexedVector *regionSparse,
394  CoinIndexedVector *regionSparse2,
395  bool noPermute = false) const;
397  virtual int updateTwoColumnsFT(CoinIndexedVector *regionSparse1,
398  CoinIndexedVector *regionSparse2,
399  CoinIndexedVector *regionSparse3,
400  bool noPermute = false);
405  virtual int updateColumnTranspose(CoinIndexedVector *regionSparse,
406  CoinIndexedVector *regionSparse2) const;
408 
413  inline void clearArrays()
415  {
417  }
419  virtual inline int *indices() const
420  {
421  return reinterpret_cast< int * >(elements_ + numberRows_ * numberRows_);
422  }
424  virtual inline int *permute() const
425  {
426  return NULL; /*pivotRow_*/
427  ;
428  }
430 
432  void gutsOfDestructor();
434  void gutsOfInitialize();
436  void gutsOfCopy(const CoinDenseFactorization &other);
437 
439 protected:
442  int checkPivot(double saveFromU, double oldPivot) const;
444 protected:
447 
448 };
449 #endif
450 
451 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
452 */
virtual int updateColumn(CoinIndexedVector *regionSparse, CoinIndexedVector *regionSparse2, bool noPermute=false) const =0
This version has same effect as above with FTUpdate==false so number returned is always &gt;=0...
virtual void postProcess(const int *sequence, int *pivotVariable)
Does post processing on valid factorization - putting variables on correct rows.
virtual int * intWorkArea() const
Returns int work area.
virtual int updateColumnFT(CoinIndexedVector *regionSparse, CoinIndexedVector *regionSparse2, bool noPermute=false)=0
Updates one column (FTRAN) from regionSparse2 Tries to do FT update number returned is negative if no...
void setNumberRows(int value)
Set number of Rows after factorization.
CoinDenseFactorization()
Default constructor.
Abstract base class which also has some scalars so can be used from Dense or Simp.
int numberPivots_
Number pivots since last factorization.
virtual int * indices() const
Returns array to put basis indices in.
int status_
Status of factorization.
int numberRows_
Number of Rows in factorization.
virtual int updateColumnFT(CoinIndexedVector *regionSparse, CoinIndexedVector *regionSparse2, bool=false)
Updates one column (FTRAN) from regionSparse2 Tries to do FT update number returned is negative if no...
virtual void postProcess(const int *sequence, int *pivotVariable)=0
Does post processing on valid factorization - putting variables on correct rows.
friend void CoinDenseFactorizationUnitTest(const std::string &mpsDir)
int numberRows() const
Number of Rows after factorization.
double maximumCoefficient() const
Returns maximum absolute value in factorization.
virtual int updateColumnTranspose(CoinIndexedVector *regionSparse, CoinIndexedVector *regionSparse2) const =0
Updates one column (BTRAN) from regionSparse2 regionSparse starts as zero and is zero at end Note - i...
int numberGoodU_
Number factorized in U (not row singletons)
int maximumSpace_
Maximum length of iterating area.
int numberGoodColumns() const
Number of good columns in factorization.
double slackValue() const
Whether slack value is +1 or -1.
virtual void preProcess()=0
PreProcesses column ordered copy of basis.
int maximumPivots_
Maximum number of pivots before factorization.
virtual void getAreas(int numberRows, int numberColumns, int maximumL, int maximumU)
Gets space for a factorization.
double slackValue_
Whether slack value is +1 or -1.
virtual void clearArrays()
Get rid of all memory.
virtual void makeNonSingular(int *sequence, int numberColumns)=0
Makes a non-singular basis by replacing variables.
int maximumRows_
Maximum rows ever (i.e. use to copy arrays etc)
int maximumPivots() const
Maximum number of pivots between factorizations.
CoinFactorizationDouble * elements_
Elements of factorization and updates length is maxR*maxR+maxSpace will always be long enough so can ...
double CoinFactorizationDouble
Definition: CoinTypes.hpp:57
virtual int * numberInColumn() const
Number of entries in each column.
double zeroTolerance_
Zero tolerance.
virtual int * permuteBack() const
Returns permute back.
virtual CoinFactorizationDouble * elements() const
Returns array to put basis elements in.
int numberColumns() const
Total number of columns in factorization.
double zeroTolerance() const
Zero tolerance.
void setSolveMode(int value)
Set solve mode e.g.
virtual int updateColumn(CoinIndexedVector *regionSparse, CoinIndexedVector *regionSparse2, bool noPermute=false) const
This version has same effect as above with FTUpdate==false so number returned is always &gt;=0...
int checkPivot(double saveFromU, double oldPivot) const
Returns accuracy status of replaceColumn returns 0=OK, 1=Probably OK, 2=singular. ...
Indexed Vector.
virtual CoinOtherFactorization * clone() const
Clone.
virtual bool wantsTableauColumn() const
Returns true if wants tableauColumn in replaceColumn.
virtual int factor()
Does most of factorization returning status 0 - OK -99 - needs more memory -1 - singular - use number...
CoinFactorizationDouble * workArea_
Work area of numberRows_.
CoinDenseFactorization & operator=(const CoinDenseFactorization &other)
= copy
virtual int * starts() const
Returns array to put basis starts in.
virtual int updateColumnTranspose(CoinIndexedVector *regionSparse, CoinIndexedVector *regionSparse2) const
Updates one column (BTRAN) from regionSparse2 regionSparse starts as zero and is zero at end Note - i...
int solveMode() const
Get solve mode e.g.
virtual int numberElements() const
Total number of elements in factorization.
virtual void makeNonSingular(int *sequence, int numberColumns)
Makes a non-singular basis by replacing variables.
void clearArrays()
Get rid of all memory.
void setStatus(int value)
Sets status.
virtual int * numberInRow() const
Number of entries in each row.
virtual ~CoinDenseFactorization()
Destructor.
virtual int replaceColumn(CoinIndexedVector *regionSparse, 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...
CoinOtherFactorization()
Default constructor.
This deals with Factorization and Updates This is a simple dense version so other people can write a ...
int status() const
Returns status.
void gutsOfInitialize()
The real work of constructor.
Sparse Matrix Base Class.
virtual int factor()=0
Does most of factorization returning status 0 - OK -99 - needs more memory -1 - singular - use number...
virtual int replaceColumn(CoinIndexedVector *regionSparse, int pivotRow, double pivotCheck, bool checkBeforeModifying=false, double acceptablePivot=1.0e-8)=0
Replaces one Column to basis, returns 0=OK, 1=Probably OK, 2=singular, 3=no room If checkBeforeModify...
double pivotTolerance() const
Pivot tolerance.
virtual int * indices() const =0
Returns array to put basis indices in.
virtual void preProcess()
PreProcesses column ordered copy of basis.
double relaxCheck_
Relax check on accuracy in replaceColumn.
virtual int updateTwoColumnsFT(CoinIndexedVector *regionSparse1, CoinIndexedVector *regionSparse2, CoinIndexedVector *regionSparse3, bool noPermute=false)=0
does FTRAN on two columns
int factorElements_
Number of elements after factorization.
virtual ~CoinOtherFactorization()
Destructor.
void setPivots(int value)
Sets number of pivots since factorization.
void gutsOfCopy(const CoinDenseFactorization &other)
The real work of copy.
virtual CoinFactorizationDouble * workArea() const
Returns work area.
double pivotTolerance_
Pivot tolerance.
virtual int * pivotRow() const
Returns pivot row.
void gutsOfDestructor()
The real work of desstructor.
virtual int * permute() const
Returns permute in.
int pivots() const
Returns number of pivots since factorization.
virtual CoinOtherFactorization * clone() const =0
Clone.
virtual int * permute() const =0
Returns permute in.
int numberColumns_
Number of Columns in factorization.
void relaxAccuracyCheck(double value)
Allows change of pivot accuracy check 1.0 == none &gt;1.0 relaxed.
virtual int updateTwoColumnsFT(CoinIndexedVector *regionSparse1, CoinIndexedVector *regionSparse2, CoinIndexedVector *regionSparse3, bool noPermute=false)
does FTRAN on two columns
virtual void getAreas(int numberRows, int numberColumns, int maximumL, int maximumU)=0
Gets space for a factorization.
virtual void setUsefulInformation(const int *info, int whereFrom)
Useful information for factorization 0 - iteration number whereFrom is 0 for factorize and 1 for repl...
virtual int numberElements() const =0
Total number of elements in factorization.
CoinOtherFactorization & operator=(const CoinOtherFactorization &other)
= copy