44 #ifndef ROL_NEWTONKRYLOVSTEP_H 45 #define ROL_NEWTONKRYLOVSTEP_H 75 Teuchos::RCP<Vector<Real> >
gp_;
86 const Teuchos::RCP<Objective<Real> >
obj_;
87 const Teuchos::RCP<Vector<Real> >
x_;
92 obj_->hessVec(Hv,v,*
x_,tol);
98 const Teuchos::RCP<Objective<Real> >
obj_;
99 const Teuchos::RCP<Vector<Real> >
x_;
107 obj_->precond(Hv,v,*
x_,tol);
129 Teuchos::ParameterList& Glist = parlist.sublist(
"General");
134 krylov_ = KrylovFactory<Real>(parlist);
138 secant_ = SecantFactory<Real>(parlist);
155 const bool computeObj =
true)
161 Teuchos::ParameterList& Glist = parlist.sublist(
"General");
167 secant_ = SecantFactory<Real>(parlist);
170 if (
krylov_ == Teuchos::null ) {
172 krylov_ = KrylovFactory<Real>(parlist);
192 Teuchos::RCP<Objective<Real> > obj_ptr = Teuchos::rcpFromRef(obj);
193 Teuchos::RCP<LinearOperator<Real> > hessian
195 Teuchos::RCP<LinearOperator<Real> > precond;
209 s.
set((step_state->gradientVec)->dual());
217 Real tol = std::sqrt(ROL_EPSILON<Real>());
223 (step_state->descentVec)->
set(s);
228 gp_->set(*(step_state->gradientVec));
235 obj.
gradient(*(step_state->gradientVec),x,tol);
240 secant_->updateStorage(x,*(step_state->gradientVec),*
gp_,s,algo_state.
snorm,algo_state.
iter+1);
245 algo_state.
gnorm = step_state->gradientVec->norm();
249 std::stringstream hist;
252 hist << std::string(109,
'-') <<
"\n";
254 hist <<
" status output definitions\n\n";
255 hist <<
" iter - Number of iterates (steps taken) \n";
256 hist <<
" value - Objective function value \n";
257 hist <<
" gnorm - Norm of the gradient\n";
258 hist <<
" snorm - Norm of the step (update to optimization vector)\n";
259 hist <<
" #fval - Cumulative number of times the objective function was evaluated\n";
260 hist <<
" #grad - Number of times the gradient was computed\n";
261 hist <<
" iterCG - Number of Krylov iterations used to compute search direction\n";
262 hist <<
" flagCG - Krylov solver flag" <<
"\n";
263 hist << std::string(109,
'-') <<
"\n";
267 hist << std::setw(6) << std::left <<
"iter";
268 hist << std::setw(15) << std::left <<
"value";
269 hist << std::setw(15) << std::left <<
"gnorm";
270 hist << std::setw(15) << std::left <<
"snorm";
271 hist << std::setw(10) << std::left <<
"#fval";
272 hist << std::setw(10) << std::left <<
"#grad";
273 hist << std::setw(10) << std::left <<
"iterCG";
274 hist << std::setw(10) << std::left <<
"flagCG";
279 std::stringstream hist;
289 std::stringstream hist;
290 hist << std::scientific << std::setprecision(6);
291 if ( algo_state.
iter == 0 ) {
294 if ( print_header ) {
297 if ( algo_state.
iter == 0 ) {
299 hist << std::setw(6) << std::left << algo_state.
iter;
300 hist << std::setw(15) << std::left << algo_state.
value;
301 hist << std::setw(15) << std::left << algo_state.
gnorm;
306 hist << std::setw(6) << std::left << algo_state.
iter;
307 hist << std::setw(15) << std::left << algo_state.
value;
308 hist << std::setw(15) << std::left << algo_state.
gnorm;
309 hist << std::setw(15) << std::left << algo_state.
snorm;
310 hist << std::setw(10) << std::left << algo_state.
nfval;
311 hist << std::setw(10) << std::left << algo_state.
ngrad;
const Teuchos::RCP< Vector< Real > > x_
Provides the interface to evaluate objective functions.
virtual void scale(const Real alpha)=0
Compute where .
Teuchos::RCP< Vector< Real > > gp_
virtual void plus(const Vector &x)=0
Compute , where .
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 Real value(const Vector< Real > &x, Real &tol)=0
Compute value.
Provides the interface to compute optimization steps.
int verbosity_
Verbosity level.
const Teuchos::RCP< Objective< Real > > obj_
Teuchos::RCP< StepState< Real > > getState(void)
Contains definitions of custom data types in ROL.
virtual Teuchos::RCP< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
Teuchos::RCP< Krylov< Real > > krylov_
Krylov solver object (used for inexact Newton)
ESecant StringToESecant(std::string s)
std::string EDescentToString(EDescent tr)
PrecondNK(const Teuchos::RCP< Objective< Real > > &obj, const Teuchos::RCP< Vector< Real > > &x)
int flagKrylov_
Termination flag for Krylov method (used for inexact Newton)
Defines the linear algebra or vector space interface.
EKrylov
Enumeration of Krylov methods.
EKrylov StringToEKrylov(std::string s)
State for algorithm class. Will be used for restarts.
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.
virtual void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
std::string printHeader(void) const
Print iterate header.
HessianNK(const Teuchos::RCP< Objective< Real > > &obj, const Teuchos::RCP< Vector< Real > > &x)
ESecant
Enumeration of secant update algorithms.
void compute(Vector< Real > &s, const Vector< Real > &x, Objective< Real > &obj, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
Compute step.
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.
Provides interface for and implements limited-memory secant operators.
Provides definitions for Krylov solvers.
Provides the interface to apply a linear operator.
Provides the interface to apply upper and lower bound constraints.
std::string print(AlgorithmState< Real > &algo_state, bool print_header=false) const
Print iterate status.
NewtonKrylovStep(Teuchos::ParameterList &parlist, const bool computeObj=true)
Constructor.
std::string EKrylovToString(EKrylov tr)
Provides the interface to compute optimization steps with projected inexact Newton's method using lin...
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.
Teuchos::RCP< Vector< Real > > iterateVec
virtual void set(const Vector &x)
Set where .
virtual Real norm() const =0
Returns where .
virtual void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Update objective function.
Teuchos::RCP< Secant< Real > > secant_
Secant object (used for quasi-Newton)
std::string printName(void) const
Print step name.
const Teuchos::RCP< Vector< Real > > x_
bool useSecantPrecond_
Whether or not a secant approximation is used for preconditioning inexact Newton. ...
std::string ESecantToString(ESecant tr)
const Teuchos::RCP< Objective< Real > > obj_
NewtonKrylovStep(Teuchos::ParameterList &parlist, const Teuchos::RCP< Krylov< Real > > &krylov, const Teuchos::RCP< Secant< Real > > &secant, const bool computeObj=true)
Constructor.