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 std::string descentType = parlist.sublist(
"Step").sublist(
"Line Search").sublist(
"Descent Method").get(
"Type",
"Quasi-Newton Method");
86 std::string condType = parlist.sublist(
"Step").sublist(
"Line Search").sublist(
"Curvature Condition").get(
"Type",
"Strong Wolfe Conditions");
89 alpha0_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Initial Step Size",one);
90 alpha0bnd_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Lower Bound for Initial Step Size",one);
91 useralpha_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"User Defined Initial Step Size",
false);
92 usePrevAlpha_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Use Previous Step Length as Initial Guess",
false);
93 acceptMin_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Accept Linesearch Minimizer",
false);
94 maxit_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Function Evaluation Limit",20);
95 c1_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Sufficient Decrease Tolerance",oem4);
96 c2_ = parlist.sublist(
"Step").sublist(
"Line Search").sublist(
"Curvature Condition").get(
"General Parameter",p9);
97 c3_ = parlist.sublist(
"Step").sublist(
"Line Search").sublist(
"Curvature Condition").get(
"Generalized Wolfe Parameter",p6);
99 fmin_ = std::numeric_limits<Real>::max();
102 FDdirDeriv_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Finite Difference Directional Derivative",
false);
113 c3_ = std::min(one-c2_,c3_);
121 virtual void run( Real &alpha, Real &fval,
int &ls_neval,
int &ls_ngrad,
143 const Real fold,
const Real sgold,
const Real fnew,
146 const Real one(1), two(2);
150 if ( fnew <= fold +
c1_*alpha*sgold ) {
156 if ( ls_neval >=
maxit_ ) {
161 bool curvcond =
false;
165 if (fnew >= fold + (one-
c1_)*alpha*sgold) {
173 Real sgnew =
dirDeriv(x,s,alpha,fnew,obj);
175 && (sgnew >=
c2_*sgold))
177 && (std::abs(sgnew) <=
c2_*std::abs(sgold)))
179 && (
c2_*sgold <= sgnew && sgnew <= -
c3_*sgold))
181 && (
c2_*sgold <= sgnew && sgnew <= (two*
c1_ - one)*sgold)) ) {
194 return ((armijo && curvcond) ||
itcond_);
201 return ((armijo && curvcond) ||
itcond_);
205 virtual Real
getInitialAlpha(
int &ls_neval,
int &ls_ngrad,
const Real fval,
const Real gs,
213 const Real one(1), half(0.5);
215 Real tol = std::sqrt(ROL_EPSILON<Real>());
222 Real denom = (fnew - fval - gs);
223 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)