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 edesc_ =
StringToEDescent(parlist.sublist(
"Step").sublist(
"Line Search").sublist(
"Descent Method").get(
"Type",
"Quasi-Newton Method"));
66 alpha0_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Initial Step Size",one);
67 alpha0bnd_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Lower Bound for Initial Step Size",one);
68 useralpha_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"User Defined Initial Step Size",
false);
69 usePrevAlpha_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Use Previous Step Length as Initial Guess",
false);
70 acceptMin_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Accept Linesearch Minimizer",
false);
71 maxit_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Function Evaluation Limit",20);
72 c1_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Sufficient Decrease Tolerance",oem4);
73 c2_ = parlist.sublist(
"Step").sublist(
"Line Search").sublist(
"Curvature Condition").get(
"General Parameter",p9);
74 c3_ = parlist.sublist(
"Step").sublist(
"Line Search").sublist(
"Curvature Condition").get(
"Generalized Wolfe Parameter",p6);
76 fmin_ = std::numeric_limits<Real>::max();
89 c3_ = std::min(one-c2_,c3_);
102 virtual void run( Real &alpha, Real &fval,
int &ls_neval,
int &ls_ngrad,
131 const Real fold,
const Real sgold,
const Real fnew,
134 Real tol = std::sqrt(ROL_EPSILON<Real>()), one(1), two(2);
150 gs = alpha*(
grad_)->dot(
d_->dual());
158 if ( fnew <= fold -
c1_*gs ) {
163 if ( fnew <= fold +
c1_*alpha*sgold ) {
170 if ( ls_neval >=
maxit_ ) {
175 bool curvcond =
false;
179 if (fnew >= fold + (one-
c1_)*alpha*sgold) {
195 sgnew = -
d_->dot(
g_->dual());
198 sgnew = s.
dot(
g_->dual());
203 && (sgnew >=
c2_*sgold))
205 && (std::abs(sgnew) <=
c2_*std::abs(sgold)))
207 && (
c2_*sgold <= sgnew && sgnew <= -
c3_*sgold))
209 && (
c2_*sgold <= sgnew && sgnew <= (two*
c1_ - one)*sgold)) ) {
222 return ((armijo && curvcond) ||
itcond_);
229 return ((armijo && curvcond) ||
itcond_);
233 virtual Real
getInitialAlpha(
int &ls_neval,
int &ls_ngrad,
const Real fval,
const Real gs,
236 Real val(1), one(1), half(0.5);
242 Real tol = std::sqrt(ROL_EPSILON<Real>());
246 Real fnew = obj.
value(*
d_,tol);
249 Real denom = (fnew - fval - gs);
250 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)