44 #ifndef ROL_LINESEARCH_H
45 #define ROL_LINESEARCH_H
51 #include "ROL_Ptr.hpp"
52 #include "ROL_ParameterList.hpp"
57 #include "ROL_ScalarFunction.hpp"
83 ROL::Ptr<Vector<Real> >
d_;
84 ROL::Ptr<Vector<Real> >
g_;
95 Real one(1), p9(0.9), p6(0.6), p4(0.4), oem4(1.e-4),
zero(0);
97 edesc_ =
StringToEDescent(parlist.sublist(
"Step").sublist(
"Line Search").sublist(
"Descent Method").get(
"Type",
"Quasi-Newton Method"));
100 alpha0_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Initial Step Size",one);
101 alpha0bnd_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Lower Bound for Initial Step Size",one);
102 useralpha_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"User Defined Initial Step Size",
false);
103 usePrevAlpha_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Use Previous Step Length as Initial Guess",
false);
104 acceptMin_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Accept Linesearch Minimizer",
false);
105 maxit_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Function Evaluation Limit",20);
106 c1_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Sufficient Decrease Tolerance",oem4);
107 c2_ = parlist.sublist(
"Step").sublist(
"Line Search").sublist(
"Curvature Condition").get(
"General Parameter",p9);
108 c3_ = parlist.sublist(
"Step").sublist(
"Line Search").sublist(
"Curvature Condition").get(
"Generalized Wolfe Parameter",p6);
110 fmin_ = std::numeric_limits<Real>::max();
123 c3_ = std::min(one-c2_,c3_);
136 virtual void run( Real &alpha, Real &fval,
int &ls_neval,
int &ls_ngrad,
165 const Real fold,
const Real sgold,
const Real fnew,
168 Real tol = std::sqrt(ROL_EPSILON<Real>()), one(1), two(2);
184 gs = alpha*(
grad_)->dot(
d_->dual());
192 if ( fnew <= fold -
c1_*gs ) {
197 if ( fnew <= fold +
c1_*alpha*sgold ) {
204 if ( ls_neval >=
maxit_ ) {
209 bool curvcond =
false;
213 if (fnew >= fold + (one-
c1_)*alpha*sgold) {
229 sgnew = -
d_->dot(
g_->dual());
232 sgnew = s.
dot(
g_->dual());
237 && (sgnew >=
c2_*sgold))
239 && (std::abs(sgnew) <=
c2_*std::abs(sgold)))
241 && (
c2_*sgold <= sgnew && sgnew <= -
c3_*sgold))
243 && (
c2_*sgold <= sgnew && sgnew <= (two*
c1_ - one)*sgold)) ) {
256 return ((armijo && curvcond) ||
itcond_);
263 return ((armijo && curvcond) ||
itcond_);
267 virtual Real
getInitialAlpha(
int &ls_neval,
int &ls_ngrad,
const Real fval,
const Real gs,
270 Real val(1), one(1), half(0.5);
276 Real tol = std::sqrt(ROL_EPSILON<Real>());
280 Real fnew = obj.
value(*
d_,tol);
283 Real denom = (fnew - fval - gs);
284 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.
void pruneInactive(Vector< Real > &v, const Vector< Real > &x, Real eps=0)
Set variables to zero if they correspond to the -inactive set.
ELineSearch
Enumeration of line-search types.
void pruneActive(Vector< Real > &v, const Vector< Real > &x, Real eps=0)
Set variables to zero if they correspond to the -active set.
Defines the linear algebra or vector space interface.
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_
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 void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Update objective function.
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 project(Vector< Real > &x)
Project optimization variables onto the bounds.
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)