ClpCholeskyBase.hpp
Go to the documentation of this file.
1 /* $Id: ClpCholeskyBase.hpp 1722 2011-04-17 09:58:37Z stefan $ */
2 // Copyright (C) 2003, 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 #ifndef ClpCholeskyBase_H
7 #define ClpCholeskyBase_H
8 
9 #include "CoinPragma.hpp"
10 #include "CoinTypes.hpp"
11 //#define CLP_LONG_CHOLESKY 0
12 #ifndef CLP_LONG_CHOLESKY
13 #define CLP_LONG_CHOLESKY 0
14 #endif
15 /* valid combinations are
16  CLP_LONG_CHOLESKY 0 and COIN_LONG_WORK 0
17  CLP_LONG_CHOLESKY 1 and COIN_LONG_WORK 1
18  CLP_LONG_CHOLESKY 2 and COIN_LONG_WORK 1
19 */
20 #if COIN_LONG_WORK==0
21 #if CLP_LONG_CHOLESKY>0
22 #define CHOLESKY_BAD_COMBINATION
23 #endif
24 #else
25 #if CLP_LONG_CHOLESKY==0
26 #define CHOLESKY_BAD_COMBINATION
27 #endif
28 #endif
29 #ifdef CHOLESKY_BAD_COMBINATION
30 # warning("Bad combination of CLP_LONG_CHOLESKY and COIN_BIG_DOUBLE/COIN_LONG_WORK");
31 "Bad combination of CLP_LONG_CHOLESKY and COIN_LONG_WORK"
32 #endif
33 #if CLP_LONG_CHOLESKY>1
34 typedef long double longDouble;
35 #define CHOL_SMALL_VALUE 1.0e-15
36 #elif CLP_LONG_CHOLESKY==1
37 typedef double longDouble;
38 #define CHOL_SMALL_VALUE 1.0e-11
39 #else
40 typedef double longDouble;
41 #define CHOL_SMALL_VALUE 1.0e-11
42 #endif
43 class ClpInterior;
44 class ClpCholeskyDense;
45 class ClpMatrixBase;
46 
54 
55 public:
64  virtual int order(ClpInterior * model);
69  virtual int symbolic();
72  virtual int factorize(const CoinWorkDouble * diagonal, int * rowsDropped) ;
74  virtual void solve (CoinWorkDouble * region) ;
77  virtual void solveKKT (CoinWorkDouble * region1, CoinWorkDouble * region2, const CoinWorkDouble * diagonal,
78  CoinWorkDouble diagonalScaleFactor);
79 private:
81  int orderAMD();
82 public:
84 
87  inline int status() const {
89  return status_;
90  }
92  inline int numberRowsDropped() const {
93  return numberRowsDropped_;
94  }
96  void resetRowsDropped();
98  inline char * rowsDropped() const {
99  return rowsDropped_;
100  }
102  inline double choleskyCondition() const {
103  return choleskyCondition_;
104  }
106  inline double goDense() const {
107  return goDense_;
108  }
110  inline void setGoDense(double value) {
111  goDense_ = value;
112  }
114  inline int rank() const {
116  }
118  inline int numberRows() const {
119  return numberRows_;
120  }
122  inline CoinBigIndex size() const {
123  return sizeFactor_;
124  }
126  inline longDouble * sparseFactor() const {
127  return sparseFactor_;
128  }
130  inline longDouble * diagonal() const {
131  return diagonal_;
132  }
134  inline longDouble * workDouble() const {
135  return workDouble_;
136  }
138  inline bool kkt() const {
139  return doKKT_;
140  }
142  inline void setKKT(bool yesNo) {
143  doKKT_ = yesNo;
144  }
146  inline void setIntegerParameter(int i, int value) {
147  integerParameters_[i] = value;
148  }
150  inline int getIntegerParameter(int i) {
151  return integerParameters_[i];
152  }
154  inline void setDoubleParameter(int i, double value) {
155  doubleParameters_[i] = value;
156  }
158  inline double getDoubleParameter(int i) {
159  return doubleParameters_[i];
160  }
162 
163 
164 public:
165 
171  ClpCholeskyBase(int denseThreshold = -1);
173  virtual ~ClpCholeskyBase();
179 
180  virtual ClpCholeskyBase * clone() const;
183 
185  inline int type() const {
186  if (doKKT_) return 100;
187  else return type_;
188  }
189 protected:
191  inline void setType(int type) {
192  type_ = type;
193  }
195  inline void setModel(ClpInterior * model) {
196  model_ = model;
197  }
199 
206  int symbolic1(const CoinBigIndex * Astart, const int * Arow);
210  void symbolic2(const CoinBigIndex * Astart, const int * Arow);
214  void factorizePart2(int * rowsDropped) ;
218  void solve(CoinWorkDouble * region, int type);
220  int preOrder(bool lowerTriangular, bool includeDiagonal, bool doKKT);
222  void updateDense(longDouble * d, /*longDouble * work,*/ int * first);
224 
225 protected:
229  int type_;
232  bool doKKT_;
234  double goDense_;
244  int status_;
246  char * rowsDropped_;
250  int * permute_;
266  int * link_;
267  // Integer work array
269  // Clique information
270  int * clique_;
280  double doubleParameters_[64];
284  char * whichDense_;
292 };
293 
294 #endif
int CoinBigIndex
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.
double CoinWorkDouble
Definition: CoinTypes.hpp:53
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.