CoinUtils 2.11.12
Loading...
Searching...
No Matches
CoinDenseFactorization.hpp
Go to the documentation of this file.
1/* $Id$ */
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
27
28public:
31
35
40
42 virtual CoinOtherFactorization *clone() const = 0;
44
47
48 inline int status() const
49 {
50 return status_;
51 }
52
53 inline void setStatus(int value)
54 {
55 status_ = value;
56 }
57
58 inline int pivots() const
59 {
60 return numberPivots_;
61 }
62
63 inline void setPivots(int value)
64 {
65 numberPivots_ = value;
66 }
67
68 inline void setNumberRows(int value)
69 {
70 numberRows_ = value;
71 }
72
73 inline int numberRows() const
74 {
75 return numberRows_;
76 }
77
78 inline int numberColumns() const
79 {
80 return numberColumns_;
81 }
82
83 inline int numberGoodColumns() const
84 {
85 return numberGoodU_;
86 }
87
88 inline void relaxAccuracyCheck(double value)
89 {
90 relaxCheck_ = value;
91 }
92 inline double getAccuracyCheck() const
93 {
94 return relaxCheck_;
95 }
96
97 inline int maximumPivots() const
98 {
99 return maximumPivots_;
100 }
101
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
118 inline double slackValue() const
119 {
120 return slackValue_;
121 }
122 void slackValue(double value);
123#endif
127 virtual int *pivotRow() 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 }
148
152 inline void setSolveMode(int value)
153 {
154 solveMode_ = value;
155 }
156
157 virtual bool wantsTableauColumn() const;
162 virtual void setUsefulInformation(const int *info, int whereFrom);
164 virtual void clearArrays() {}
166
168
169 virtual int *indices() const = 0;
171 virtual int *permute() const = 0;
173 virtual int numberElements() const = 0;
175
177
178 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
219
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
249protected:
252
256#ifndef COIN_FAST_CODE
259#else
260#ifndef slackValue_
261#define slackValue_ -1.0
262#endif
263#endif
299};
300
306
308 friend void CoinDenseFactorizationUnitTest(const std::string &mpsDir);
309
310public:
313
317
325
328
329 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
351 virtual inline int numberElements() const
352 {
354 }
355
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
379
385 virtual inline int updateColumnFT(CoinIndexedVector *regionSparse,
386 CoinIndexedVector *regionSparse2,
387 bool = false)
388 {
389 return updateColumn(regionSparse, regionSparse2);
390 }
391
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
409
413
414 inline void clearArrays()
415 {
417 }
418
419 virtual inline int *indices() const
420 {
421 return reinterpret_cast< int * >(elements_ + numberRows_ * numberRows_);
422 }
423
424 virtual inline int *permute() const
425 {
426 return NULL; /*pivotRow_*/
427 ;
428 }
429
430
437
439protected:
442 int checkPivot(double saveFromU, double oldPivot) const;
444protected:
447
448};
449#endif
450
451/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
452*/
double CoinFactorizationDouble
Definition CoinTypes.hpp:57
virtual CoinOtherFactorization * clone() const
Clone.
virtual int factor()
Does most of factorization returning status 0 - OK -99 - needs more memory -1 - singular - use number...
void gutsOfInitialize()
The real work of constructor.
friend void CoinDenseFactorizationUnitTest(const std::string &mpsDir)
void clearArrays()
Get rid of all memory.
virtual int * indices() const
Returns array to put basis indices in.
void gutsOfDestructor()
The real work of desstructor.
virtual void postProcess(const int *sequence, int *pivotVariable)
Does post processing on valid factorization - putting variables on correct rows.
virtual int * permute() const
Returns permute in.
virtual void makeNonSingular(int *sequence, int numberColumns)
Makes a non-singular basis by replacing variables.
virtual void getAreas(int numberRows, int numberColumns, int maximumL, int maximumU)
Gets space for a factorization.
virtual ~CoinDenseFactorization()
Destructor.
CoinDenseFactorization & operator=(const CoinDenseFactorization &other)
= copy
int checkPivot(double saveFromU, double oldPivot) const
Returns accuracy status of replaceColumn returns 0=OK, 1=Probably OK, 2=singular.
double maximumCoefficient() const
Returns maximum absolute value in factorization.
void gutsOfCopy(const CoinDenseFactorization &other)
The real work of copy.
virtual void preProcess()
PreProcesses column ordered copy of basis.
CoinDenseFactorization(const CoinDenseFactorization &other)
Copy constructor.
virtual int updateTwoColumnsFT(CoinIndexedVector *regionSparse1, CoinIndexedVector *regionSparse2, CoinIndexedVector *regionSparse3, bool noPermute=false)
does FTRAN on two columns
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 >=0.
CoinDenseFactorization()
Default constructor.
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...
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...
virtual int numberElements() const
Total number of elements 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...
int factorElements_
Number of elements after factorization.
int numberGoodColumns() const
Number of good columns in factorization.
int maximumSpace_
Maximum length of iterating area.
virtual int numberElements() const =0
Total number of elements in factorization.
void setStatus(int value)
Sets status.
double slackValue_
Whether slack value is +1 or -1.
void pivotTolerance(double value)
double pivotTolerance_
Pivot tolerance.
int numberPivots_
Number pivots since last factorization.
double slackValue() const
Whether slack value is +1 or -1.
CoinOtherFactorization & operator=(const CoinOtherFactorization &other)
= copy
double zeroTolerance_
Zero tolerance.
double zeroTolerance() const
Zero tolerance.
int numberRows_
Number of Rows in factorization.
virtual CoinFactorizationDouble * elements() const
Returns array to put basis elements in.
virtual int * indices() const =0
Returns array to put basis indices in.
virtual void getAreas(int numberRows, int numberColumns, int maximumL, int maximumU)=0
Gets space for a factorization.
virtual int * intWorkArea() const
Returns int work area.
void setNumberRows(int value)
Set number of Rows after factorization.
int maximumRows_
Maximum rows ever (i.e. use to copy arrays etc)
virtual void makeNonSingular(int *sequence, int numberColumns)=0
Makes a non-singular basis by replacing variables.
CoinOtherFactorization(const CoinOtherFactorization &other)
Copy constructor.
virtual int updateTwoColumnsFT(CoinIndexedVector *regionSparse1, CoinIndexedVector *regionSparse2, CoinIndexedVector *regionSparse3, bool noPermute=false)=0
does FTRAN on two columns
virtual bool wantsTableauColumn() const
Returns true if wants tableauColumn in replaceColumn.
int maximumPivots_
Maximum number of pivots before factorization.
virtual void maximumPivots(int value)
Set maximum pivots.
void setPivots(int value)
Sets number of pivots since factorization.
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.
CoinFactorizationDouble * workArea_
Work area of numberRows_.
CoinFactorizationDouble * elements_
Elements of factorization and updates length is maxR*maxR+maxSpace will always be long enough so can ...
virtual int * numberInColumn() const
Number of entries in each column.
virtual int * permute() const =0
Returns permute in.
int numberColumns_
Number of Columns in factorization.
int numberRows() const
Number of Rows after factorization.
virtual void postProcess(const int *sequence, int *pivotVariable)=0
Does post processing on valid factorization - putting variables on correct rows.
virtual int * permuteBack() const
Returns permute back.
int status_
Status of 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...
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...
virtual int * starts() const
Returns array to put basis starts in.
void setSolveMode(int value)
Set solve mode e.g.
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 void preProcess()=0
PreProcesses column ordered copy of basis.
virtual ~CoinOtherFactorization()
Destructor.
double relaxCheck_
Relax check on accuracy in replaceColumn.
virtual CoinFactorizationDouble * workArea() const
Returns work area.
virtual int * numberInRow() const
Number of entries in each row.
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...
void relaxAccuracyCheck(double value)
Allows change of pivot accuracy check 1.0 == none >1.0 relaxed.
int solveMode() const
Get solve mode e.g.
int maximumPivots() const
Maximum number of pivots between factorizations.
virtual int * pivotRow() const
Returns pivot row.
int pivots() const
Returns number of pivots since factorization.
void zeroTolerance(double value)
int numberGoodU_
Number factorized in U (not row singletons)
CoinOtherFactorization()
Default constructor.
double pivotTolerance() const
Pivot tolerance.
int status() const
Returns status.
virtual int factor()=0
Does most of factorization returning status 0 - OK -99 - needs more memory -1 - singular - use number...
virtual void clearArrays()
Get rid of all memory.
virtual CoinOtherFactorization * clone() const =0
Clone.
void slackValue(double value)
int numberColumns() const
Total number of columns in factorization.
Sparse Matrix Base Class.