10 #ifndef ROL_LINESEARCHSTEP_H
11 #define ROL_LINESEARCHSTEP_H
103 template <
class Real>
113 ROL::Ptr<Vector<Real> >
d_;
175 const ROL::Ptr<NonlinearCG<Real> > &nlcg = ROL::nullPtr )
181 ROL::ParameterList& Llist = parlist.sublist(
"Step").sublist(
"Line Search");
182 ROL::ParameterList& Glist = parlist.sublist(
"General");
186 computeObj_ = Glist.get(
"Recompute Objective Function",
false);
189 lineSearchName_ = Llist.sublist(
"Line-Search Method").get(
"Type",
"Cubic Interpolation");
194 lineSearchName_ = Llist.sublist(
"Line-Search Method").get(
"User Defined Line-Search Name",
195 "Unspecified User Defined Line-Search");
206 ROL::ParameterList& list
207 =
parlist_.sublist(
"Step").sublist(
"Line Search").sublist(
"Descent Method");
232 ROL_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
233 ">>> (LineSearchStep::Initialize): Undefined descent type!");
259 ROL_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
260 ">>> (LineSearchStep::Initialize): Undefined descent type!");
263 desc_->initialize(x,s,g,obj,bnd,algo_state);
287 Real
zero(0), one(1);
289 desc_->compute(s,x,obj,bnd,algo_state);
293 const ROL::Ptr<const StepState<Real> > desc_state =
desc_->getStepState();
296 s.
set((desc_state->gradientVec)->dual());
304 step_state->nfval = 0; step_state->ngrad = 0;
306 lineSearch_->run(step_state->searchSize,
fval_,step_state->nfval,step_state->ngrad,gs,s,x,obj,bnd);
314 s.
scale(step_state->searchSize);
318 s.
axpy(static_cast<Real>(-1),x);
337 algo_state.
nfval += step_state->nfval;
338 algo_state.
ngrad += step_state->ngrad;
339 desc_->update(x,s,obj,bnd,algo_state);
340 step_state->flag =
desc_->getStepState()->flag;
341 step_state->SPiter =
desc_->getStepState()->SPiter;
342 step_state->SPflag =
desc_->getStepState()->SPflag;
353 std::string head =
desc_->printHeader();
354 head.erase(std::remove(head.end()-3,head.end(),
'\n'), head.end());
355 std::stringstream hist;
356 hist.write(head.c_str(),head.length());
357 hist << std::setw(10) << std::left <<
"ls_#fval";
358 hist << std::setw(10) << std::left <<
"ls_#grad";
368 std::string name =
desc_->printName();
369 std::stringstream hist;
385 std::string desc =
desc_->print(algo_state,
false);
386 desc.erase(std::remove(desc.end()-3,desc.end(),
'\n'), desc.end());
387 std::string name =
desc_->printName();
388 size_t pos = desc.find(name);
389 if ( pos != std::string::npos ) {
390 desc.erase(pos, name.length());
393 std::stringstream hist;
394 if ( algo_state.
iter == 0 ) {
397 if ( print_header ) {
401 if ( algo_state.
iter == 0 ) {
405 hist << std::setw(10) << std::left << step_state->nfval;
406 hist << std::setw(10) << std::left << step_state->ngrad;
Provides the interface to evaluate objective functions.
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
virtual void scale(const Real alpha)=0
Compute where .
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
virtual void plus(const Vector &x)=0
Compute , where .
bool acceptLastAlpha_
For backwards compatibility. When max function evaluations are reached take last step.
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
ELineSearch StringToELineSearch(std::string s)
Real GradDotStep(const Vector< Real > &g, const Vector< Real > &s, const Vector< Real > &x, BoundConstraint< Real > &bnd, Real eps=0)
bool isActivated(void) const
Check if bounds are on.
std::string printName(void) const
Print step name.
Provides the interface to compute optimization steps.
Contains definitions of custom data types in ROL.
LineSearchStep(ROL::ParameterList &parlist, const ROL::Ptr< LineSearch< Real > > &lineSearch=ROL::nullPtr, const ROL::Ptr< Secant< Real > > &secant=ROL::nullPtr, const ROL::Ptr< Krylov< Real > > &krylov=ROL::nullPtr, const ROL::Ptr< NonlinearCG< Real > > &nlcg=ROL::nullPtr)
Constructor.
ROL::ParameterList parlist_
void update(Vector< Real > &x, const Vector< Real > &s, Objective< Real > &obj, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
Update step, if successful.
ELineSearch
Enumeration of line-search types.
bool usePreviousAlpha_
If true, use the previously accepted step length (if any) as the new initial step length...
std::string printHeader(void) const
Print iterate header.
Defines the linear algebra or vector space interface.
virtual Real dot(const Vector &x) const =0
Compute where .
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0_ zero()
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.
EDescent StringToEDescent(std::string s)
State for algorithm class. Will be used for restarts.
Provides the interface to compute optimization steps with line search.
std::string ECurvatureConditionToString(ECurvatureCondition ls)
ROL::Ptr< NonlinearCG< Real > > nlcg_
Nonlinear CG object (used for nonlinear CG)
Provides interface for and implements line searches.
ROL::Ptr< StepState< Real > > getState(void)
Provides interface for and implements limited-memory secant operators.
ROL::Ptr< Step< Real > > desc_
Unglobalized step object.
virtual void project(Vector< Real > &x)
Project optimization variables onto the bounds.
ELineSearch els_
enum determines type of line search
void pruneInactive(Vector< Real > &v, const Vector< Real > &x, Real eps=Real(0))
Set variables to zero if they correspond to the -inactive set.
void pruneActive(Vector< Real > &v, const Vector< Real > &x, Real eps=Real(0))
Set variables to zero if they correspond to the -active set.
std::string print(AlgorithmState< Real > &algo_state, bool print_header=false) const
Print iterate status.
Provides definitions for Krylov solvers.
Provides the interface to apply upper and lower bound constraints.
ROL::Ptr< LineSearch< Real > > lineSearch_
Line-search object.
void compute(Vector< Real > &s, const Vector< Real > &x, Objective< Real > &obj, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
Compute step.
ROL::Ptr< Vector< Real > > d_
ECurvatureCondition
Enumeration of line-search curvature conditions.
virtual void set(const Vector &x)
Set where .
ECurvatureCondition StringToECurvatureCondition(std::string s)
ROL::Ptr< Krylov< Real > > krylov_
Krylov solver object (used for inexact Newton)
EDescent
Enumeration of descent direction types.
ECurvatureCondition econd_
enum determines type of curvature condition
ROL::Ptr< Secant< Real > > secant_
Secant object (used for quasi-Newton)
std::string lineSearchName_
const ROL::Ptr< const StepState< Real > > getStepState(void) const
Get state for step object.