44#ifndef ROL_LINESEARCH_U_H
45#define ROL_LINESEARCH_U_H
52#include "ROL_ParameterList.hpp"
55#include "ROL_ScalarFunction.hpp"
60template<
typename Real>
89 Real tol = std::sqrt(ROL_EPSILON<Real>());
93 Real snorm = s.
norm();
94 if (snorm >
static_cast<Real
>(0)) {
95 Real xnorm =
xtst_->norm();
96 Real cbrteps = std::cbrt(ROL_EPSILON<Real>());
97 Real h = cbrteps*std::max(xnorm/snorm,
static_cast<Real
>(1));
101 val = (ftrial - fnew) / h;
116 Real one(1), p9(0.9), p6(0.6), p4(0.4), oem4(1.e-4),
zero(0);
118 edesc_ =
StringToEDescentU(parlist.sublist(
"Step").sublist(
"Line Search").sublist(
"Descent Method").get(
"Type",
"Quasi-Newton Method"));
121 alpha0_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Initial Step Size",one);
122 alpha0bnd_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Lower Bound for Initial Step Size",one);
123 useralpha_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"User Defined Initial Step Size",
false);
124 usePrevAlpha_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Use Previous Step Length as Initial Guess",
false);
125 acceptMin_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Accept Linesearch Minimizer",
false);
126 maxit_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Function Evaluation Limit",20);
127 c1_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Sufficient Decrease Tolerance",oem4);
128 c2_ = parlist.sublist(
"Step").sublist(
"Line Search").sublist(
"Curvature Condition").get(
"General Parameter",p9);
129 c3_ = parlist.sublist(
"Step").sublist(
"Line Search").sublist(
"Curvature Condition").get(
"Generalized Wolfe Parameter",p6);
131 fmin_ = std::numeric_limits<Real>::max();
134 FDdirDeriv_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Finite Difference Directional Derivative",
false);
153 virtual void run( Real &alpha, Real &fval,
int &ls_neval,
int &ls_ngrad,
175 const Real fold,
const Real sgold,
const Real fnew,
178 const Real one(1), two(2);
182 if ( fnew <= fold +
c1_*alpha*sgold ) {
188 if ( ls_neval >=
maxit_ ) {
193 bool curvcond =
false;
197 if (fnew >= fold + (one-
c1_)*alpha*sgold) {
205 Real sgnew =
dirDeriv(x,s,alpha,fnew,obj);
207 && (sgnew >=
c2_*sgold))
209 && (std::abs(sgnew) <=
c2_*std::abs(sgold)))
211 && (
c2_*sgold <= sgnew && sgnew <= -
c3_*sgold))
213 && (
c2_*sgold <= sgnew && sgnew <= (two*
c1_ - one)*sgold)) ) {
226 return ((armijo && curvcond) ||
itcond_);
233 return ((armijo && curvcond) ||
itcond_);
237 virtual Real
getInitialAlpha(
int &ls_neval,
int &ls_ngrad,
const Real fval,
const Real gs,
245 const Real one(1), half(0.5);
247 Real tol = std::sqrt(ROL_EPSILON<Real>());
254 Real denom = (fnew - fval - gs);
255 Real alpha = ((denom > ROL_EPSILON<Real>()) ? -half*gs/denom : one);
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0_ zero()
Contains definitions of custom data types in ROL.
Provides interface for and implements line searches.
void setMaxitUpdate(Real &alpha, Real &fnew, const Real &fold)
Real dirDeriv(const Vector< Real > &x, const Vector< Real > &s, const Real alpha, const Real fnew, Objective< Real > &obj)
virtual bool status(const ELineSearchU type, int &ls_neval, int &ls_ngrad, const Real alpha, const Real fold, const Real sgold, const Real fnew, const Vector< Real > &x, const Vector< Real > &s, Objective< Real > &obj)
virtual Real getInitialAlpha(int &ls_neval, int &ls_ngrad, const Real fval, const Real gs, const Vector< Real > &x, const Vector< Real > &s, Objective< Real > &obj)
virtual void initialize(const Vector< Real > &x, const Vector< Real > &g)
Ptr< Vector< Real > > xtst_
ECurvatureConditionU econd_
virtual void run(Real &alpha, Real &fval, int &ls_neval, int &ls_ngrad, const Real &gs, const Vector< Real > &s, const Vector< Real > &x, Objective< Real > &obj)=0
void setNextInitialAlpha(Real alpha)
LineSearch_U(ParameterList &parlist)
Provides the interface to evaluate objective functions.
virtual Real dirDeriv(const Vector< Real > &x, const Vector< Real > &d, Real &tol)
Compute directional derivative.
virtual Real value(const Vector< Real > &x, Real &tol)=0
Compute value.
virtual void update(const Vector< Real > &x, UpdateType type, int iter=-1)
Update objective function.
Defines the linear algebra or vector space interface.
virtual Real norm() const =0
Returns where .
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
@ CURVATURECONDITION_U_APPROXIMATEWOLFE
@ CURVATURECONDITION_U_GOLDSTEIN
@ CURVATURECONDITION_U_GENERALIZEDWOLFE
@ CURVATURECONDITION_U_STRONGWOLFE
@ CURVATURECONDITION_U_NULL
@ CURVATURECONDITION_U_WOLFE
ECurvatureConditionU StringToECurvatureConditionU(std::string s)
@ LINESEARCH_U_BACKTRACKING
@ LINESEARCH_U_CUBICINTERP
EDescentU StringToEDescentU(std::string s)