CoinUtils  2.9.15
CoinDenseFactorization.hpp
Go to the documentation of this file.
1 /* $Id: CoinDenseFactorization.hpp 1416 2011-04-17 09:57:29Z stefan $ */
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 class CoinPackedMatrix;
25 
26 public:
27 
34 
36  virtual ~CoinOtherFactorization ( );
39 
41  virtual CoinOtherFactorization * clone() const = 0;
43 
46  inline int status ( ) const {
48  return status_;
49  }
51  inline void setStatus ( int value)
52  { status_=value; }
54  inline int pivots ( ) const {
55  return numberPivots_;
56  }
58  inline void setPivots ( int value )
59  { numberPivots_=value; }
61  inline void setNumberRows(int value)
62  { numberRows_ = value; }
64  inline int numberRows ( ) const {
65  return numberRows_;
66  }
68  inline int numberColumns ( ) const {
69  return numberColumns_;
70  }
72  inline int numberGoodColumns ( ) const {
73  return numberGoodU_;
74  }
76  inline void relaxAccuracyCheck(double value)
77  { relaxCheck_ = value;}
78  inline double getAccuracyCheck() const
79  { return relaxCheck_;}
81  inline int maximumPivots ( ) const {
82  return maximumPivots_ ;
83  }
85  virtual void maximumPivots ( int value );
86 
88  inline double pivotTolerance ( ) const {
89  return pivotTolerance_ ;
90  }
91  void pivotTolerance ( double value );
93  inline double zeroTolerance ( ) const {
94  return zeroTolerance_ ;
95  }
96  void zeroTolerance ( double value );
97 #ifndef COIN_FAST_CODE
98  inline double slackValue ( ) const {
100  return slackValue_ ;
101  }
102  void slackValue ( double value );
103 #endif
104  virtual CoinFactorizationDouble * elements() const;
107  virtual int * pivotRow() const;
109  virtual CoinFactorizationDouble * workArea() const;
111  virtual int * intWorkArea() const;
113  virtual int * numberInRow() const;
115  virtual int * numberInColumn() const;
117  virtual CoinBigIndex * starts() const;
119  virtual int * permuteBack() const;
124  inline int solveMode() const
125  { return solveMode_ ;}
130  inline void setSolveMode(int value)
131  { solveMode_ = value;}
133  virtual bool wantsTableauColumn() const;
138  virtual void setUsefulInformation(const int * info,int whereFrom);
140  virtual void clearArrays() {}
142 
144  virtual int * indices() const = 0;
147  virtual int * permute() const = 0;
149  virtual int numberElements ( ) const = 0;
151 
153  virtual void getAreas ( int numberRows,
155  int numberColumns,
156  CoinBigIndex maximumL,
157  CoinBigIndex maximumU ) = 0;
158 
160  virtual void preProcess ( ) = 0;
166  virtual int factor ( ) = 0;
168  virtual void postProcess(const int * sequence, int * pivotVariable) = 0;
170  virtual void makeNonSingular(int * sequence, int numberColumns) = 0;
172 
175 
183  virtual int replaceColumn ( CoinIndexedVector * regionSparse,
184  int pivotRow,
185  double pivotCheck ,
186  bool checkBeforeModifying=false,
187  double acceptablePivot=1.0e-8)=0;
189 
199  virtual int updateColumnFT ( CoinIndexedVector * regionSparse,
200  CoinIndexedVector * regionSparse2,
201  bool noPermute=false) = 0;
204  virtual int updateColumn ( CoinIndexedVector * regionSparse,
205  CoinIndexedVector * regionSparse2,
206  bool noPermute=false) const = 0;
208  virtual int updateTwoColumnsFT(CoinIndexedVector * regionSparse1,
209  CoinIndexedVector * regionSparse2,
210  CoinIndexedVector * regionSparse3,
211  bool noPermute=false) = 0;
216  virtual int updateColumnTranspose ( CoinIndexedVector * regionSparse,
217  CoinIndexedVector * regionSparse2) const = 0;
219 
221 protected:
222 
225  double pivotTolerance_;
229 #ifndef COIN_FAST_CODE
230  double slackValue_;
232 #else
233 #ifndef slackValue_
234 #define slackValue_ -1.0
235 #endif
236 #endif
237  double relaxCheck_;
252  int status_;
258  int * pivotRow_;
272 };
283  friend void CoinDenseFactorizationUnitTest( const std::string & mpsDir );
284 
285 public:
286 
293 
295  virtual ~CoinDenseFactorization ( );
299  virtual CoinOtherFactorization * clone() const ;
301 
304  virtual void getAreas ( int numberRows,
306  int numberColumns,
307  CoinBigIndex maximumL,
308  CoinBigIndex maximumU );
309 
311  virtual void preProcess ( );
317  virtual int factor ( );
319  virtual void postProcess(const int * sequence, int * pivotVariable);
321  virtual void makeNonSingular(int * sequence, int numberColumns);
323 
326  virtual inline int numberElements ( ) const {
329  }
331  double maximumCoefficient() const;
333 
336 
344  virtual int replaceColumn ( CoinIndexedVector * regionSparse,
345  int pivotRow,
346  double pivotCheck ,
347  bool checkBeforeModifying=false,
348  double acceptablePivot=1.0e-8);
350 
360  virtual inline int updateColumnFT ( CoinIndexedVector * regionSparse,
361  CoinIndexedVector * regionSparse2,
362  bool = false)
363  { return updateColumn(regionSparse,regionSparse2);}
366  virtual int updateColumn ( CoinIndexedVector * regionSparse,
367  CoinIndexedVector * regionSparse2,
368  bool noPermute=false) const;
370  virtual int updateTwoColumnsFT(CoinIndexedVector * regionSparse1,
371  CoinIndexedVector * regionSparse2,
372  CoinIndexedVector * regionSparse3,
373  bool noPermute=false);
378  virtual int updateColumnTranspose ( CoinIndexedVector * regionSparse,
379  CoinIndexedVector * regionSparse2) const;
381 
386  inline void clearArrays()
388  { gutsOfDestructor();}
390  virtual inline int * indices() const
391  { return reinterpret_cast<int *> (elements_+numberRows_*numberRows_);}
393  virtual inline int * permute() const
394  { return NULL;/*pivotRow_*/;}
396 
398  void gutsOfDestructor();
400  void gutsOfInitialize();
402  void gutsOfCopy(const CoinDenseFactorization &other);
403 
405 protected:
408  int checkPivot(double saveFromU, double oldPivot) const;
410 protected:
411 
414 
415 };
416 #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 >=0...
int numberRows() const
Number of Rows after factorization.
double slackValue() const
Whether slack value is +1 or -1.
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.
virtual int * numberInRow() const
Number of entries in each row.
int maximumPivots() const
Maximum number of pivots between factorizations.
Abstract base class which also has some scalars so can be used from Dense or Simp.
int numberPivots_
Number pivots since last factorization.
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.
virtual int * permute() const
Returns permute in.
double pivotTolerance() const
Pivot tolerance.
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.
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 int * indices() const
Returns array to put basis indices in.
virtual void clearArrays()
Get rid of all memory.
virtual void makeNonSingular(int *sequence, int numberColumns)=0
Makes a non-singular basis by replacing variables.
double zeroTolerance() const
Zero tolerance.
int maximumRows_
Maximum rows ever (i.e. use to copy arrays etc)
CoinFactorizationDouble * elements_
Elements of factorization and updates length is maxR*maxR+maxSpace will always be long enough so can ...
double CoinFactorizationDouble
Definition: CoinTypes.hpp:54
double zeroTolerance_
Zero tolerance.
void setSolveMode(int value)
Set solve mode e.g.
Indexed Vector.
virtual CoinFactorizationDouble * elements() const
Returns array to put basis elements in.
virtual int * numberInColumn() const
Number of entries in each column.
int numberColumns() const
Total number of columns in factorization.
CoinFactorizationDouble * workArea_
Work area of numberRows_.
int pivots() const
Returns number of pivots since factorization.
void setStatus(int value)
Sets status.
CoinOtherFactorization()
Default constructor.
This deals with Factorization and Updates This is a simple dense version so other people can write a ...
virtual void getAreas(int numberRows, int numberColumns, CoinBigIndex maximumL, CoinBigIndex maximumU)=0
Gets space for a factorization.
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...
int solveMode() const
Get solve mode e.g.
virtual int * indices() const =0
Returns array to put basis indices in.
virtual int * intWorkArea() const
Returns int work area.
int CoinBigIndex
virtual bool wantsTableauColumn() const
Returns true if wants tableauColumn in replaceColumn.
double relaxCheck_
Relax check on accuracy in replaceColumn.
virtual int * permuteBack() const
Returns permute back.
int numberGoodColumns() const
Number of good columns in factorization.
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.
double pivotTolerance_
Pivot tolerance.
virtual CoinBigIndex * starts() const
Returns array to put basis starts in.
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 >1.0 relaxed.
virtual int * pivotRow() const
Returns pivot row.
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 CoinFactorizationDouble * workArea() const
Returns work area.
int status() const
Returns status.
virtual int numberElements() const =0
Total number of elements in factorization.
CoinOtherFactorization & operator=(const CoinOtherFactorization &other)
= copy