10 #ifndef ROL_LINESEARCH_U_H
11 #define ROL_LINESEARCH_U_H
17 #include "ROL_Ptr.hpp"
18 #include "ROL_ParameterList.hpp"
21 #include "ROL_ScalarFunction.hpp"
26 template<
typename Real>
55 Real tol = std::sqrt(ROL_EPSILON<Real>());
59 Real snorm = s.
norm();
60 if (snorm > static_cast<Real>(0)) {
61 Real xnorm =
xtst_->norm();
62 Real cbrteps = std::cbrt(ROL_EPSILON<Real>());
63 Real h = cbrteps*std::max(xnorm/snorm,static_cast<Real>(1));
67 val = (ftrial - fnew) / h;
82 Real one(1), p9(0.9), p6(0.6), p4(0.4), oem4(1.e-4),
zero(0);
84 edesc_ =
StringToEDescentU(parlist.sublist(
"Step").sublist(
"Line Search").sublist(
"Descent Method").get(
"Type",
"Quasi-Newton Method"));
87 alpha0_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Initial Step Size",one);
88 alpha0bnd_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Lower Bound for Initial Step Size",one);
89 useralpha_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"User Defined Initial Step Size",
false);
90 usePrevAlpha_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Use Previous Step Length as Initial Guess",
false);
91 acceptMin_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Accept Linesearch Minimizer",
false);
92 maxit_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Function Evaluation Limit",20);
93 c1_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Sufficient Decrease Tolerance",oem4);
94 c2_ = parlist.sublist(
"Step").sublist(
"Line Search").sublist(
"Curvature Condition").get(
"General Parameter",p9);
95 c3_ = parlist.sublist(
"Step").sublist(
"Line Search").sublist(
"Curvature Condition").get(
"Generalized Wolfe Parameter",p6);
97 fmin_ = std::numeric_limits<Real>::max();
100 FDdirDeriv_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Finite Difference Directional Derivative",
false);
111 c3_ = std::min(one-c2_,c3_);
119 virtual void run( Real &alpha, Real &fval,
int &ls_neval,
int &ls_ngrad,
141 const Real fold,
const Real sgold,
const Real fnew,
144 const Real one(1), two(2);
148 if ( fnew <= fold +
c1_*alpha*sgold ) {
154 if ( ls_neval >=
maxit_ ) {
159 bool curvcond =
false;
163 if (fnew >= fold + (one-
c1_)*alpha*sgold) {
171 Real sgnew =
dirDeriv(x,s,alpha,fnew,obj);
173 && (sgnew >=
c2_*sgold))
175 && (std::abs(sgnew) <=
c2_*std::abs(sgold)))
177 && (
c2_*sgold <= sgnew && sgnew <= -
c3_*sgold))
179 && (
c2_*sgold <= sgnew && sgnew <= (two*
c1_ - one)*sgold)) ) {
192 return ((armijo && curvcond) ||
itcond_);
199 return ((armijo && curvcond) ||
itcond_);
203 virtual Real
getInitialAlpha(
int &ls_neval,
int &ls_ngrad,
const Real fval,
const Real gs,
211 const Real one(1), half(0.5);
213 Real tol = std::sqrt(ROL_EPSILON<Real>());
220 Real denom = (fnew - fval - gs);
221 Real alpha = ((denom > ROL_EPSILON<Real>()) ? -half*gs/denom : one);
Provides interface for and implements line searches.
virtual void initialize(const Vector< Real > &x, const Vector< Real > &g)
ECurvatureConditionU econd_
Provides the interface to evaluate objective functions.
void setNextInitialAlpha(Real alpha)
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
Real dirDeriv(const Vector< Real > &x, const Vector< Real > &s, const Real alpha, const Real fnew, Objective< Real > &obj)
EDescentU
Enumeration of descent direction types.
Ptr< Vector< Real > > xtst_
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 value(const Vector< Real > &x, Real &tol)=0
Compute value.
virtual Real dirDeriv(const Vector< Real > &x, const Vector< Real > &d, Real &tol)
Compute directional derivative.
Contains definitions of custom data types in ROL.
void setMaxitUpdate(Real &alpha, Real &fnew, const Real &fold)
ELineSearchU
Enumeration of line-search types.
ECurvatureConditionU
Enumeration of line-search curvature conditions.
Defines the linear algebra or vector space interface.
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 update(const Vector< Real > &x, UpdateType type, int iter=-1)
Update objective function.
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0_ zero()
EDescentU StringToEDescentU(std::string s)
LineSearch_U(ParameterList &parlist)
virtual Real norm() const =0
Returns where .
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
ECurvatureConditionU StringToECurvatureConditionU(std::string s)