Chombo + EB  3.2
ConstrainedLS.H
Go to the documentation of this file.
1 #ifdef CH_LANG_CC
2 /*
3  * _______ __
4  * / ___/ / ___ __ _ / / ___
5  * / /__/ _ \/ _ \/ V \/ _ \/ _ \
6  * \___/_//_/\___/_/_/_/_.__/\___/
7  * Please refer to Copyright.txt, in Chombo's root directory.
8  */
9 #endif
10 
11 #ifndef _CONSTRAINEDLS_H_
12 #define _CONSTRAINEDLS_H_
13 
14 #include "Vector.H"
15 #include "REAL.H"
16 #include "RealVect.H"
17 #include "NamespaceHeader.H"
18 
20 {
21 public:
22  enum Bound
23  {
27  };
28 
29  enum LSResult
30  {
36  };
37 
38  ConstrainedLS();
39 
40  ///
41  /** Solve the bound-constrained least squares
42  Uses the Lawson-Hanson active set method
43  as given by P.B. Stark and R.L. Parker,
44  Bounded-Variable Least-Squares: An Algorithm
45  and Applications, Computational Statistics, 10:129-141, 1995.
46  Uses solveUnconstrained for sub-problems
47  */
49  Real** a_A,
50  const Vector<Real>& a_rhs,
51  const Vector<Real>& a_lowerBound,
52  const Vector<Real>& a_upperBound);
53 
54  /** Solve the unconstrained least squares problem
55  */
57  Real** a_A,
58  const Vector<Real> & a_rhs);
59 
60  bool boundsConsistent(const Vector<Real> & a_lowBound,
61  const Vector<Real> & a_hiBound) const;
62 
63  /** Get a vector of Bound indicating constraint activity.
64  */
66 
67  /** Query the number of active constraints.
68  Bails if a LS problem has not been solved yet
69  */
70  int numberActiveConstraints() const;
71 
72  /** Get the LS residual
73  Bails if a LS problem has not been solved yet
74  */
75  Real getResidual() const;
76 
77  /** Solve the least squares problem.
78  Uses successive Householder rotations
79  */
80  LSResult qrSolution(Real ** a_A,
81  Vector<Real> & a_x,
82  Vector<Real> & a_b,
83  Real & resq);
84 
85 
86 
87 
88 protected:
90  int m_nbound;
91 
92 
93 
94 private:
96  void allocArray(const int& rows,
97  const int& cols,
98  Real**& A);
99 
100  void freeArray(const int& rows,
101  const int& cols,
102  Real**& A);
103 
104 
105 };
106 
107 #include "NamespaceFooter.H"
108 #endif
Real m_residual
Definition: ConstrainedLS.H:95
LSResult solveBoundConstrained(Vector< Real > &a_x, Real **a_A, const Vector< Real > &a_rhs, const Vector< Real > &a_lowerBound, const Vector< Real > &a_upperBound)
Definition: ConstrainedLS.H:32
int numberActiveConstraints() const
LSResult solveUnconstrained(Vector< Real > &a_x, Real **a_A, const Vector< Real > &a_rhs)
Definition: ConstrainedLS.H:33
Bound
Definition: ConstrainedLS.H:22
void allocArray(const int &rows, const int &cols, Real **&A)
LSResult qrSolution(Real **a_A, Vector< Real > &a_x, Vector< Real > &a_b, Real &resq)
Definition: ConstrainedLS.H:35
LSResult
Definition: ConstrainedLS.H:29
Vector< Bound > m_boundState
Definition: ConstrainedLS.H:89
Definition: ConstrainedLS.H:24
Definition: ConstrainedLS.H:31
void const char const int const int const int const Real const Real * A
Definition: Lapack.H:83
double Real
Definition: REAL.H:33
Real getResidual() const
Definition: ConstrainedLS.H:26
bool boundsConsistent(const Vector< Real > &a_lowBound, const Vector< Real > &a_hiBound) const
Definition: ConstrainedLS.H:25
int m_nbound
Definition: ConstrainedLS.H:90
Vector< Bound > getConstraints() const
Definition: ConstrainedLS.H:19
void freeArray(const int &rows, const int &cols, Real **&A)
Definition: ConstrainedLS.H:34