10 #ifndef ROL_NEWTONKRYLOV_U_H
11 #define ROL_NEWTONKRYLOV_U_H
28 template<
typename Real>
46 const Ptr<Objective<Real>>
obj_;
47 const Ptr<const Vector<Real>>
x_;
52 obj_->hessVec(Hv,v,*
x_,tol);
58 const Ptr<Objective<Real>>
obj_;
59 const Ptr<const Vector<Real>>
x_;
67 obj_->precond(Hv,v,*
x_,tol);
83 ParameterList& Glist = parlist.sublist(
"General");
86 krylovName_ = Glist.sublist(
"Krylov").get(
"Type",
"Conjugate Gradients");
88 krylov_ = KrylovFactory<Real>(parlist);
90 secantName_ = Glist.sublist(
"Secant").get(
"Type",
"Limited-Memory BFGS");
93 secant_ = SecantFactory<Real>(parlist);
109 const Ptr<
Secant<Real>> &secant,
const bool computeObj =
true)
114 ParameterList& Glist = parlist.sublist(
"General");
119 secantName_ = Glist.sublist(
"Secant").get(
"Type",
"Limited-Memory BFGS");
121 secant_ = SecantFactory<Real>(parlist);
124 secantName_ = Glist.sublist(
"Secant").get(
"User Defined Secant Name",
125 "Unspecified User Defined Secant Method");
131 krylovName_ = Glist.sublist(
"Krylov").get(
"Type",
"Conjugate Gradients");
133 krylov_ = KrylovFactory<Real>(parlist);
136 krylovName_ = Glist.sublist(
"Krylov").get(
"User Defined Krylov Name",
137 "Unspecified User Defined Krylov Method");
144 Ptr<Objective<Real>> obj_ptr = makePtrFromRef(obj);
145 Ptr<const Vector<Real>> x_ptr = makePtrFromRef(x);
146 Ptr<LinearOperator<Real>> hessian
147 = makePtr<HessianNK>(obj_ptr,x_ptr);
148 Ptr<LinearOperator<Real>> precond;
150 precond = makePtr<PrecondNK>(obj_ptr,x_ptr);
155 krylov_->run(s,*hessian,g,*precond,iter,flag);
158 if ( flag == 2 && iter <= 1 ) {
161 s.
scale(static_cast<Real>(-1));
169 const Real snorm,
const int iter)
override {
172 secant_->updateStorage(x,gnew,gold,s,snorm,iter+1);
177 std::stringstream name;
178 name <<
"Newton-Krylov Method using " <<
krylovName_;
180 name <<
" with " <<
secantName_ <<
" preconditioning";
Provides the interface to evaluate objective functions.
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
virtual void scale(const Real alpha)=0
Compute where .
NewtonKrylov_U(ParameterList &parlist, const Ptr< Krylov< Real >> &krylov, const Ptr< Secant< Real >> &secant, const bool computeObj=true)
Constructor.
virtual Real apply(const Vector< Real > &x) const
Apply to a dual vector. This is equivalent to the call .
const Ptr< Objective< Real > > obj_
Ptr< Secant< Real > > secant_
Secant object (used for quasi-Newton)
Contains definitions of custom data types in ROL.
NewtonKrylov_U(ParameterList &parlist)
Constructor.
const Ptr< const Vector< Real > > x_
bool useSecantPrecond_
Whether or not a secant approximation is used for preconditioning inexact Newton. ...
Provides the interface to compute optimization steps with projected inexact Newton's method using lin...
ESecant StringToESecant(std::string s)
std::string printName(void) const override
Defines the linear algebra or vector space interface.
HessianNK(const Ptr< Objective< Real >> &obj, const Ptr< const Vector< Real >> &x)
EKrylov
Enumeration of Krylov methods.
EKrylov StringToEKrylov(std::string s)
const Ptr< const Vector< Real > > x_
void applyInverse(Vector< Real > &Hv, const Vector< Real > &v, Real &tol) const
Apply inverse of linear operator.
ESecant
Enumeration of secant update algorithms.
void apply(Vector< Real > &Hv, const Vector< Real > &v, Real &tol) const
Apply linear operator.
Provides interface for and implements limited-memory secant operators.
void apply(Vector< Real > &Hv, const Vector< Real > &v, Real &tol) const
Apply linear operator.
Ptr< LinearOperator< Real > > precond_
Provides definitions for Krylov solvers.
Provides the interface to apply a linear operator.
virtual void set(const Vector &x)
Set where .
virtual Real norm() const =0
Returns where .
Provides the interface to compute unconstrained optimization steps for line search.
const Ptr< Objective< Real > > obj_
Ptr< Krylov< Real > > krylov_
Krylov solver object (used for inexact Newton)
PrecondNK(const Ptr< Objective< Real >> &obj, const Ptr< const Vector< Real >> &x)
void compute(Vector< Real > &s, Real &snorm, Real &sdotg, int &iter, int &flag, const Vector< Real > &x, const Vector< Real > &g, Objective< Real > &obj) override
void update(const Vector< Real > &x, const Vector< Real > &s, const Vector< Real > &gold, const Vector< Real > &gnew, const Real snorm, const int iter) override