44 #ifndef ROL_PROJECTEDNEWTONKRYLOVSTEP_H 45 #define ROL_PROJECTEDNEWTONKRYLOVSTEP_H 76 Teuchos::RCP<Vector<Real> >
gp_;
77 Teuchos::RCP<Vector<Real> >
d_;
89 const Teuchos::RCP<Objective<Real> >
obj_;
90 const Teuchos::RCP<BoundConstraint<Real> >
bnd_;
91 const Teuchos::RCP<Vector<Real> >
x_;
92 const Teuchos::RCP<Vector<Real> >
g_;
93 Teuchos::RCP<Vector<Real> >
v_;
117 const Teuchos::RCP<Objective<Real> >
obj_;
119 const Teuchos::RCP<BoundConstraint<Real> >
bnd_;
120 const Teuchos::RCP<Vector<Real> >
x_;
121 const Teuchos::RCP<Vector<Real> >
g_;
122 Teuchos::RCP<Vector<Real> >
v_;
176 gp_(Teuchos::null),
d_(Teuchos::null),
180 Teuchos::ParameterList& Glist = parlist.sublist(
"General");
186 krylov_ = KrylovFactory<Real>(parlist);
190 secant_ = SecantFactory<Real>(parlist);
207 const bool computeObj =
true)
210 gp_(Teuchos::null),
d_(Teuchos::null),
214 Teuchos::ParameterList& Glist = parlist.sublist(
"General");
221 secant_ = SecantFactory<Real>(parlist);
224 if (
krylov_ == Teuchos::null ) {
226 krylov_ = KrylovFactory<Real>(parlist);
245 Teuchos::RCP<Objective<Real> > obj_ptr = Teuchos::rcpFromRef(obj);
246 Teuchos::RCP<BoundConstraint<Real> > bnd_ptr = Teuchos::rcpFromRef(bnd);
247 Teuchos::RCP<LinearOperator<Real> > hessian
249 step_state->gradientVec,algo_state.
gnorm));
250 Teuchos::RCP<LinearOperator<Real> > precond;
256 precond = Teuchos::rcp(
new PrecondPNK(obj_ptr,bnd_ptr,
266 s.
set((step_state->gradientVec)->dual());
274 Real tol = std::sqrt(ROL_EPSILON<Real>()), one(1);
282 (step_state->descentVec)->
set(x);
283 (step_state->descentVec)->axpy(-one,*
d_);
288 gp_->set(*(step_state->gradientVec));
295 obj.
gradient(*(step_state->gradientVec),x,tol);
300 secant_->updateStorage(x,*(step_state->gradientVec),*
gp_,s,algo_state.
snorm,algo_state.
iter+1);
306 gp_->set(*(step_state->gradientVec));
312 d_->axpy(-one,(step_state->gradientVec)->dual());
320 std::stringstream hist;
323 hist << std::string(109,
'-') <<
"\n";
325 hist <<
" status output definitions\n\n";
326 hist <<
" iter - Number of iterates (steps taken) \n";
327 hist <<
" value - Objective function value \n";
328 hist <<
" gnorm - Norm of the gradient\n";
329 hist <<
" snorm - Norm of the step (update to optimization vector)\n";
330 hist <<
" #fval - Cumulative number of times the objective function was evaluated\n";
331 hist <<
" #grad - Number of times the gradient was computed\n";
332 hist <<
" iterCG - Number of Krylov iterations used to compute search direction\n";
333 hist <<
" flagCG - Krylov solver flag" <<
"\n";
334 hist << std::string(109,
'-') <<
"\n";
338 hist << std::setw(6) << std::left <<
"iter";
339 hist << std::setw(15) << std::left <<
"value";
340 hist << std::setw(15) << std::left <<
"gnorm";
341 hist << std::setw(15) << std::left <<
"snorm";
342 hist << std::setw(10) << std::left <<
"#fval";
343 hist << std::setw(10) << std::left <<
"#grad";
344 hist << std::setw(10) << std::left <<
"iterCG";
345 hist << std::setw(10) << std::left <<
"flagCG";
350 std::stringstream hist;
360 std::stringstream hist;
361 hist << std::scientific << std::setprecision(6);
362 if ( algo_state.
iter == 0 ) {
365 if ( print_header ) {
368 if ( algo_state.
iter == 0 ) {
370 hist << std::setw(6) << std::left << algo_state.
iter;
371 hist << std::setw(15) << std::left << algo_state.
value;
372 hist << std::setw(15) << std::left << algo_state.
gnorm;
377 hist << std::setw(6) << std::left << algo_state.
iter;
378 hist << std::setw(15) << std::left << algo_state.
value;
379 hist << std::setw(15) << std::left << algo_state.
gnorm;
380 hist << std::setw(15) << std::left << algo_state.
snorm;
381 hist << std::setw(10) << std::left << algo_state.
nfval;
382 hist << std::setw(10) << std::left << algo_state.
ngrad;
Provides the interface to evaluate objective functions.
bool useSecantPrecond_
Whether or not a secant approximation is used for preconditioning inexact Newton. ...
virtual void scale(const Real alpha)=0
Compute where .
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(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 .
PrecondPNK(const Teuchos::RCP< Secant< Real > > &secant, const Teuchos::RCP< BoundConstraint< Real > > &bnd, const Teuchos::RCP< Vector< Real > > &x, const Teuchos::RCP< Vector< Real > > &g, Real eps=0)
Teuchos::RCP< Vector< Real > > v_
virtual Real value(const Vector< Real > &x, Real &tol)=0
Compute value.
Provides the interface to compute optimization steps.
std::string printName(void) const
Print step name.
Teuchos::RCP< StepState< Real > > getState(void)
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.
Teuchos::RCP< Vector< Real > > gp_
virtual Teuchos::RCP< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
ESecant StringToESecant(std::string s)
std::string EDescentToString(EDescent tr)
const Teuchos::RCP< Secant< Real > > secant_
Defines the linear algebra or vector space interface.
Provides the interface to compute optimization steps with projected inexact ProjectedNewton's method ...
EKrylov
Enumeration of Krylov methods.
EKrylov StringToEKrylov(std::string s)
State for algorithm class. Will be used for restarts.
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.
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
void apply(Vector< Real > &Hv, const Vector< Real > &v, Real &tol) const
Apply linear operator.
ESecant
Enumeration of secant update algorithms.
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)
ProjectedNewtonKrylovStep(Teuchos::ParameterList &parlist, const Teuchos::RCP< Krylov< Real > > &krylov, const Teuchos::RCP< Secant< Real > > &secant, const bool computeObj=true)
Constructor.
Provides interface for and implements limited-memory secant operators.
std::string printHeader(void) const
Print iterate header.
const Teuchos::RCP< Vector< Real > > g_
std::string print(AlgorithmState< Real > &algo_state, bool print_header=false) const
Print iterate status.
const Teuchos::RCP< BoundConstraint< Real > > bnd_
Teuchos::RCP< Secant< Real > > secant_
Secant object (used for quasi-Newton)
Provides definitions for Krylov solvers.
Provides the interface to apply a linear operator.
PrecondPNK(const Teuchos::RCP< Objective< Real > > &obj, const Teuchos::RCP< BoundConstraint< Real > > &bnd, const Teuchos::RCP< Vector< Real > > &x, const Teuchos::RCP< Vector< Real > > &g, Real eps=0)
Provides the interface to apply upper and lower bound constraints.
const Teuchos::RCP< Vector< Real > > x_
void computeProjectedGradient(Vector< Real > &g, const Vector< Real > &x)
Compute projected gradient.
std::string EKrylovToString(EKrylov tr)
Teuchos::RCP< Vector< Real > > v_
const Teuchos::RCP< Objective< Real > > obj_
int iterKrylov_
Number of Krylov iterations (used for inexact Newton)
Teuchos::RCP< Krylov< Real > > krylov_
Krylov solver object (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.
const Teuchos::RCP< Vector< Real > > g_
ProjectedNewtonKrylovStep(Teuchos::ParameterList &parlist, const bool computeObj=true)
Constructor.
Teuchos::RCP< Vector< Real > > iterateVec
virtual void set(const Vector &x)
Set where .
HessianPNK(const Teuchos::RCP< Objective< Real > > &obj, const Teuchos::RCP< BoundConstraint< Real > > &bnd, const Teuchos::RCP< Vector< Real > > &x, const Teuchos::RCP< Vector< Real > > &g, Real eps=0)
virtual Real norm() const =0
Returns where .
virtual void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Update objective function.
const Teuchos::RCP< Vector< Real > > x_
const Teuchos::RCP< Objective< Real > > obj_
std::string ESecantToString(ESecant tr)
const Teuchos::RCP< BoundConstraint< Real > > bnd_
Teuchos::RCP< Vector< Real > > d_
virtual void project(Vector< Real > &x)
Project optimization variables onto the bounds.
int verbosity_
Verbosity level.