Ignore:
Timestamp:
Jan 6, 2019 2:43:06 PM (3 months ago)
Author:
unxusr
Message:

formatting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Clp/src/ClpCholeskyBase.hpp

    r2271 r2385  
    1818   CLP_LONG_CHOLESKY 2 and COIN_LONG_WORK 1
    1919*/
    20 #if COIN_LONG_WORK==0
    21 #if CLP_LONG_CHOLESKY>0
     20#if COIN_LONG_WORK == 0
     21#if CLP_LONG_CHOLESKY > 0
    2222#define CHOLESKY_BAD_COMBINATION
    2323#endif
    2424#else
    25 #if CLP_LONG_CHOLESKY==0
     25#if CLP_LONG_CHOLESKY == 0
    2626#define CHOLESKY_BAD_COMBINATION
    2727#endif
    2828#endif
    2929#ifdef CHOLESKY_BAD_COMBINATION
    30 #  warning("Bad combination of CLP_LONG_CHOLESKY and COIN_BIG_DOUBLE/COIN_LONG_WORK");
     30#warning("Bad combination of CLP_LONG_CHOLESKY and COIN_BIG_DOUBLE/COIN_LONG_WORK");
    3131"Bad combination of CLP_LONG_CHOLESKY and COIN_LONG_WORK"
    3232#endif
    33 #if CLP_LONG_CHOLESKY>1
    34 typedef long double longDouble;
     33#if CLP_LONG_CHOLESKY > 1
     34  typedef long double longDouble;
    3535#define CHOL_SMALL_VALUE 1.0e-15
    36 #elif CLP_LONG_CHOLESKY==1
     36#elif CLP_LONG_CHOLESKY == 1
    3737typedef double longDouble;
    3838#define CHOL_SMALL_VALUE 1.0e-11
     
    5151*/
    5252
    53 class ClpCholeskyBase  {
     53class ClpCholeskyBase {
    5454
    5555public:
    56      /**@name Virtual methods that the derived classes may provide  */
    57      //@{
    58      /** Orders rows and saves pointer to matrix.and model.
     56  /**@name Virtual methods that the derived classes may provide  */
     57  //@{
     58  /** Orders rows and saves pointer to matrix.and model.
    5959      returns non-zero if not enough memory.
    6060      You can use preOrder to set up ADAT
     
    6262      size of input matrix to order (and to symbolic).
    6363      Also just permute_ and permuteInverse_ should be created */
    64      virtual int order(ClpInterior * model);
    65      /** Does Symbolic factorization given permutation.
     64  virtual int order(ClpInterior *model);
     65  /** Does Symbolic factorization given permutation.
    6666         This is called immediately after order.  If user provides this then
    6767         user must provide factorize and solve.  Otherwise the default factorization is used
    6868         returns non-zero if not enough memory */
    69      virtual int symbolic();
    70      /** Factorize - filling in rowsDropped and returning number dropped.
     69  virtual int symbolic();
     70  /** Factorize - filling in rowsDropped and returning number dropped.
    7171         If return code negative then out of memory */
    72      virtual int factorize(const CoinWorkDouble * diagonal, int * rowsDropped) ;
    73      /** Uses factorization to solve. */
    74      virtual void solve (CoinWorkDouble * region) ;
    75      /** Uses factorization to solve. - given as if KKT.
     72  virtual int factorize(const CoinWorkDouble *diagonal, int *rowsDropped);
     73  /** Uses factorization to solve. */
     74  virtual void solve(CoinWorkDouble *region);
     75  /** Uses factorization to solve. - given as if KKT.
    7676      region1 is rows+columns, region2 is rows */
    77      virtual void solveKKT (CoinWorkDouble * region1, CoinWorkDouble * region2, const CoinWorkDouble * diagonal,
    78                             CoinWorkDouble diagonalScaleFactor);
     77  virtual void solveKKT(CoinWorkDouble *region1, CoinWorkDouble *region2, const CoinWorkDouble *diagonal,
     78    CoinWorkDouble diagonalScaleFactor);
     79
    7980private:
    80      /// AMD ordering
    81      int orderAMD();
     81  /// AMD ordering
     82  int orderAMD();
     83
    8284public:
    83      //@}
    84 
    85      /**@name Gets */
    86      //@{
    87      /// status.  Returns status
    88      inline int status() const {
    89           return status_;
    90      }
    91      /// numberRowsDropped.  Number of rows gone
    92      inline int numberRowsDropped() const {
    93           return numberRowsDropped_;
    94      }
    95      /// reset numberRowsDropped and rowsDropped.
    96      void resetRowsDropped();
    97      /// rowsDropped - which rows are gone
    98      inline char * rowsDropped() const {
    99           return rowsDropped_;
    100      }
    101      /// choleskyCondition.
    102      inline double choleskyCondition() const {
    103           return choleskyCondition_;
    104      }
    105      /// goDense i.e. use dense factoriaztion if > this (default 0.7).
    106      inline double goDense() const {
    107           return goDense_;
    108      }
    109      /// goDense i.e. use dense factoriaztion if > this (default 0.7).
    110      inline void setGoDense(double value) {
    111           goDense_ = value;
    112      }
    113      /// rank.  Returns rank
    114      inline int rank() const {
    115           return numberRows_ - numberRowsDropped_;
    116      }
    117      /// Return number of rows
    118      inline int numberRows() const {
    119           return numberRows_;
    120      }
    121      /// Return size
    122      inline int size() const {
    123           return sizeFactor_;
    124      }
    125      /// Return sparseFactor
    126      inline longDouble * sparseFactor() const {
    127           return sparseFactor_;
    128      }
    129      /// Return diagonal
    130      inline longDouble * diagonal() const {
    131           return diagonal_;
    132      }
    133      /// Return workDouble
    134      inline longDouble * workDouble() const {
    135           return workDouble_;
    136      }
    137      /// If KKT on
    138      inline bool kkt() const {
    139           return doKKT_;
    140      }
    141      /// Set KKT
    142      inline void setKKT(bool yesNo) {
    143           doKKT_ = yesNo;
    144      }
    145      /// Set integer parameter
    146      inline void setIntegerParameter(int i, int value) {
    147           integerParameters_[i] = value;
    148      }
    149      /// get integer parameter
    150      inline int getIntegerParameter(int i) {
    151           return integerParameters_[i];
    152      }
    153      /// Set double parameter
    154      inline void setDoubleParameter(int i, double value) {
    155           doubleParameters_[i] = value;
    156      }
    157      /// get double parameter
    158      inline double getDoubleParameter(int i) {
    159           return doubleParameters_[i];
    160      }
    161      //@}
    162 
     85  //@}
     86
     87  /**@name Gets */
     88  //@{
     89  /// status.  Returns status
     90  inline int status() const
     91  {
     92    return status_;
     93  }
     94  /// numberRowsDropped.  Number of rows gone
     95  inline int numberRowsDropped() const
     96  {
     97    return numberRowsDropped_;
     98  }
     99  /// reset numberRowsDropped and rowsDropped.
     100  void resetRowsDropped();
     101  /// rowsDropped - which rows are gone
     102  inline char *rowsDropped() const
     103  {
     104    return rowsDropped_;
     105  }
     106  /// choleskyCondition.
     107  inline double choleskyCondition() const
     108  {
     109    return choleskyCondition_;
     110  }
     111  /// goDense i.e. use dense factoriaztion if > this (default 0.7).
     112  inline double goDense() const
     113  {
     114    return goDense_;
     115  }
     116  /// goDense i.e. use dense factoriaztion if > this (default 0.7).
     117  inline void setGoDense(double value)
     118  {
     119    goDense_ = value;
     120  }
     121  /// rank.  Returns rank
     122  inline int rank() const
     123  {
     124    return numberRows_ - numberRowsDropped_;
     125  }
     126  /// Return number of rows
     127  inline int numberRows() const
     128  {
     129    return numberRows_;
     130  }
     131  /// Return size
     132  inline int size() const
     133  {
     134    return sizeFactor_;
     135  }
     136  /// Return sparseFactor
     137  inline longDouble *sparseFactor() const
     138  {
     139    return sparseFactor_;
     140  }
     141  /// Return diagonal
     142  inline longDouble *diagonal() const
     143  {
     144    return diagonal_;
     145  }
     146  /// Return workDouble
     147  inline longDouble *workDouble() const
     148  {
     149    return workDouble_;
     150  }
     151  /// If KKT on
     152  inline bool kkt() const
     153  {
     154    return doKKT_;
     155  }
     156  /// Set KKT
     157  inline void setKKT(bool yesNo)
     158  {
     159    doKKT_ = yesNo;
     160  }
     161  /// Set integer parameter
     162  inline void setIntegerParameter(int i, int value)
     163  {
     164    integerParameters_[i] = value;
     165  }
     166  /// get integer parameter
     167  inline int getIntegerParameter(int i)
     168  {
     169    return integerParameters_[i];
     170  }
     171  /// Set double parameter
     172  inline void setDoubleParameter(int i, double value)
     173  {
     174    doubleParameters_[i] = value;
     175  }
     176  /// get double parameter
     177  inline double getDoubleParameter(int i)
     178  {
     179    return doubleParameters_[i];
     180  }
     181  //@}
    163182
    164183public:
    165 
    166      /**@name Constructors, destructor
     184  /**@name Constructors, destructor
    167185      */
    168      //@{
    169      /** Constructor which has dense columns activated.
     186  //@{
     187  /** Constructor which has dense columns activated.
    170188         Default is off. */
    171      ClpCholeskyBase(int denseThreshold = -1);
    172      /** Destructor (has to be public) */
    173      virtual ~ClpCholeskyBase();
    174      /// Copy
    175      ClpCholeskyBase(const ClpCholeskyBase&);
    176      /// Assignment
    177      ClpCholeskyBase& operator=(const ClpCholeskyBase&);
    178      //@}
    179      //@{
    180      ///@name Other
    181      /// Clone
    182      virtual ClpCholeskyBase * clone() const;
    183 
    184      /// Returns type
    185      inline int type() const {
    186           if (doKKT_) return 100;
    187           else return type_;
    188      }
     189  ClpCholeskyBase(int denseThreshold = -1);
     190  /** Destructor (has to be public) */
     191  virtual ~ClpCholeskyBase();
     192  /// Copy
     193  ClpCholeskyBase(const ClpCholeskyBase &);
     194  /// Assignment
     195  ClpCholeskyBase &operator=(const ClpCholeskyBase &);
     196  //@}
     197  //@{
     198  ///@name Other
     199  /// Clone
     200  virtual ClpCholeskyBase *clone() const;
     201
     202  /// Returns type
     203  inline int type() const
     204  {
     205    if (doKKT_)
     206      return 100;
     207    else
     208      return type_;
     209  }
     210
    189211protected:
    190      /// Sets type
    191      inline void setType(int type) {
    192           type_ = type;
    193      }
    194      /// model.
    195      inline void setModel(ClpInterior * model) {
    196           model_ = model;
    197      }
    198      //@}
    199 
    200      /**@name Symbolic, factor and solve */
    201      //@{
    202      /** Symbolic1  - works out size without clever stuff.
     212  /// Sets type
     213  inline void setType(int type)
     214  {
     215    type_ = type;
     216  }
     217  /// model.
     218  inline void setModel(ClpInterior *model)
     219  {
     220    model_ = model;
     221  }
     222  //@}
     223
     224  /**@name Symbolic, factor and solve */
     225  //@{
     226  /** Symbolic1  - works out size without clever stuff.
    203227         Uses upper triangular as much easier.
    204228         Returns size
    205229      */
    206      int symbolic1(const int * Astart, const int * Arow);
    207      /** Symbolic2  - Fills in indices
     230  int symbolic1(const int *Astart, const int *Arow);
     231  /** Symbolic2  - Fills in indices
    208232         Uses lower triangular so can do cliques etc
    209233      */
    210      void symbolic2(const int * Astart, const int * Arow);
    211      /** Factorize - filling in rowsDropped and returning number dropped
     234  void symbolic2(const int *Astart, const int *Arow);
     235  /** Factorize - filling in rowsDropped and returning number dropped
    212236         in integerParam.
    213237      */
    214      void factorizePart2(int * rowsDropped) ;
    215      /** solve - 1 just first half, 2 just second half - 3 both.
     238  void factorizePart2(int *rowsDropped);
     239  /** solve - 1 just first half, 2 just second half - 3 both.
    216240     If 1 and 2 then diagonal has sqrt of inverse otherwise inverse
    217241     */
    218      void solve(CoinWorkDouble * region, int type);
    219      /// Forms ADAT - returns nonzero if not enough memory
    220      int preOrder(bool lowerTriangular, bool includeDiagonal, bool doKKT);
    221      /// Updates dense part (broken out for profiling)
    222      void updateDense(longDouble * d, /*longDouble * work,*/ int * first);
    223      //@}
     242  void solve(CoinWorkDouble *region, int type);
     243  /// Forms ADAT - returns nonzero if not enough memory
     244  int preOrder(bool lowerTriangular, bool includeDiagonal, bool doKKT);
     245  /// Updates dense part (broken out for profiling)
     246  void updateDense(longDouble *d, /*longDouble * work,*/ int *first);
     247  //@}
    224248
    225249protected:
    226      /**@name Data members
     250  /**@name Data members
    227251        The data members are protected to allow access for derived classes. */
    228      //@{
    229      /// type (may be useful) if > 20 do KKT
    230      int type_;
    231      /// Doing full KKT (only used if default symbolic and factorization)
    232      bool doKKT_;
    233      /// Go dense at this fraction
    234      double goDense_;
    235      /// choleskyCondition.
    236      double choleskyCondition_;
    237      /// model.
    238      ClpInterior * model_;
    239      /// numberTrials.  Number of trials before rejection
    240      int numberTrials_;
    241      /// numberRows.  Number of Rows in factorization
    242      int numberRows_;
    243      /// status.  Status of factorization
    244      int status_;
    245      /// rowsDropped
    246      char * rowsDropped_;
    247      /// permute inverse.
    248      int * permuteInverse_;
    249      /// main permute.
    250      int * permute_;
    251      /// numberRowsDropped.  Number of rows gone
    252      int numberRowsDropped_;
    253      /// sparseFactor.
    254      longDouble * sparseFactor_;
    255      /// choleskyStart - element starts
    256      int * choleskyStart_;
    257      /// choleskyRow (can be shorter than sparsefactor)
    258      int * choleskyRow_;
    259      /// Index starts
    260      int * indexStart_;
    261      /// Diagonal
    262      longDouble * diagonal_;
    263      /// double work array
    264      longDouble * workDouble_;
    265      /// link array
    266      int * link_;
    267      // Integer work array
    268      int * workInteger_;
    269      // Clique information
    270      int * clique_;
    271      /// sizeFactor.
    272      int sizeFactor_;
    273      /// Size of index array
    274      int sizeIndex_;
    275      /// First dense row
    276      int firstDense_;
    277      /// integerParameters
    278      int integerParameters_[64];
    279      /// doubleParameters;
    280      double doubleParameters_[64];
    281      /// Row copy of matrix
    282      ClpMatrixBase * rowCopy_;
    283      /// Dense indicators
    284      char * whichDense_;
    285      /// Dense columns (updated)
    286      longDouble * denseColumn_;
    287      /// Dense cholesky
    288      ClpCholeskyDense * dense_;
    289      /// Dense threshold (for taking out of Cholesky)
    290      int denseThreshold_;
    291      //@}
     252  //@{
     253  /// type (may be useful) if > 20 do KKT
     254  int type_;
     255  /// Doing full KKT (only used if default symbolic and factorization)
     256  bool doKKT_;
     257  /// Go dense at this fraction
     258  double goDense_;
     259  /// choleskyCondition.
     260  double choleskyCondition_;
     261  /// model.
     262  ClpInterior *model_;
     263  /// numberTrials.  Number of trials before rejection
     264  int numberTrials_;
     265  /// numberRows.  Number of Rows in factorization
     266  int numberRows_;
     267  /// status.  Status of factorization
     268  int status_;
     269  /// rowsDropped
     270  char *rowsDropped_;
     271  /// permute inverse.
     272  int *permuteInverse_;
     273  /// main permute.
     274  int *permute_;
     275  /// numberRowsDropped.  Number of rows gone
     276  int numberRowsDropped_;
     277  /// sparseFactor.
     278  longDouble *sparseFactor_;
     279  /// choleskyStart - element starts
     280  int *choleskyStart_;
     281  /// choleskyRow (can be shorter than sparsefactor)
     282  int *choleskyRow_;
     283  /// Index starts
     284  int *indexStart_;
     285  /// Diagonal
     286  longDouble *diagonal_;
     287  /// double work array
     288  longDouble *workDouble_;
     289  /// link array
     290  int *link_;
     291  // Integer work array
     292  int *workInteger_;
     293  // Clique information
     294  int *clique_;
     295  /// sizeFactor.
     296  int sizeFactor_;
     297  /// Size of index array
     298  int sizeIndex_;
     299  /// First dense row
     300  int firstDense_;
     301  /// integerParameters
     302  int integerParameters_[64];
     303  /// doubleParameters;
     304  double doubleParameters_[64];
     305  /// Row copy of matrix
     306  ClpMatrixBase *rowCopy_;
     307  /// Dense indicators
     308  char *whichDense_;
     309  /// Dense columns (updated)
     310  longDouble *denseColumn_;
     311  /// Dense cholesky
     312  ClpCholeskyDense *dense_;
     313  /// Dense threshold (for taking out of Cholesky)
     314  int denseThreshold_;
     315  //@}
    292316};
    293317
    294318#endif
     319
     320/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
     321*/
Note: See TracChangeset for help on using the changeset viewer.