44 #ifndef ROL_NONLINEARCGSTEP_H
45 #define ROL_NONLINEARCGSTEP_H
63 ROL::Ptr<NonlinearCG<Real> >
nlcg_;
86 const ROL::Ptr<NonlinearCG<Real> > &nlcg = ROL::nullPtr,
87 const bool computeObj =
true )
91 verbosity_ = parlist.sublist(
"General").get(
"Print Verbosity",0);
93 ROL::ParameterList& Llist = parlist.sublist(
"Step").sublist(
"Line Search");
94 if ( nlcg == ROL::nullPtr ) {
95 ncgName_ = Llist.sublist(
"Descent Method").get(
"Nonlinear CG Type",
"Oren-Luenberger");
101 ncgName_ = Llist.sublist(
"Descent Method").get(
"User Defined Nonlinear CG Name",
102 "Unspecified User Define Nonlinear CG Method");
113 nlcg_->run(s,*(step_state->gradientVec),x,obj);
119 Real tol = std::sqrt(ROL_EPSILON<Real>());
125 (step_state->descentVec)->set(s);
134 obj.
gradient(*(step_state->gradientVec),x,tol);
139 algo_state.
gnorm = (step_state->gradientVec)->norm();
143 std::stringstream hist;
146 hist << std::string(109,
'-') <<
"\n";
148 hist <<
" status output definitions\n\n";
149 hist <<
" iter - Number of iterates (steps taken) \n";
150 hist <<
" value - Objective function value \n";
151 hist <<
" gnorm - Norm of the gradient\n";
152 hist <<
" snorm - Norm of the step (update to optimization vector)\n";
153 hist <<
" #fval - Cumulative number of times the objective function was evaluated\n";
154 hist <<
" #grad - Number of times the gradient was computed\n";
155 hist << std::string(109,
'-') <<
"\n";
159 hist << std::setw(6) << std::left <<
"iter";
160 hist << std::setw(15) << std::left <<
"value";
161 hist << std::setw(15) << std::left <<
"gnorm";
162 hist << std::setw(15) << std::left <<
"snorm";
163 hist << std::setw(10) << std::left <<
"#fval";
164 hist << std::setw(10) << std::left <<
"#grad";
169 std::stringstream hist;
175 std::stringstream hist;
176 hist << std::scientific << std::setprecision(6);
177 if ( algo_state.
iter == 0 ) {
180 if ( print_header ) {
183 if ( algo_state.
iter == 0 ) {
185 hist << std::setw(6) << std::left << algo_state.
iter;
186 hist << std::setw(15) << std::left << algo_state.
value;
187 hist << std::setw(15) << std::left << algo_state.
gnorm;
192 hist << std::setw(6) << std::left << algo_state.
iter;
193 hist << std::setw(15) << std::left << algo_state.
value;
194 hist << std::setw(15) << std::left << algo_state.
gnorm;
195 hist << std::setw(15) << std::left << algo_state.
snorm;
196 hist << std::setw(10) << std::left << algo_state.
nfval;
197 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.
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 .
virtual void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Update objective function.