ROL
ROL_SemismoothNewtonProjection.hpp
Go to the documentation of this file.
1// @HEADER
2// ************************************************************************
3//
4// Rapid Optimization Library (ROL) Package
5// Copyright (2014) Sandia Corporation
6//
7// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8// license for use of this work by or on behalf of the U.S. Government.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact lead developers:
38// Drew Kouri (dpkouri@sandia.gov) and
39// Denis Ridzal (dridzal@sandia.gov)
40//
41// ************************************************************************
42// @HEADER
43
44
45#ifndef ROL_SEMISMOOTHNEWTONPROJECTION_H
46#define ROL_SEMISMOOTHNEWTONPROJECTION_H
47
49#include "ROL_ParameterList.hpp"
50#include "ROL_KrylovFactory.hpp"
51
52namespace ROL {
53
54template<typename Real>
56private:
57 int dim_;
58 Ptr<Krylov<Real>> krylov_;
59 Ptr<Vector<Real>> xnew_, lnew_, dlam_;
60
65
69
76
77public:
78
80 const Vector<Real> &xdual,
81 const Ptr<BoundConstraint<Real>> &bnd,
82 const Ptr<Constraint<Real>> &con,
83 const Vector<Real> &mul,
84 const Vector<Real> &res);
85
87 const Vector<Real> &xdual,
88 const Ptr<BoundConstraint<Real>> &bnd,
89 const Ptr<Constraint<Real>> &con,
90 const Vector<Real> &mul,
91 const Vector<Real> &res,
92 ParameterList &list);
93
94 void project(Vector<Real> &x, std::ostream &stream = std::cout) override;
95
96private:
97
98 // Jv = inv(A DP(y) A^T) v
99 // y = P(x + A^T lam)
100 class Jacobian : public LinearOperator<Real> {
101 private:
102 const Ptr<Constraint<Real>> con_;
103 const Ptr<BoundConstraint<Real>> bnd_;
104 const Ptr<const Vector<Real>> y_;
105 const Ptr<Vector<Real>> xdual_, xprim_;
106 const Real alpha_;
107 public:
108 Jacobian(const Ptr<Constraint<Real>> &con,
109 const Ptr<BoundConstraint<Real>> &bnd,
110 const Ptr<const Vector<Real>> &y,
111 const Ptr<Vector<Real>> &xdual,
112 const Ptr<Vector<Real>> &xprim,
113 const Real alpha = 1e-4)
114 : con_(con), bnd_(bnd), y_(y), xdual_(xdual), xprim_(xprim), alpha_(alpha) {}
115 void apply(Vector<Real> &Jx, const Vector<Real> &x, Real &tol) const {
116 con_->applyAdjointJacobian(*xdual_,x.dual(),*y_,tol);
117 xprim_->set(xdual_->dual());
118 bnd_->pruneActive(*xprim_,*y_);
119 con_->applyJacobian(Jx,*xprim_,*y_,tol);
120 // This is a hack to make the Jacobian invertible
121 Jx.axpy(alpha_,x);
122 }
123 };
124
125 class Precond : public LinearOperator<Real> {
126 private:
127 const Real alpha_;
128 public:
129 Precond(Real alpha = 1e-4) : alpha_(alpha) {}
130 void apply( Vector<Real> &Hv, const Vector<Real> &v, Real &tol ) const {
131 const Real one(1);
132 Hv.set(v.dual());
133 Hv.scale(one+alpha_);
134 }
135 void applyInverse( Vector<Real> &Hv, const Vector<Real> &v, Real &tol ) const {
136 const Real one(1);
137 Hv.set(v.dual());
138 Hv.scale(one/(one+alpha_));
139 }
140 };
141
142 Real residual(Vector<Real> &r, const Vector<Real> &y) const;
143
145 const Vector<Real> &r,
146 const Vector<Real> &y,
147 const Real mu,
148 const Real rho,
149 int &iter,
150 int &flag) const;
151
153 const Vector<Real> &x,
154 const Vector<Real> &lam) const;
155
157 Vector<Real> &lam,
158 Vector<Real> &dlam,
159 std::ostream &stream = std::cout) const;
160
161 Real compute_tolerance() const;
162
163}; // class SemismoothNewtonProjection
164
165} // namespace ROL
166
168
169#endif
Provides the interface to apply upper and lower bound constraints.
Defines the general constraint operator interface.
Provides the interface to apply a linear operator.
const Ptr< Constraint< Real > > con_
const Ptr< BoundConstraint< Real > > bnd_
void apply(Vector< Real > &Jx, const Vector< Real > &x, Real &tol) const
Apply linear operator.
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 applyInverse(Vector< Real > &Hv, const Vector< Real > &v, Real &tol) const
Apply inverse of linear operator.
void apply(Vector< Real > &Hv, const Vector< Real > &v, Real &tol) const
Apply linear operator.
void update_primal(Vector< Real > &y, const Vector< Real > &x, const Vector< Real > &lam) const
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
void project_ssn(Vector< Real > &x, Vector< Real > &lam, Vector< Real > &dlam, std::ostream &stream=std::cout) const
void project(Vector< Real > &x, std::ostream &stream=std::cout) override
Real residual(Vector< Real > &r, const Vector< Real > &y) const
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:84
virtual void set(const Vector &x)
Set where .
Definition: ROL_Vector.hpp:209
virtual void scale(const Real alpha)=0
Compute where .
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:226
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
Definition: ROL_Vector.hpp:153