ClpCholeskyBase.hpp
Go to the documentation of this file.
1 /* $Id: ClpCholeskyBase.hpp 1525 2010-02-26 17:27:59Z mjs $ */
2 // Copyright (C) 2003, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 #ifndef ClpCholeskyBase_H
5 #define ClpCholeskyBase_H
6 
7 #include "CoinPragma.hpp"
8 #include "CoinFinite.hpp"
9 //#define CLP_LONG_CHOLESKY 0
10 #ifndef CLP_LONG_CHOLESKY
11 #define CLP_LONG_CHOLESKY 0
12 #endif
13 /* valid combinations are
14  CLP_LONG_CHOLESKY 0 and COIN_LONG_WORK 0
15  CLP_LONG_CHOLESKY 1 and COIN_LONG_WORK 1
16  CLP_LONG_CHOLESKY 2 and COIN_LONG_WORK 1
17 */
18 #if COIN_LONG_WORK==0
19 #if CLP_LONG_CHOLESKY>0
20 #define CHOLESKY_BAD_COMBINATION
21 #endif
22 #else
23 #if CLP_LONG_CHOLESKY==0
24 #define CHOLESKY_BAD_COMBINATION
25 #endif
26 #endif
27 #ifdef CHOLESKY_BAD_COMBINATION
28 # warning("Bad combination of CLP_LONG_CHOLESKY and COIN_BIG_DOUBLE/COIN_LONG_WORK");
29 "Bad combination of CLP_LONG_CHOLESKY and COIN_LONG_WORK"
30 #endif
31 #if CLP_LONG_CHOLESKY>1
32 typedef long double longDouble;
33 #define CHOL_SMALL_VALUE 1.0e-15
34 #elif CLP_LONG_CHOLESKY==1
35 typedef double longDouble;
36 #define CHOL_SMALL_VALUE 1.0e-11
37 #else
38 typedef double longDouble;
39 #define CHOL_SMALL_VALUE 1.0e-11
40 #endif
41 class ClpInterior;
42 class ClpCholeskyDense;
43 class ClpMatrixBase;
44 
52 
53 public:
62  virtual int order(ClpInterior * model);
67  virtual int symbolic();
70  virtual int factorize(const CoinWorkDouble * diagonal, int * rowsDropped) ;
72  virtual void solve (CoinWorkDouble * region) ;
75  virtual void solveKKT (CoinWorkDouble * region1, CoinWorkDouble * region2, const CoinWorkDouble * diagonal,
76  CoinWorkDouble diagonalScaleFactor);
77 private:
79  int orderAMD();
80 public:
82 
85  inline int status() const {
87  return status_;
88  }
90  inline int numberRowsDropped() const {
91  return numberRowsDropped_;
92  }
94  void resetRowsDropped();
96  inline char * rowsDropped() const {
97  return rowsDropped_;
98  }
100  inline double choleskyCondition() const {
101  return choleskyCondition_;
102  }
104  inline double goDense() const {
105  return goDense_;
106  }
108  inline void setGoDense(double value) {
109  goDense_ = value;
110  }
112  inline int rank() const {
114  }
116  inline int numberRows() const {
117  return numberRows_;
118  }
120  inline CoinBigIndex size() const {
121  return sizeFactor_;
122  }
124  inline longDouble * sparseFactor() const {
125  return sparseFactor_;
126  }
128  inline longDouble * diagonal() const {
129  return diagonal_;
130  }
132  inline longDouble * workDouble() const {
133  return workDouble_;
134  }
136  inline bool kkt() const {
137  return doKKT_;
138  }
140  inline void setKKT(bool yesNo) {
141  doKKT_ = yesNo;
142  }
144  inline void setIntegerParameter(int i, int value) {
145  integerParameters_[i] = value;
146  }
148  inline int getIntegerParameter(int i) {
149  return integerParameters_[i];
150  }
152  inline void setDoubleParameter(int i, double value) {
153  doubleParameters_[i] = value;
154  }
156  inline double getDoubleParameter(int i) {
157  return doubleParameters_[i];
158  }
160 
161 
162 public:
163 
169  ClpCholeskyBase(int denseThreshold = -1);
171  virtual ~ClpCholeskyBase();
177 
178  virtual ClpCholeskyBase * clone() const;
181 
183  inline int type() const {
184  if (doKKT_) return 100;
185  else return type_;
186  }
187 protected:
189  inline void setType(int type) {
190  type_ = type;
191  }
193  inline void setModel(ClpInterior * model) {
194  model_ = model;
195  }
197 
204  int symbolic1(const CoinBigIndex * Astart, const int * Arow);
208  void symbolic2(const CoinBigIndex * Astart, const int * Arow);
212  void factorizePart2(int * rowsDropped) ;
216  void solve(CoinWorkDouble * region, int type);
218  int preOrder(bool lowerTriangular, bool includeDiagonal, bool doKKT);
220  void updateDense(longDouble * d, /*longDouble * work,*/ int * first);
222 
223 protected:
227  int type_;
230  bool doKKT_;
232  double goDense_;
242  int status_;
244  char * rowsDropped_;
248  int * permute_;
254  CoinBigIndex * choleskyStart_;
258  CoinBigIndex * indexStart_;
264  int * link_;
265  // Integer work array
266  CoinBigIndex * workInteger_;
267  // Clique information
268  int * clique_;
270  CoinBigIndex sizeFactor_;
272  CoinBigIndex sizeIndex_;
278  double doubleParameters_[64];
282  char * whichDense_;
290 };
291 
292 #endif
int status_
status. Status of factorization
bool kkt() const
If KKT on.
virtual ClpCholeskyBase * clone() const
Returns type.
virtual void solve(CoinWorkDouble *region)
Uses factorization to solve.
longDouble * sparseFactor_
sparseFactor.
double getDoubleParameter(int i)
get double parameter
char * whichDense_
Dense indicators.
int * link_
link array
int numberRowsDropped_
numberRowsDropped. Number of rows gone
int * choleskyRow_
choleskyRow (can be shorter than sparsefactor)
void updateDense(longDouble *d, int *first)
Updates dense part (broken out for profiling)
CoinBigIndex sizeIndex_
Size of index array.
bool doKKT_
Doing full KKT (only used if default symbolic and factorization)
int * clique_
type (may be useful) if > 20 do KKT
int numberRows() const
Return number of rows.
void resetRowsDropped()
reset numberRowsDropped and rowsDropped.
char * rowsDropped() const
rowsDropped - which rows are gone
int numberRows_
numberRows. Number of Rows in factorization
void factorizePart2(int *rowsDropped)
Factorize - filling in rowsDropped and returning number dropped in integerParam.
int status() const
status. Returns status
int preOrder(bool lowerTriangular, bool includeDiagonal, bool doKKT)
Forms ADAT - returns nonzero if not enough memory.
int symbolic1(const CoinBigIndex *Astart, const int *Arow)
Symbolic1 - works out size without clever stuff.
Base class for Clp Cholesky factorization Will do better factorization.
longDouble * diagonal() const
Return diagonal.
int numberRowsDropped() const
numberRowsDropped. Number of rows gone
ClpInterior * model_
model.
virtual ~ClpCholeskyBase()
Destructor (has to be public)
virtual int factorize(const CoinWorkDouble *diagonal, int *rowsDropped)
Factorize - filling in rowsDropped and returning number dropped.
This solves LPs using interior point methods.
Definition: ClpInterior.hpp:72
CoinBigIndex * workInteger_
type (may be useful) if > 20 do KKT
double choleskyCondition_
choleskyCondition.
longDouble * workDouble_
double work array
longDouble * denseColumn_
Dense columns (updated)
int * permuteInverse_
permute inverse.
int rank() const
rank. Returns rank
virtual int order(ClpInterior *model)
Orders rows and saves pointer to matrix.and model.
int firstDense_
First dense row.
void setIntegerParameter(int i, int value)
Set integer parameter.
CoinBigIndex size() const
Return size.
longDouble * workDouble() const
Return workDouble.
double choleskyCondition() const
choleskyCondition.
int denseThreshold_
Dense threshold (for taking out of Cholesky)
ClpCholeskyDense * dense_
Dense cholesky.
void setDoubleParameter(int i, double value)
Set double parameter.
double doubleParameters_[64]
doubleParameters;
CoinBigIndex * choleskyStart_
choleskyStart - element starts
char * rowsDropped_
rowsDropped
Abstract base class for Clp Matrices.
int integerParameters_[64]
integerParameters
int orderAMD()
AMD ordering.
ClpCholeskyBase(int denseThreshold=-1)
Constructor which has dense columns activated.
virtual int symbolic()
Does Symbolic factorization given permutation.
double goDense() const
goDense i.e. use dense factoriaztion if > this (default 0.7).
int type() const
Returns type.
void setKKT(bool yesNo)
Set KKT.
void setType(int type)
Sets type.
int type_
type (may be useful) if > 20 do KKT
virtual void solveKKT(CoinWorkDouble *region1, CoinWorkDouble *region2, const CoinWorkDouble *diagonal, CoinWorkDouble diagonalScaleFactor)
Uses factorization to solve.
longDouble * sparseFactor() const
Return sparseFactor.
int numberTrials_
numberTrials. Number of trials before rejection
longDouble * diagonal_
Diagonal.
void setGoDense(double value)
goDense i.e. use dense factoriaztion if > this (default 0.7).
double longDouble
ClpMatrixBase * rowCopy_
Row copy of matrix.
CoinBigIndex * indexStart_
Index starts.
int getIntegerParameter(int i)
get integer parameter
CoinBigIndex sizeFactor_
sizeFactor.
int * permute_
main permute.
void setModel(ClpInterior *model)
model.
void symbolic2(const CoinBigIndex *Astart, const int *Arow)
Symbolic2 - Fills in indices Uses lower triangular so can do cliques etc.
ClpCholeskyBase & operator=(const ClpCholeskyBase &)
Assignment.
double goDense_
Go dense at this fraction.