10 #ifndef ROL_NONLINEARCGSTEP_H
11 #define ROL_NONLINEARCGSTEP_H
29 ROL::Ptr<NonlinearCG<Real> >
nlcg_;
52 const ROL::Ptr<NonlinearCG<Real> > &nlcg = ROL::nullPtr,
53 const bool computeObj =
true )
57 verbosity_ = parlist.sublist(
"General").get(
"Print Verbosity",0);
59 ROL::ParameterList& Llist = parlist.sublist(
"Step").sublist(
"Line Search");
60 if ( nlcg == ROL::nullPtr ) {
61 ncgName_ = Llist.sublist(
"Descent Method").get(
"Nonlinear CG Type",
"Oren-Luenberger");
67 ncgName_ = Llist.sublist(
"Descent Method").get(
"User Defined Nonlinear CG Name",
68 "Unspecified User Define Nonlinear CG Method");
79 nlcg_->run(s,*(step_state->gradientVec),x,obj);
85 Real tol = std::sqrt(ROL_EPSILON<Real>());
91 (step_state->descentVec)->set(s);
100 obj.
gradient(*(step_state->gradientVec),x,tol);
105 algo_state.
gnorm = (step_state->gradientVec)->norm();
109 std::stringstream hist;
112 hist << std::string(109,
'-') <<
"\n";
114 hist <<
" status output definitions\n\n";
115 hist <<
" iter - Number of iterates (steps taken) \n";
116 hist <<
" value - Objective function value \n";
117 hist <<
" gnorm - Norm of the gradient\n";
118 hist <<
" snorm - Norm of the step (update to optimization vector)\n";
119 hist <<
" #fval - Cumulative number of times the objective function was evaluated\n";
120 hist <<
" #grad - Number of times the gradient was computed\n";
121 hist << std::string(109,
'-') <<
"\n";
125 hist << std::setw(6) << std::left <<
"iter";
126 hist << std::setw(15) << std::left <<
"value";
127 hist << std::setw(15) << std::left <<
"gnorm";
128 hist << std::setw(15) << std::left <<
"snorm";
129 hist << std::setw(10) << std::left <<
"#fval";
130 hist << std::setw(10) << std::left <<
"#grad";
135 std::stringstream hist;
141 std::stringstream hist;
142 hist << std::scientific << std::setprecision(6);
143 if ( algo_state.
iter == 0 ) {
146 if ( print_header ) {
149 if ( algo_state.
iter == 0 ) {
151 hist << std::setw(6) << std::left << algo_state.
iter;
152 hist << std::setw(15) << std::left << algo_state.
value;
153 hist << std::setw(15) << std::left << algo_state.
gnorm;
158 hist << std::setw(6) << std::left << algo_state.
iter;
159 hist << std::setw(15) << std::left << algo_state.
value;
160 hist << std::setw(15) << std::left << algo_state.
gnorm;
161 hist << std::setw(15) << std::left << algo_state.
snorm;
162 hist << std::setw(10) << std::left << algo_state.
nfval;
163 hist << std::setw(10) << std::left << algo_state.
ngrad;
Provides the interface to evaluate objective functions.
int verbosity_
Verbosity setting.
virtual void scale(const Real alpha)=0
Compute where .
void compute(Vector< Real > &s, const Vector< Real > &x, Objective< Real > &obj, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
Compute step.
virtual void plus(const Vector &x)=0
Compute , where .
virtual Real value(const Vector< Real > &x, Real &tol)=0
Compute value.
Provides the interface to compute optimization steps.
Contains definitions of custom data types in ROL.
std::string EDescentToString(EDescent tr)
Defines the linear algebra or vector space interface.
virtual void update(const Vector< Real > &x, UpdateType type, int iter=-1)
Update objective function.
std::string print(AlgorithmState< Real > &algo_state, bool print_header=false) const
Print iterate status.
State for algorithm class. Will be used for restarts.
virtual void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
ENonlinearCG
Enumeration of nonlinear CG algorithms.
ROL::Ptr< NonlinearCG< Real > > nlcg_
NonlinearCG object (used for quasi-Newton)
ROL::Ptr< StepState< Real > > getState(void)
ROL::Ptr< Vector< Real > > iterateVec
ENonlinearCG StringToENonlinearCG(std::string s)
std::string printHeader(void) const
Print iterate header.
std::string printName(void) const
Print step name.
Provides the interface to apply upper and lower bound constraints.
NonlinearCGStep(ROL::ParameterList &parlist, const ROL::Ptr< NonlinearCG< Real > > &nlcg=ROL::nullPtr, const bool computeObj=true)
Constructor.
Provides the interface to compute optimization steps with nonlinear CG.
void update(Vector< Real > &x, const Vector< Real > &s, Objective< Real > &obj, BoundConstraint< Real > &con, AlgorithmState< Real > &algo_state)
Update step, if successful.
virtual Real norm() const =0
Returns where .