ROL
ROL_SemismoothNewtonProjection.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Rapid Optimization Library (ROL) Package
4 //
5 // Copyright 2014 NTESS and the ROL contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef ROL_SEMISMOOTHNEWTONPROJECTION_H
11 #define ROL_SEMISMOOTHNEWTONPROJECTION_H
12 
14 #include "ROL_ParameterList.hpp"
15 #include "ROL_KrylovFactory.hpp"
16 
17 namespace ROL {
18 
19 template<typename Real>
21 private:
22  int dim_;
23  Ptr<Krylov<Real>> krylov_;
24  Ptr<Vector<Real>> xnew_, lnew_, dlam_;
25 
30 
33  bool useproj_;
34 
41 
42 public:
43 
45  const Vector<Real> &xdual,
46  const Ptr<BoundConstraint<Real>> &bnd,
47  const Ptr<Constraint<Real>> &con,
48  const Vector<Real> &mul,
49  const Vector<Real> &res);
50 
52  const Vector<Real> &xdual,
53  const Ptr<BoundConstraint<Real>> &bnd,
54  const Ptr<Constraint<Real>> &con,
55  const Vector<Real> &mul,
56  const Vector<Real> &res,
57  ParameterList &list);
58 
59  void project(Vector<Real> &x, std::ostream &stream = std::cout) override;
60 
61 private:
62 
63  // Jv = inv(A DP(y) A^T) v
64  // y = P(x + A^T lam)
65  class Jacobian : public LinearOperator<Real> {
66  private:
67  const Ptr<Constraint<Real>> con_;
68  const Ptr<BoundConstraint<Real>> bnd_;
69  const Ptr<const Vector<Real>> y_;
70  const Ptr<Vector<Real>> xdual_, xprim_;
71  const Real alpha_;
72  public:
73  Jacobian(const Ptr<Constraint<Real>> &con,
74  const Ptr<BoundConstraint<Real>> &bnd,
75  const Ptr<const Vector<Real>> &y,
76  const Ptr<Vector<Real>> &xdual,
77  const Ptr<Vector<Real>> &xprim,
78  const Real alpha = 1e-4)
79  : con_(con), bnd_(bnd), y_(y), xdual_(xdual), xprim_(xprim), alpha_(alpha) {}
80  void apply(Vector<Real> &Jx, const Vector<Real> &x, Real &tol) const {
81  con_->applyAdjointJacobian(*xdual_,x.dual(),*y_,tol);
82  xprim_->set(xdual_->dual());
83  bnd_->pruneActive(*xprim_,*y_);
84  con_->applyJacobian(Jx,*xprim_,*y_,tol);
85  // This is a hack to make the Jacobian invertible
86  Jx.axpy(alpha_,x);
87  }
88  };
89 
90  class Precond : public LinearOperator<Real> {
91  private:
92  const Real alpha_;
93  public:
94  Precond(Real alpha = 1e-4) : alpha_(alpha) {}
95  void apply( Vector<Real> &Hv, const Vector<Real> &v, Real &tol ) const {
96  const Real one(1);
97  Hv.set(v.dual());
98  Hv.scale(one+alpha_);
99  }
100  void applyInverse( Vector<Real> &Hv, const Vector<Real> &v, Real &tol ) const {
101  const Real one(1);
102  Hv.set(v.dual());
103  Hv.scale(one/(one+alpha_));
104  }
105  };
106 
107  Real residual(Vector<Real> &r, const Vector<Real> &y) const;
108 
110  const Vector<Real> &r,
111  const Vector<Real> &y,
112  const Real mu,
113  const Real rho,
114  int &iter,
115  int &flag) const;
116 
117  void update_primal(Vector<Real> &y,
118  const Vector<Real> &x,
119  const Vector<Real> &lam) const;
120 
121  void project_ssn(Vector<Real> &x,
122  Vector<Real> &lam,
123  Vector<Real> &dlam,
124  std::ostream &stream = std::cout) const;
125 
126  Real compute_tolerance() const;
127 
128 }; // class SemismoothNewtonProjection
129 
130 } // namespace ROL
131 
133 
134 #endif
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
Definition: ROL_Vector.hpp:192
virtual void scale(const Real alpha)=0
Compute where .
void project(Vector< Real > &x, std::ostream &stream=std::cout) override
SemismoothNewtonProjection(const Vector< Real > &xprim, const Vector< Real > &xdual, const Ptr< BoundConstraint< Real >> &bnd, const Ptr< Constraint< Real >> &con, const Vector< Real > &mul, const Vector< Real > &res)
void solve_newton_system(Vector< Real > &s, const Vector< Real > &r, const Vector< Real > &y, const Real mu, const Real rho, int &iter, int &flag) const
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
Definition: ROL_Vector.hpp:119
void applyInverse(Vector< Real > &Hv, const Vector< Real > &v, Real &tol) const
Apply inverse of linear operator.
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:46
void apply(Vector< Real > &Jx, const Vector< Real > &x, Real &tol) const
Apply linear operator.
void apply(Vector< Real > &Hv, const Vector< Real > &v, Real &tol) const
Apply linear operator.
Provides the interface to apply a linear operator.
Provides the interface to apply upper and lower bound constraints.
Real residual(Vector< Real > &r, const Vector< Real > &y) const
Jacobian(const Ptr< Constraint< Real >> &con, const Ptr< BoundConstraint< Real >> &bnd, const Ptr< const Vector< Real >> &y, const Ptr< Vector< Real >> &xdual, const Ptr< Vector< Real >> &xprim, const Real alpha=1e-4)
void project_ssn(Vector< Real > &x, Vector< Real > &lam, Vector< Real > &dlam, std::ostream &stream=std::cout) const
virtual void set(const Vector &x)
Set where .
Definition: ROL_Vector.hpp:175
void update_primal(Vector< Real > &y, const Vector< Real > &x, const Vector< Real > &lam) const
Defines the general constraint operator interface.