44 #ifndef ROL_NEWTONKRYLOV_U_H
45 #define ROL_NEWTONKRYLOV_U_H
62 template<
typename Real>
80 const Ptr<Objective<Real>>
obj_;
81 const Ptr<const Vector<Real>>
x_;
86 obj_->hessVec(Hv,v,*
x_,tol);
92 const Ptr<Objective<Real>>
obj_;
93 const Ptr<const Vector<Real>>
x_;
101 obj_->precond(Hv,v,*
x_,tol);
117 ParameterList& Glist = parlist.sublist(
"General");
120 krylovName_ = Glist.sublist(
"Krylov").get(
"Type",
"Conjugate Gradients");
122 krylov_ = KrylovFactory<Real>(parlist);
124 secantName_ = Glist.sublist(
"Secant").get(
"Type",
"Limited-Memory BFGS");
127 secant_ = SecantFactory<Real>(parlist);
143 const Ptr<
Secant<Real>> &secant,
const bool computeObj =
true)
148 ParameterList& Glist = parlist.sublist(
"General");
153 secantName_ = Glist.sublist(
"Secant").get(
"Type",
"Limited-Memory BFGS");
155 secant_ = SecantFactory<Real>(parlist);
158 secantName_ = Glist.sublist(
"Secant").get(
"User Defined Secant Name",
159 "Unspecified User Defined Secant Method");
165 krylovName_ = Glist.sublist(
"Krylov").get(
"Type",
"Conjugate Gradients");
167 krylov_ = KrylovFactory<Real>(parlist);
170 krylovName_ = Glist.sublist(
"Krylov").get(
"User Defined Krylov Name",
171 "Unspecified User Defined Krylov Method");
178 Ptr<Objective<Real>> obj_ptr = makePtrFromRef(obj);
179 Ptr<const Vector<Real>> x_ptr = makePtrFromRef(x);
180 Ptr<LinearOperator<Real>> hessian
181 = makePtr<HessianNK>(obj_ptr,x_ptr);
182 Ptr<LinearOperator<Real>> precond;
184 precond = makePtr<PrecondNK>(obj_ptr,x_ptr);
189 krylov_->run(s,*hessian,g,*precond,iter,flag);
192 if ( flag == 2 && iter <= 1 ) {
195 s.
scale(static_cast<Real>(-1));
203 const Real snorm,
const int iter)
override {
206 secant_->updateStorage(x,gnew,gold,s,snorm,iter+1);
211 std::stringstream name;
212 name <<
"Newton-Krylov Method using " <<
krylovName_;
214 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