10 #ifndef ROL_LINESEARCH_H
11 #define ROL_LINESEARCH_H
17 #include "ROL_Ptr.hpp"
18 #include "ROL_ParameterList.hpp"
23 #include "ROL_ScalarFunction.hpp"
49 ROL::Ptr<Vector<Real> >
d_;
50 ROL::Ptr<Vector<Real> >
g_;
61 Real one(1), p9(0.9), p6(0.6), p4(0.4), oem4(1.e-4),
zero(0);
63 std::string descentName = parlist.sublist(
"Step").sublist(
"Line Search").sublist(
"Descent Method").get(
"Type",
"Quasi-Newton Method");
66 std::string condName = parlist.sublist(
"Step").sublist(
"Line Search").sublist(
"Curvature Condition").get(
"Type",
"Strong Wolfe Conditions");
69 alpha0_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Initial Step Size",one);
70 alpha0bnd_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Lower Bound for Initial Step Size",one);
71 useralpha_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"User Defined Initial Step Size",
false);
72 usePrevAlpha_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Use Previous Step Length as Initial Guess",
false);
73 acceptMin_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Accept Linesearch Minimizer",
false);
74 maxit_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Function Evaluation Limit",20);
75 c1_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Sufficient Decrease Tolerance",oem4);
76 c2_ = parlist.sublist(
"Step").sublist(
"Line Search").sublist(
"Curvature Condition").get(
"General Parameter",p9);
77 c3_ = parlist.sublist(
"Step").sublist(
"Line Search").sublist(
"Curvature Condition").get(
"Generalized Wolfe Parameter",p6);
79 fmin_ = std::numeric_limits<Real>::max();
92 c3_ = std::min(one-c2_,c3_);
105 virtual void run( Real &alpha, Real &fval,
int &ls_neval,
int &ls_ngrad,
134 const Real fold,
const Real sgold,
const Real fnew,
137 Real tol = std::sqrt(ROL_EPSILON<Real>()), one(1), two(2);
153 gs = alpha*(
grad_)->dot(
d_->dual());
161 if ( fnew <= fold -
c1_*gs ) {
166 if ( fnew <= fold +
c1_*alpha*sgold ) {
173 if ( ls_neval >=
maxit_ ) {
178 bool curvcond =
false;
182 if (fnew >= fold + (one-
c1_)*alpha*sgold) {
198 sgnew = -
d_->dot(
g_->dual());
201 sgnew = s.
dot(
g_->dual());
206 && (sgnew >=
c2_*sgold))
208 && (std::abs(sgnew) <=
c2_*std::abs(sgold)))
210 && (
c2_*sgold <= sgnew && sgnew <= -
c3_*sgold))
212 && (
c2_*sgold <= sgnew && sgnew <= (two*
c1_ - one)*sgold)) ) {
225 return ((armijo && curvcond) ||
itcond_);
232 return ((armijo && curvcond) ||
itcond_);
236 virtual Real
getInitialAlpha(
int &ls_neval,
int &ls_ngrad,
const Real fval,
const Real gs,
239 Real val(1), one(1), half(0.5);
245 Real tol = std::sqrt(ROL_EPSILON<Real>());
249 Real fnew = obj.
value(*
d_,tol);
252 Real denom = (fnew - fval - gs);
253 Real alpha = ((denom > ROL_EPSILON<Real>()) ? -half*gs/denom : one);
Provides the interface to evaluate objective functions.
void setData(Real &eps, const Vector< Real > &g)
void updateIterate(Vector< Real > &xnew, const Vector< Real > &x, const Vector< Real > &s, Real alpha, BoundConstraint< Real > &con)
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, BoundConstraint< Real > &con)
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
bool isActivated(void) const
Check if bounds are on.
virtual Real value(const Vector< Real > &x, Real &tol)=0
Compute value.
Contains definitions of custom data types in ROL.
ELineSearch
Enumeration of line-search types.
Defines the linear algebra or vector space interface.
virtual void update(const Vector< Real > &x, UpdateType type, int iter=-1)
Update objective function.
virtual Real dot(const Vector &x) const =0
Compute where .
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0_ zero()
ROL::Ptr< Vector< Real > > g_
EDescent StringToEDescent(std::string s)
virtual void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
Provides interface for and implements line searches.
void setMaxitUpdate(Real &alpha, Real &fnew, const Real &fold)
ROL::Ptr< Vector< Real > > grad_
virtual void project(Vector< Real > &x)
Project optimization variables onto the bounds.
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.
Provides the interface to apply upper and lower bound constraints.
ECurvatureCondition
Enumeration of line-search curvature conditions.
LineSearch(ROL::ParameterList &parlist)
virtual void set(const Vector &x)
Set where .
ECurvatureCondition StringToECurvatureCondition(std::string s)
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, BoundConstraint< Real > &con)=0
virtual bool status(const ELineSearch 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, BoundConstraint< Real > &con)
ROL::Ptr< Vector< Real > > xtst_
ECurvatureCondition econd_
EDescent
Enumeration of descent direction types.
ROL::Ptr< Vector< Real > > d_
virtual void initialize(const Vector< Real > &x, const Vector< Real > &s, const Vector< Real > &g, Objective< Real > &obj, BoundConstraint< Real > &con)
void setNextInitialAlpha(Real alpha)