44 #ifndef ROL_NONLINEARCGSTEP_H 45 #define ROL_NONLINEARCGSTEP_H 63 Teuchos::RCP<NonlinearCG<Real> >
nlcg_;
84 const Teuchos::RCP<NonlinearCG<Real> > &nlcg = Teuchos::null,
85 const bool computeObj =
true )
89 verbosity_ = parlist.sublist(
"General").get(
"Print Verbosity",0);
91 Teuchos::ParameterList& Llist = parlist.sublist(
"Step").sublist(
"Line Search");
92 if ( nlcg == Teuchos::null ) {
94 =
StringToENonlinearCG(Llist.sublist(
"Descent Method").get(
"Nonlinear CG Type",
"Oren-Luenberger"));
95 nlcg_ = Teuchos::rcp(
new NonlinearCG<Real>(
enlcg_));
106 nlcg_->run(s,*(step_state->gradientVec),x,obj);
112 Real tol = std::sqrt(ROL_EPSILON<Real>());
118 (step_state->descentVec)->
set(s);
127 obj.
gradient(*(step_state->gradientVec),x,tol);
132 algo_state.
gnorm = (step_state->gradientVec)->norm();
136 std::stringstream hist;
139 hist << std::string(109,
'-') <<
"\n";
141 hist <<
" status output definitions\n\n";
142 hist <<
" iter - Number of iterates (steps taken) \n";
143 hist <<
" value - Objective function value \n";
144 hist <<
" gnorm - Norm of the gradient\n";
145 hist <<
" snorm - Norm of the step (update to optimization vector)\n";
146 hist <<
" #fval - Cumulative number of times the objective function was evaluated\n";
147 hist <<
" #grad - Number of times the gradient was computed\n";
148 hist << std::string(109,
'-') <<
"\n";
152 hist << std::setw(6) << std::left <<
"iter";
153 hist << std::setw(15) << std::left <<
"value";
154 hist << std::setw(15) << std::left <<
"gnorm";
155 hist << std::setw(15) << std::left <<
"snorm";
156 hist << std::setw(10) << std::left <<
"#fval";
157 hist << std::setw(10) << std::left <<
"#grad";
162 std::stringstream hist;
168 std::stringstream hist;
169 hist << std::scientific << std::setprecision(6);
170 if ( algo_state.
iter == 0 ) {
173 if ( print_header ) {
176 if ( algo_state.
iter == 0 ) {
178 hist << std::setw(6) << std::left << algo_state.
iter;
179 hist << std::setw(15) << std::left << algo_state.
value;
180 hist << std::setw(15) << std::left << algo_state.
gnorm;
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;
188 hist << std::setw(15) << std::left << algo_state.
snorm;
189 hist << std::setw(10) << std::left << algo_state.
nfval;
190 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.
std::string printName(void) const
Print step name.
virtual void plus(const Vector &x)=0
Compute , where .
NonlinearCGStep(Teuchos::ParameterList &parlist, const Teuchos::RCP< NonlinearCG< Real > > &nlcg=Teuchos::null, const bool computeObj=true)
Constructor.
virtual Real value(const Vector< Real > &x, Real &tol)=0
Compute value.
Provides the interface to compute optimization steps.
Teuchos::RCP< StepState< Real > > getState(void)
Contains definitions of custom data types in ROL.
std::string print(AlgorithmState< Real > &algo_state, bool print_header=false) const
Print iterate status.
Teuchos::RCP< NonlinearCG< Real > > nlcg_
NonlinearCG object (used for quasi-Newton)
std::string EDescentToString(EDescent tr)
Defines the linear algebra or vector space interface.
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.
std::string printHeader(void) const
Print iterate header.
std::string ENonlinearCGToString(ENonlinearCG tr)
ENonlinearCG StringToENonlinearCG(std::string s)
Provides the interface to apply upper and lower bound constraints.
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.
Teuchos::RCP< Vector< Real > > iterateVec
virtual Real norm() const =0
Returns where .
virtual void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Update objective function.