44 #ifndef ROL_LINESEARCH_H
45 #define ROL_LINESEARCH_H
51 #include "Teuchos_RCP.hpp"
52 #include "Teuchos_ParameterList.hpp"
75 Teuchos::RCP<Vector<Real> >
xtst_;
76 Teuchos::RCP<Vector<Real> >
d_;
77 Teuchos::RCP<Vector<Real> >
g_;
78 Teuchos::RCP<const Vector<Real> >
grad_;
90 maxit_ = parlist.get(
"Maximum Number of Function Evaluations", 20);
91 c1_ = parlist.get(
"Sufficient Decrease Parameter", 1.e-4);
92 c2_ = parlist.get(
"Curvature Conditions Parameter", 0.9);
93 c3_ = parlist.get(
"Curvature Conditions Parameter: Generalized Wolfe", 0.6);
94 alpha0_ = parlist.get(
"Initial Linesearch Parameter",1.0);
95 useralpha_ = parlist.get(
"User Defined Linesearch Parameter",
false);
118 grad_ = Teuchos::rcp(&g,
false);
129 const Real fold,
const Real sgold,
const Real fnew,
156 if ( fnew <= fold -
c1_*gs ) {
161 if ( fnew <= fold +
c1_*alpha*sgold ) {
168 if ( ls_neval >=
maxit_ ) {
173 bool curvcond =
false;
177 if (fnew >= fold + (1.0-
c1_)*alpha*sgold) {
193 sgnew = -
d_->dot(
g_->dual());
196 sgnew = s.
dot(
g_->dual());
201 && (sgnew >=
c2_*sgold))
203 && (std::abs(sgnew) <=
c2_*std::abs(sgold)))
205 && (
c2_*sgold <= sgnew && sgnew <= -
c3_*sgold))
207 && (
c2_*sgold <= sgnew && sgnew <= (2.0*
c1_ - 1.0)*sgold)) ) {
215 return ((armijo && curvcond) || itcond);
218 return (armijo || itcond);
222 return ((armijo && curvcond) || itcond);
226 virtual void run( Real &alpha, Real &fval,
int &ls_neval,
int &ls_ngrad,
230 virtual Real
getInitialAlpha(
int &ls_neval,
int &ls_ngrad,
const Real fval,
const Real gs,
244 Real fnew = obj.
value(*
d_,tol);
247 alpha = -gs/(2.0*(fnew-fval-gs));
254 bool stat =
status(
LINESEARCH_BISECTION,ls_neval,ls_ngrad,alpha,fval,gs,fnew,x,s,obj,con);
Provides the interface to evaluate objective functions.
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 void axpy(const Real alpha, const Vector &x)
Compute where .
Teuchos::RCP< Vector< Real > > xtst_
virtual Real value(const Vector< Real > &x, Real &tol)=0
Compute value.
Contains definitions of custom data types in ROL.
Teuchos::RCP< Vector< Real > > g_
virtual Teuchos::RCP< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
ELineSearch
Enumeration of line-search types.
Defines the linear algebra or vector space interface.
LineSearch(Teuchos::ParameterList &parlist)
virtual Real dot(const Vector &x) const =0
Compute where .
EDescent StringToEDescent(std::string s)
virtual void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
bool isActivated(void)
Check if bounds are on.
Provides interface for and implements line searches.
void pruneInactive(Vector< Real > &v, const Vector< Real > &x, Real eps=0.0)
Set variables to zero if they correspond to the -inactive set.
Teuchos::RCP< Vector< Real > > d_
Provides the interface to apply upper and lower bound constraints.
ECurvatureCondition
Enumeration of line-search curvature conditions.
Teuchos::RCP< const Vector< Real > > grad_
virtual void set(const Vector &x)
Set where .
virtual void pruneActive(Vector< Real > &v, const Vector< Real > &x, Real eps=0.0)
Set variables to zero if they correspond to the -active set.
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)
ECurvatureCondition econd_
EDescent
Enumeration of descent direction types.
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)
static const double ROL_EPSILON
Platform-dependent machine epsilon.