44 #ifndef ROL_LINESEARCHSTEP_H 45 #define ROL_LINESEARCHSTEP_H 138 template <
class Real>
145 Teuchos::RCP<NonlinearCG<Real> >
nlcg_;
148 Teuchos::RCP<Vector<Real> >
d_;
206 const Teuchos::RCP<
Secant<Real> > &secant = Teuchos::null,
207 const Teuchos::RCP<
Krylov<Real> > &krylov = Teuchos::null,
208 const Teuchos::RCP<NonlinearCG<Real> > &nlcg = Teuchos::null )
214 Teuchos::ParameterList& Llist = parlist.sublist(
"Step").sublist(
"Line Search");
215 Teuchos::ParameterList& Glist = parlist.sublist(
"General");
219 computeObj_ = Glist.get(
"Recompute Objective Function",
true);
233 Teuchos::ParameterList& list
234 =
parlist_.sublist(
"Step").sublist(
"Line Search").sublist(
"Descent Method");
259 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
260 ">>> (LineSearchStep::Initialize): Undefined descent type!");
286 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
287 ">>> (LineSearchStep::Initialize): Undefined descent type!");
290 desc_->initialize(x,s,g,obj,bnd,algo_state);
314 Real zero(0), one(1);
316 desc_->compute(s,x,obj,bnd,algo_state);
320 const Teuchos::RCP<const StepState<Real> > desc_state =
desc_->getStepState();
323 s.
set((desc_state->gradientVec)->dual());
331 step_state->nfval = 0; step_state->ngrad = 0;
333 lineSearch_->run(step_state->searchSize,
fval_,step_state->nfval,step_state->ngrad,gs,s,x,obj,bnd);
341 s.
scale(step_state->searchSize);
359 algo_state.
nfval += step_state->nfval;
360 algo_state.
ngrad += step_state->ngrad;
361 desc_->update(x,s,obj,bnd,algo_state);
372 std::string head =
desc_->printHeader();
373 head.erase(std::remove(head.end()-3,head.end(),
'\n'), head.end());
374 std::stringstream hist;
375 hist.write(head.c_str(),head.length());
376 hist << std::setw(10) << std::left <<
"ls_#fval";
377 hist << std::setw(10) << std::left <<
"ls_#grad";
387 std::string name =
desc_->printName();
388 std::stringstream hist;
404 std::string desc =
desc_->print(algo_state,
false);
405 desc.erase(std::remove(desc.end()-3,desc.end(),
'\n'), desc.end());
406 std::string name =
desc_->printName();
407 size_t pos = desc.find(name);
408 if ( pos != std::string::npos ) {
409 desc.erase(pos, name.length());
412 std::stringstream hist;
413 if ( algo_state.
iter == 0 ) {
416 if ( print_header ) {
420 if ( algo_state.
iter == 0 ) {
424 hist << std::setw(10) << std::left << step_state->nfval;
425 hist << std::setw(10) << std::left << step_state->ngrad;
Provides the interface to evaluate objective functions.
virtual void scale(const Real alpha)=0
Compute where .
bool acceptLastAlpha_
For backwards compatibility. When max function evaluations are reached take last step.
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)
Provides the interface to compute optimization steps with projected Newton's method using line search...
Provides the interface to compute optimization steps.
Teuchos::RCP< StepState< Real > > getState(void)
Contains definitions of custom data types in ROL.
Teuchos::ParameterList parlist_
void pruneInactive(Vector< Real > &v, const Vector< Real > &x, Real eps=0)
Set variables to zero if they correspond to the -inactive set.
virtual Teuchos::RCP< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
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...
Contains definitions for helper functions in ROL.
Defines the linear algebra or vector space interface.
Provides the interface to compute optimization steps with projected inexact ProjectedNewton's method ...
Provides the interface to compute optimization steps with projected secant method using line search...
virtual Real dot(const Vector &x) const =0
Compute where .
virtual void pruneActive(Vector< Real > &v, const Vector< Real > &x, Real eps=0)
Set variables to zero if they correspond to the -active set.
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.
Provides the interface to compute optimization steps with Newton's method globalized using line searc...
EDescent StringToEDescent(std::string s)
State for algorithm class. Will be used for restarts.
Provides the interface to compute optimization steps with line search.
Teuchos::RCP< Krylov< Real > > krylov_
Krylov solver object (used for inexact Newton)
bool isActivated(void)
Check if bounds are on.
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
std::string ECurvatureConditionToString(ECurvatureCondition ls)
Provides interface for and implements line searches.
const Teuchos::RCP< const StepState< Real > > getStepState(void) const
Get state for step object.
std::string printHeader(void) const
Print iterate header.
LineSearchStep(Teuchos::ParameterList &parlist, const Teuchos::RCP< LineSearch< Real > > &lineSearch=Teuchos::null, const Teuchos::RCP< Secant< Real > > &secant=Teuchos::null, const Teuchos::RCP< Krylov< Real > > &krylov=Teuchos::null, const Teuchos::RCP< NonlinearCG< Real > > &nlcg=Teuchos::null)
Constructor.
Provides interface for and implements limited-memory secant operators.
std::string ELineSearchToString(ELineSearch ls)
Teuchos::RCP< LineSearch< Real > > lineSearch_
Line-search object.
ELineSearch els_
enum determines type of line search
Provides definitions for Krylov solvers.
Provides the interface to apply upper and lower bound constraints.
Teuchos::RCP< Step< Real > > desc_
Unglobalized step object.
void compute(Vector< Real > &s, const Vector< Real > &x, Objective< Real > &obj, BoundConstraint< Real > &bnd, AlgorithmState< Real > &algo_state)
Compute step.
std::string print(AlgorithmState< Real > &algo_state, bool print_header=false) const
Print iterate status.
Provides the interface to compute optimization steps with nonlinear CG.
Provides the interface to compute optimization steps with projected inexact Newton's method using lin...
ECurvatureCondition
Enumeration of line-search curvature conditions.
Teuchos::RCP< NonlinearCG< Real > > nlcg_
Nonlinear CG object (used for nonlinear CG)
std::string printName(void) const
Print step name.
Teuchos::RCP< Vector< Real > > d_
virtual void set(const Vector &x)
Set where .
ECurvatureCondition StringToECurvatureCondition(std::string s)
Provides the interface to compute optimization steps with the gradient descent method globalized usin...
EDescent
Enumeration of descent direction types.
ECurvatureCondition econd_
enum determines type of curvature condition
Teuchos::RCP< Secant< Real > > secant_
Secant object (used for quasi-Newton)
virtual void project(Vector< Real > &x)
Project optimization variables onto the bounds.
Provides the interface to compute optimization steps with a secant method.