CoinUtils 2.10.15

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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;
27 class CoinOtherFactorization {
28
29 public:
30
33 CoinOtherFactorization ( );
36 CoinOtherFactorization ( const CoinOtherFactorization &other);
37
39 virtual ~CoinOtherFactorization ( );
41 CoinOtherFactorization & operator = ( const CoinOtherFactorization & other );
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_;
231 double zeroTolerance_;
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_;
243 CoinBigIndex factorElements_;
245 int numberRows_;
247 int numberColumns_;
249 int numberGoodU_;
251 int maximumPivots_;
253 int numberPivots_;
255 int status_;
257 int maximumRows_;
259 CoinBigIndex maximumSpace_;
261 int * pivotRow_;
266 CoinFactorizationDouble * elements_;
268 CoinFactorizationDouble * workArea_;
273 int solveMode_;
275 };
285 class CoinDenseFactorization : public CoinOtherFactorization {
286 friend void CoinDenseFactorizationUnitTest( const std::string & mpsDir );
287
288 public:
289
292 CoinDenseFactorization ( );
295 CoinDenseFactorization ( const CoinDenseFactorization &other);
296
298 virtual ~CoinDenseFactorization ( );
300 CoinDenseFactorization & operator = ( const CoinDenseFactorization & other );
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 {
331 return numberRows_*(numberColumns_+numberPivots_);
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
CoinOtherFactorization::updateColumn
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...
CoinDenseFactorization::postProcess
virtual void postProcess(const int *sequence, int *pivotVariable)
Does post processing on valid factorization - putting variables on correct rows.
CoinOtherFactorization::intWorkArea
virtual int * intWorkArea() const
Returns int work area.
CoinOtherFactorization::updateColumnFT
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...
CoinOtherFactorization::setNumberRows
void setNumberRows(int value)
Set number of Rows after factorization.
Definition: CoinDenseFactorization.hpp:64
CoinTypes.hpp
CoinDenseFactorization::CoinDenseFactorization
CoinDenseFactorization()
Default constructor.
CoinOtherFactorization
Abstract base class which also has some scalars so can be used from Dense or Simp.
Definition: CoinDenseFactorization.hpp:27
CoinOtherFactorization::numberPivots_
int numberPivots_
Number pivots since last factorization.
Definition: CoinDenseFactorization.hpp:253
CoinDenseFactorization::indices
virtual int * indices() const
Returns array to put basis indices in.
Definition: CoinDenseFactorization.hpp:393
CoinOtherFactorization::status_
int status_
Status of factorization.
Definition: CoinDenseFactorization.hpp:255
CoinOtherFactorization::starts
virtual CoinBigIndex * starts() const
Returns array to put basis starts in.
CoinOtherFactorization::numberRows_
int numberRows_
Number of Rows in factorization.
Definition: CoinDenseFactorization.hpp:245
CoinDenseFactorization::updateColumnFT
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...
Definition: CoinDenseFactorization.hpp:363
CoinOtherFactorization::postProcess
virtual void postProcess(const int *sequence, int *pivotVariable)=0
Does post processing on valid factorization - putting variables on correct rows.
CoinDenseFactorization::CoinDenseFactorizationUnitTest
friend void CoinDenseFactorizationUnitTest(const std::string &mpsDir)
CoinOtherFactorization::numberRows
int numberRows() const
Number of Rows after factorization.
Definition: CoinDenseFactorization.hpp:67
CoinDenseFactorization::maximumCoefficient
double maximumCoefficient() const
Returns maximum absolute value in factorization.
CoinOtherFactorization::updateColumnTranspose
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...
CoinOtherFactorization::numberGoodU_
int numberGoodU_
Number factorized in U (not row singletons)
Definition: CoinDenseFactorization.hpp:249
CoinOtherFactorization::maximumSpace_
CoinBigIndex maximumSpace_
Maximum length of iterating area.
Definition: CoinDenseFactorization.hpp:259
CoinOtherFactorization::numberGoodColumns
int numberGoodColumns() const
Number of good columns in factorization.
Definition: CoinDenseFactorization.hpp:75
CoinOtherFactorization::slackValue
double slackValue() const
Whether slack value is +1 or -1.
Definition: CoinDenseFactorization.hpp:102
CoinOtherFactorization::preProcess
virtual void preProcess()=0
PreProcesses column ordered copy of basis.
CoinOtherFactorization::maximumPivots_
int maximumPivots_
Maximum number of pivots before factorization.
Definition: CoinDenseFactorization.hpp:251
CoinFactorization.hpp
CoinOtherFactorization::slackValue_
double slackValue_
Whether slack value is +1 or -1.
Definition: CoinDenseFactorization.hpp:234
CoinOtherFactorization::clearArrays
virtual void clearArrays()
Get rid of all memory.
Definition: CoinDenseFactorization.hpp:143
CoinOtherFactorization::makeNonSingular
virtual void makeNonSingular(int *sequence, int numberColumns)=0
Makes a non-singular basis by replacing variables.
CoinOtherFactorization::getAccuracyCheck
double getAccuracyCheck() const
Definition: CoinDenseFactorization.hpp:81
CoinOtherFactorization::maximumRows_
int maximumRows_
Maximum rows ever (i.e. use to copy arrays etc)
Definition: CoinDenseFactorization.hpp:257
CoinOtherFactorization::maximumPivots
int maximumPivots() const
Maximum number of pivots between factorizations.
Definition: CoinDenseFactorization.hpp:84
CoinOtherFactorization::elements_
CoinFactorizationDouble * elements_
Elements of factorization and updates length is maxR*maxR+maxSpace will always be long enough so can ...
Definition: CoinDenseFactorization.hpp:266
CoinFactorizationDouble
double CoinFactorizationDouble
Definition: CoinTypes.hpp:57
CoinOtherFactorization::numberInColumn
virtual int * numberInColumn() const
Number of entries in each column.
CoinOtherFactorization::zeroTolerance_
double zeroTolerance_
Zero tolerance.
Definition: CoinDenseFactorization.hpp:231
CoinOtherFactorization::permuteBack
virtual int * permuteBack() const
Returns permute back.
CoinOtherFactorization::elements
virtual CoinFactorizationDouble * elements() const
Returns array to put basis elements in.
CoinOtherFactorization::numberColumns
int numberColumns() const
Total number of columns in factorization.
Definition: CoinDenseFactorization.hpp:71
CoinOtherFactorization::zeroTolerance
double zeroTolerance() const
Zero tolerance.
Definition: CoinDenseFactorization.hpp:96
CoinOtherFactorization::setSolveMode
void setSolveMode(int value)
Set solve mode e.g.
Definition: CoinDenseFactorization.hpp:133
CoinDenseFactorization::updateColumn
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...
CoinDenseFactorization::checkPivot
int checkPivot(double saveFromU, double oldPivot) const
Returns accuracy status of replaceColumn returns 0=OK, 1=Probably OK, 2=singular. ...
CoinIndexedVector
Indexed Vector.
Definition: CoinIndexedVector.hpp:104
CoinDenseFactorization::clone
virtual CoinOtherFactorization * clone() const
Clone.
CoinOtherFactorization::wantsTableauColumn
virtual bool wantsTableauColumn() const
Returns true if wants tableauColumn in replaceColumn.
CoinDenseFactorization::factor
virtual int factor()
Does most of factorization returning status 0 - OK -99 - needs more memory -1 - singular - use number...
CoinDenseFactorization::getAreas
virtual void getAreas(int numberRows, int numberColumns, CoinBigIndex maximumL, CoinBigIndex maximumU)
Gets space for a factorization.
CoinOtherFactorization::workArea_
CoinFactorizationDouble * workArea_
Work area of numberRows_.
Definition: CoinDenseFactorization.hpp:268
CoinDenseFactorization::operator=
CoinDenseFactorization & operator=(const CoinDenseFactorization &other)
= copy
CoinDenseFactorization::updateColumnTranspose
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...
CoinOtherFactorization::solveMode
int solveMode() const
Get solve mode e.g.
Definition: CoinDenseFactorization.hpp:127
CoinDenseFactorization::numberElements
virtual int numberElements() const
Total number of elements in factorization.
Definition: CoinDenseFactorization.hpp:330
CoinDenseFactorization::makeNonSingular
virtual void makeNonSingular(int *sequence, int numberColumns)
Makes a non-singular basis by replacing variables.
CoinDenseFactorization::clearArrays
void clearArrays()
Get rid of all memory.
Definition: CoinDenseFactorization.hpp:390
CoinOtherFactorization::setStatus
void setStatus(int value)
Sets status.
Definition: CoinDenseFactorization.hpp:54
CoinOtherFactorization::numberInRow
virtual int * numberInRow() const
Number of entries in each row.
CoinDenseFactorization::~CoinDenseFactorization
virtual ~CoinDenseFactorization()
Destructor.
CoinDenseFactorization::replaceColumn
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::CoinOtherFactorization
CoinOtherFactorization()
Default constructor.
CoinDenseFactorization
This deals with Factorization and Updates This is a simple dense version so other people can write a ...
Definition: CoinDenseFactorization.hpp:285
CoinOtherFactorization::status
int status() const
Returns status.
Definition: CoinDenseFactorization.hpp:50
CoinOtherFactorization::getAreas
virtual void getAreas(int numberRows, int numberColumns, CoinBigIndex maximumL, CoinBigIndex maximumU)=0
Gets space for a factorization.
CoinDenseFactorization::gutsOfInitialize
void gutsOfInitialize()
The real work of constructor.
CoinPackedMatrix
Sparse Matrix Base Class.
Definition: CoinPackedMatrix.hpp:79
CoinOtherFactorization::factorElements_
CoinBigIndex factorElements_
Number of elements after factorization.
Definition: CoinDenseFactorization.hpp:243
CoinOtherFactorization::factor
virtual int factor()=0
Does most of factorization returning status 0 - OK -99 - needs more memory -1 - singular - use number...
CoinOtherFactorization::replaceColumn
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...
CoinOtherFactorization::pivotTolerance
double pivotTolerance() const
Pivot tolerance.
Definition: CoinDenseFactorization.hpp:91
CoinOtherFactorization::indices
virtual int * indices() const =0
Returns array to put basis indices in.
CoinBigIndex
int CoinBigIndex
Definition: Coin_C_defines.h:105
CoinDenseFactorization::preProcess
virtual void preProcess()
PreProcesses column ordered copy of basis.
CoinOtherFactorization::relaxCheck_
double relaxCheck_
Relax check on accuracy in replaceColumn.
Definition: CoinDenseFactorization.hpp:241
CoinOtherFactorization::updateTwoColumnsFT
virtual int updateTwoColumnsFT(CoinIndexedVector *regionSparse1, CoinIndexedVector *regionSparse2, CoinIndexedVector *regionSparse3, bool noPermute=false)=0
does FTRAN on two columns
CoinOtherFactorization::~CoinOtherFactorization
virtual ~CoinOtherFactorization()
Destructor.
CoinOtherFactorization::setPivots
void setPivots(int value)
Sets number of pivots since factorization.
Definition: CoinDenseFactorization.hpp:61
CoinDenseFactorization::gutsOfCopy
void gutsOfCopy(const CoinDenseFactorization &other)
The real work of copy.
CoinOtherFactorization::workArea
virtual CoinFactorizationDouble * workArea() const
Returns work area.
CoinOtherFactorization::pivotTolerance_
double pivotTolerance_
Pivot tolerance.
Definition: CoinDenseFactorization.hpp:229
CoinOtherFactorization::pivotRow_
int * pivotRow_
Pivot row.
Definition: CoinDenseFactorization.hpp:261
CoinIndexedVector.hpp
CoinOtherFactorization::pivotRow
virtual int * pivotRow() const
Returns pivot row.
CoinDenseFactorization::gutsOfDestructor
void gutsOfDestructor()
The real work of desstructor.
CoinOtherFactorization::solveMode_
int solveMode_
Solve mode e.g.
Definition: CoinDenseFactorization.hpp:273
CoinDenseFactorization::permute
virtual int * permute() const
Returns permute in.
Definition: CoinDenseFactorization.hpp:396
CoinOtherFactorization::pivots
int pivots() const
Returns number of pivots since factorization.
Definition: CoinDenseFactorization.hpp:57
CoinOtherFactorization::clone
virtual CoinOtherFactorization * clone() const =0
Clone.
CoinOtherFactorization::permute
virtual int * permute() const =0
Returns permute in.
CoinOtherFactorization::numberColumns_
int numberColumns_
Number of Columns in factorization.
Definition: CoinDenseFactorization.hpp:247
CoinOtherFactorization::relaxAccuracyCheck
void relaxAccuracyCheck(double value)
Allows change of pivot accuracy check 1.0 == none &gt;1.0 relaxed.
Definition: CoinDenseFactorization.hpp:79
CoinDenseFactorization::updateTwoColumnsFT
virtual int updateTwoColumnsFT(CoinIndexedVector *regionSparse1, CoinIndexedVector *regionSparse2, CoinIndexedVector *regionSparse3, bool noPermute=false)
does FTRAN on two columns
CoinOtherFactorization::setUsefulInformation
virtual void setUsefulInformation(const int *info, int whereFrom)
Useful information for factorization 0 - iteration number whereFrom is 0 for factorize and 1 for repl...
CoinOtherFactorization::numberElements
virtual int numberElements() const =0
Total number of elements in factorization.
CoinOtherFactorization::operator=
CoinOtherFactorization & operator=(const CoinOtherFactorization &other)
= copy