10 #ifndef ROL_PROJECTEDNEWTONKRYLOVSTEP_H
11 #define ROL_PROJECTEDNEWTONKRYLOVSTEP_H
42 ROL::Ptr<Vector<Real> >
gp_;
43 ROL::Ptr<Vector<Real> >
d_;
58 const ROL::Ptr<Objective<Real> >
obj_;
59 const ROL::Ptr<BoundConstraint<Real> >
bnd_;
60 const ROL::Ptr<Vector<Real> >
x_;
61 const ROL::Ptr<Vector<Real> >
g_;
62 ROL::Ptr<Vector<Real> >
v_;
86 const ROL::Ptr<Objective<Real> >
obj_;
88 const ROL::Ptr<BoundConstraint<Real> >
bnd_;
89 const ROL::Ptr<Vector<Real> >
x_;
90 const ROL::Ptr<Vector<Real> >
g_;
91 ROL::Ptr<Vector<Real> >
v_;
145 gp_(ROL::nullPtr),
d_(ROL::nullPtr),
149 ROL::ParameterList& Glist = parlist.sublist(
"General");
154 krylovName_ = Glist.sublist(
"Krylov").get(
"Type",
"Conjugate Gradients");
156 krylov_ = KrylovFactory<Real>(parlist);
158 secantName_ = Glist.sublist(
"Secant").get(
"Type",
"Limited-Memory BFGS");
161 secant_ = SecantFactory<Real>(parlist);
178 const bool computeObj =
true)
181 gp_(ROL::nullPtr),
d_(ROL::nullPtr),
185 ROL::ParameterList& Glist = parlist.sublist(
"General");
191 if (
secant_ == ROL::nullPtr ) {
192 secantName_ = Glist.sublist(
"Secant").get(
"Type",
"Limited-Memory BFGS");
194 secant_ = SecantFactory<Real>(parlist);
197 secantName_ = Glist.sublist(
"Secant").get(
"User Defined Secant Name",
198 "Unspecified User Defined Secant Method");
202 if (
krylov_ == ROL::nullPtr ) {
203 krylovName_ = Glist.sublist(
"Krylov").get(
"Type",
"Conjugate Gradients");
205 krylov_ = KrylovFactory<Real>(parlist);
224 ROL::Ptr<Objective<Real> > obj_ptr = ROL::makePtrFromRef(obj);
225 ROL::Ptr<BoundConstraint<Real> > bnd_ptr = ROL::makePtrFromRef(bnd);
226 ROL::Ptr<LinearOperator<Real> > hessian
227 = ROL::makePtr<HessianPNK>(obj_ptr,bnd_ptr,algo_state.
iterateVec,
228 step_state->gradientVec,algo_state.
gnorm);
229 ROL::Ptr<LinearOperator<Real> > precond;
231 precond = ROL::makePtr<PrecondPNK>(
secant_,bnd_ptr,
235 precond = ROL::makePtr<PrecondPNK>(obj_ptr,bnd_ptr,
245 s.
set((step_state->gradientVec)->dual());
253 Real tol = std::sqrt(ROL_EPSILON<Real>()), one(1);
263 (step_state->descentVec)->set(x);
264 (step_state->descentVec)->axpy(-one,*
d_);
269 gp_->set(*(step_state->gradientVec));
276 obj.
gradient(*(step_state->gradientVec),x,tol);
281 secant_->updateStorage(x,*(step_state->gradientVec),*
gp_,s,algo_state.
snorm,algo_state.
iter+1);
287 gp_->set(*(step_state->gradientVec));
293 d_->axpy(-one,(step_state->gradientVec)->dual());
301 std::stringstream hist;
304 hist << std::string(109,
'-') <<
"\n";
306 hist <<
" status output definitions\n\n";
307 hist <<
" iter - Number of iterates (steps taken) \n";
308 hist <<
" value - Objective function value \n";
309 hist <<
" gnorm - Norm of the gradient\n";
310 hist <<
" snorm - Norm of the step (update to optimization vector)\n";
311 hist <<
" #fval - Cumulative number of times the objective function was evaluated\n";
312 hist <<
" #grad - Number of times the gradient was computed\n";
313 hist <<
" iterCG - Number of Krylov iterations used to compute search direction\n";
314 hist <<
" flagCG - Krylov solver flag" <<
"\n";
315 hist << std::string(109,
'-') <<
"\n";
319 hist << std::setw(6) << std::left <<
"iter";
320 hist << std::setw(15) << std::left <<
"value";
321 hist << std::setw(15) << std::left <<
"gnorm";
322 hist << std::setw(15) << std::left <<
"snorm";
323 hist << std::setw(10) << std::left <<
"#fval";
324 hist << std::setw(10) << std::left <<
"#grad";
325 hist << std::setw(10) << std::left <<
"iterCG";
326 hist << std::setw(10) << std::left <<
"flagCG";
331 std::stringstream hist;
335 hist <<
" with " <<
secantName_ <<
" preconditioning";
341 std::stringstream hist;
342 hist << std::scientific << std::setprecision(6);
343 if ( algo_state.
iter == 0 ) {
346 if ( print_header ) {
349 if ( algo_state.
iter == 0 ) {
351 hist << std::setw(6) << std::left << algo_state.
iter;
352 hist << std::setw(15) << std::left << algo_state.
value;
353 hist << std::setw(15) << std::left << algo_state.
gnorm;
358 hist << std::setw(6) << std::left << algo_state.
iter;
359 hist << std::setw(15) << std::left << algo_state.
value;
360 hist << std::setw(15) << std::left << algo_state.
gnorm;
361 hist << std::setw(15) << std::left << algo_state.
snorm;
362 hist << std::setw(10) << std::left << algo_state.
nfval;
363 hist << std::setw(10) << std::left << algo_state.
ngrad;
Provides the interface to evaluate objective functions.
void applyInverse(Vector< Real > &Hv, const Vector< Real > &v, Real &tol) const
Apply inverse of linear operator.
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
bool useSecantPrecond_
Whether or not a secant approximation is used for preconditioning inexact Newton. ...
ROL::Ptr< Secant< Real > > secant_
Secant object (used for quasi-Newton)
virtual void scale(const Real alpha)=0
Compute where .
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
void update(Vector< Real > &x, const Vector< Real > &s, Objective< Real > &obj, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
Update step, if successful.
virtual void plus(const Vector &x)=0
Compute , where .
const ROL::Ptr< BoundConstraint< Real > > bnd_
void apply(Vector< Real > &Hv, const Vector< Real > &v, Real &tol) const
Apply linear operator.
const ROL::Ptr< Vector< Real > > g_
virtual Real value(const Vector< Real > &x, Real &tol)=0
Compute value.
Provides the interface to compute optimization steps.
const ROL::Ptr< Objective< Real > > obj_
ROL::Ptr< Vector< Real > > v_
Contains definitions of custom data types in ROL.
void compute(Vector< Real > &s, const Vector< Real > &x, Objective< Real > &obj, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
Compute step.
void apply(Vector< Real > &Hv, const Vector< Real > &v, Real &tol) const
Apply linear operator.
ESecant StringToESecant(std::string s)
std::string EDescentToString(EDescent tr)
Defines the linear algebra or vector space interface.
Provides the interface to compute optimization steps with projected inexact ProjectedNewton's method ...
virtual void update(const Vector< Real > &x, UpdateType type, int iter=-1)
Update objective function.
const ROL::Ptr< Vector< Real > > g_
ProjectedNewtonKrylovStep(ROL::ParameterList &parlist, const bool computeObj=true)
Constructor.
EKrylov
Enumeration of Krylov methods.
std::string printName(void) const
Print step name.
EKrylov StringToEKrylov(std::string s)
PrecondPNK(const ROL::Ptr< Objective< Real > > &obj, const ROL::Ptr< BoundConstraint< Real > > &bnd, const ROL::Ptr< Vector< Real > > &x, const ROL::Ptr< Vector< Real > > &g, Real eps=0)
ProjectedNewtonKrylovStep(ROL::ParameterList &parlist, const ROL::Ptr< Krylov< Real > > &krylov, const ROL::Ptr< Secant< Real > > &secant, const bool computeObj=true)
Constructor.
State for algorithm class. Will be used for restarts.
ROL::Ptr< Vector< Real > > d_
PrecondPNK(const ROL::Ptr< Secant< Real > > &secant, const ROL::Ptr< BoundConstraint< Real > > &bnd, const ROL::Ptr< Vector< Real > > &x, const ROL::Ptr< Vector< Real > > &g, Real eps=0)
std::string printHeader(void) const
Print iterate header.
virtual void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
bool useProjectedGrad_
Whether or not to use to the projected gradient criticality measure.
ESecant
Enumeration of secant update algorithms.
const ROL::Ptr< Vector< Real > > x_
ROL::Ptr< StepState< Real > > getState(void)
const ROL::Ptr< Secant< Real > > secant_
ROL::Ptr< Vector< Real > > v_
void initialize(Vector< Real > &x, const Vector< Real > &s, const Vector< Real > &g, Objective< Real > &obj, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
Initialize step with bound constraint.
int flagKrylov_
Termination flag for Krylov method (used for inexact Newton)
Provides interface for and implements limited-memory secant operators.
ROL::Ptr< Vector< Real > > iterateVec
virtual void project(Vector< Real > &x)
Project optimization variables onto the bounds.
Provides definitions for Krylov solvers.
Provides the interface to apply a linear operator.
ROL::Ptr< Vector< Real > > gp_
Provides the interface to apply upper and lower bound constraints.
HessianPNK(const ROL::Ptr< Objective< Real > > &obj, const ROL::Ptr< BoundConstraint< Real > > &bnd, const ROL::Ptr< Vector< Real > > &x, const ROL::Ptr< Vector< Real > > &g, Real eps=0)
void computeProjectedGradient(Vector< Real > &g, const Vector< Real > &x)
Compute projected gradient.
const ROL::Ptr< Vector< Real > > x_
int iterKrylov_
Number of Krylov iterations (used for inexact Newton)
virtual void initialize(Vector< Real > &x, const Vector< Real > &g, Objective< Real > &obj, BoundConstraint< Real > &con, AlgorithmState< Real > &algo_state)
Initialize step with bound constraint.
virtual void set(const Vector &x)
Set where .
const ROL::Ptr< BoundConstraint< Real > > bnd_
virtual Real norm() const =0
Returns where .
const ROL::Ptr< Objective< Real > > obj_
std::string print(AlgorithmState< Real > &algo_state, bool print_header=false) const
Print iterate status.
ROL::Ptr< Krylov< Real > > krylov_
Krylov solver object (used for inexact Newton)
int verbosity_
Verbosity level.