Cbc  2.9.9
 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 1759 2014-11-18 11:07:23Z forrest $ */
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 /*
8  Authors
9 
10  John Forrest
11 
12  */
13 #ifndef CoinDenseFactorization_H
14 #define CoinDenseFactorization_H
15 
16 #include <iostream>
17 #include <string>
18 #include <cassert>
19 #include "CoinTypes.hpp"
20 #include "CoinIndexedVector.hpp"
21 #include "CoinFactorization.hpp"
22 #if COIN_FACTORIZATION_DENSE_CODE == 2
23 #undef COIN_FACTORIZATION_DENSE_CODE
24 #endif
25 class CoinPackedMatrix;
28 
29 public:
30 
37 
39  virtual ~CoinOtherFactorization ( );
42 
44  virtual CoinOtherFactorization * clone() const = 0;
46 
49  inline int status ( ) const {
51  return status_;
52  }
54  inline void setStatus ( int value)
55  { status_=value; }
57  inline int pivots ( ) const {
58  return numberPivots_;
59  }
61  inline void setPivots ( int value )
62  { numberPivots_=value; }
64  inline void setNumberRows(int value)
65  { numberRows_ = value; }
67  inline int numberRows ( ) const {
68  return numberRows_;
69  }
71  inline int numberColumns ( ) const {
72  return numberColumns_;
73  }
75  inline int numberGoodColumns ( ) const {
76  return numberGoodU_;
77  }
79  inline void relaxAccuracyCheck(double value)
80  { relaxCheck_ = value;}
81  inline double getAccuracyCheck() const
82  { return relaxCheck_;}
84  inline int maximumPivots ( ) const {
85  return maximumPivots_ ;
86  }
88  virtual void maximumPivots ( int value );
89 
91  inline double pivotTolerance ( ) const {
92  return pivotTolerance_ ;
93  }
94  void pivotTolerance ( double value );
96  inline double zeroTolerance ( ) const {
97  return zeroTolerance_ ;
98  }
99  void zeroTolerance ( double value );
100 #ifndef COIN_FAST_CODE
101  inline double slackValue ( ) const {
103  return slackValue_ ;
104  }
105  void slackValue ( double value );
106 #endif
107  virtual CoinFactorizationDouble * elements() const;
110  virtual int * pivotRow() const;
112  virtual CoinFactorizationDouble * workArea() const;
114  virtual int * intWorkArea() const;
116  virtual int * numberInRow() const;
118  virtual int * numberInColumn() const;
120  virtual CoinBigIndex * starts() const;
122  virtual int * permuteBack() const;
127  inline int solveMode() const
128  { return solveMode_ ;}
133  inline void setSolveMode(int value)
134  { solveMode_ = value;}
136  virtual bool wantsTableauColumn() const;
141  virtual void setUsefulInformation(const int * info,int whereFrom);
143  virtual void clearArrays() {}
145 
147  virtual int * indices() const = 0;
150  virtual int * permute() const = 0;
152  virtual int numberElements ( ) const = 0;
154 
156  virtual void getAreas ( int numberRows,
158  int numberColumns,
159  CoinBigIndex maximumL,
160  CoinBigIndex maximumU ) = 0;
161 
163  virtual void preProcess ( ) = 0;
169  virtual int factor ( ) = 0;
171  virtual void postProcess(const int * sequence, int * pivotVariable) = 0;
173  virtual void makeNonSingular(int * sequence, int numberColumns) = 0;
175 
178 
186  virtual int replaceColumn ( CoinIndexedVector * regionSparse,
187  int pivotRow,
188  double pivotCheck ,
189  bool checkBeforeModifying=false,
190  double acceptablePivot=1.0e-8)=0;
192 
202  virtual int updateColumnFT ( CoinIndexedVector * regionSparse,
203  CoinIndexedVector * regionSparse2,
204  bool noPermute=false) = 0;
207  virtual int updateColumn ( CoinIndexedVector * regionSparse,
208  CoinIndexedVector * regionSparse2,
209  bool noPermute=false) const = 0;
211  virtual int updateTwoColumnsFT(CoinIndexedVector * regionSparse1,
212  CoinIndexedVector * regionSparse2,
213  CoinIndexedVector * regionSparse3,
214  bool noPermute=false) = 0;
219  virtual int updateColumnTranspose ( CoinIndexedVector * regionSparse,
220  CoinIndexedVector * regionSparse2) const = 0;
222 
224 protected:
225 
228  double pivotTolerance_;
232 #ifndef COIN_FAST_CODE
233  double slackValue_;
235 #else
236 #ifndef slackValue_
237 #define slackValue_ -1.0
238 #endif
239 #endif
240  double relaxCheck_;
255  int status_;
261  int * pivotRow_;
275 };
286  friend void CoinDenseFactorizationUnitTest( const std::string & mpsDir );
287 
288 public:
289 
296 
298  virtual ~CoinDenseFactorization ( );
302  virtual CoinOtherFactorization * clone() const ;
304 
307  virtual void getAreas ( int numberRows,
309  int numberColumns,
310  CoinBigIndex maximumL,
311  CoinBigIndex maximumU );
312 
314  virtual void preProcess ( );
320  virtual int factor ( );
322  virtual void postProcess(const int * sequence, int * pivotVariable);
324  virtual void makeNonSingular(int * sequence, int numberColumns);
326 
329  virtual inline int numberElements ( ) const {
332  }
334  double maximumCoefficient() const;
336 
339 
347  virtual int replaceColumn ( CoinIndexedVector * regionSparse,
348  int pivotRow,
349  double pivotCheck ,
350  bool checkBeforeModifying=false,
351  double acceptablePivot=1.0e-8);
353 
363  virtual inline int updateColumnFT ( CoinIndexedVector * regionSparse,
364  CoinIndexedVector * regionSparse2,
365  bool = false)
366  { return updateColumn(regionSparse,regionSparse2);}
369  virtual int updateColumn ( CoinIndexedVector * regionSparse,
370  CoinIndexedVector * regionSparse2,
371  bool noPermute=false) const;
373  virtual int updateTwoColumnsFT(CoinIndexedVector * regionSparse1,
374  CoinIndexedVector * regionSparse2,
375  CoinIndexedVector * regionSparse3,
376  bool noPermute=false);
381  virtual int updateColumnTranspose ( CoinIndexedVector * regionSparse,
382  CoinIndexedVector * regionSparse2) const;
384 
389  inline void clearArrays()
391  { gutsOfDestructor();}
393  virtual inline int * indices() const
394  { return reinterpret_cast<int *> (elements_+numberRows_*numberRows_);}
396  virtual inline int * permute() const
397  { return NULL;/*pivotRow_*/;}
399 
401  void gutsOfDestructor();
403  void gutsOfInitialize();
405  void gutsOfCopy(const CoinDenseFactorization &other);
406 
408 protected:
411  int checkPivot(double saveFromU, double oldPivot) const;
413 protected:
414 
417 
418 };
419 #endif
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.
virtual CoinBigIndex * starts() const
Returns array to put basis starts in.
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)
CoinBigIndex 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.
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...
virtual void getAreas(int numberRows, int numberColumns, CoinBigIndex maximumL, CoinBigIndex maximumU)
Gets space for a factorization.
CoinFactorizationDouble * workArea_
Work area of numberRows_.
CoinDenseFactorization & operator=(const CoinDenseFactorization &other)
= copy
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.
virtual void getAreas(int numberRows, int numberColumns, CoinBigIndex maximumL, CoinBigIndex maximumU)=0
Gets space for a factorization.
void gutsOfInitialize()
The real work of constructor.
Sparse Matrix Base Class.
CoinBigIndex factorElements_
Number of elements after factorization.
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.
int CoinBigIndex
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
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 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