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 
86  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 
179 
180  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 
228  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