44 #ifndef ROL_LINESEARCH_H 45 #define ROL_LINESEARCH_H 51 #include "Teuchos_RCP.hpp" 52 #include "Teuchos_ParameterList.hpp" 79 Teuchos::RCP<Vector<Real> >
xtst_;
80 Teuchos::RCP<Vector<Real> >
d_;
81 Teuchos::RCP<Vector<Real> >
g_;
82 Teuchos::RCP<const Vector<Real> >
grad_;
90 LineSearch( Teuchos::ParameterList &parlist ) : eps_(0.0) {
92 edesc_ =
StringToEDescent(parlist.sublist(
"Step").sublist(
"Line Search").sublist(
"Descent Method").get(
"Type",
"Quasi-Newton Method"));
93 econd_ =
StringToECurvatureCondition(parlist.sublist(
"Step").sublist(
"Line Search").sublist(
"Curvature Condition").get(
"Type",
"Strong Wolfe Conditions"));
95 alpha0_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Initial Step Size",1.0);
96 useralpha_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"User Defined Initial Step Size",
false);
97 acceptMin_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Accept Linesearch Minimizer",
false);
98 maxit_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Function Evaluation Limit",20);
99 c1_ = parlist.sublist(
"Step").sublist(
"Line Search").get(
"Sufficient Decrease Tolerance",1.e-4);
100 c2_ = parlist.sublist(
"Step").sublist(
"Line Search").sublist(
"Curvature Condition").get(
"General Parameter",0.9);
101 c3_ = parlist.sublist(
"Step").sublist(
"Line Search").sublist(
"Curvature Condition").get(
"Generalized Wolfe Parameter",0.6);
103 fmin_ = std::numeric_limits<Real>::max();
107 c1_ = ((c1_ < 0.0) ? 1.e-4 :
c1_);
108 c2_ = ((c2_ < 0.0) ? 0.9 :
c2_);
109 c3_ = ((c3_ < 0.0) ? 0.9 :
c3_);
116 c3_ = std::min(1.0-c2_,c3_);
122 grad_ = Teuchos::rcp(&g,
false);
133 const Real fold,
const Real sgold,
const Real fnew,
152 gs = alpha*(
grad_)->dot(d_->dual());
158 gs += d_->dot(grad_->dual());
160 if ( fnew <= fold - c1_*gs ) {
165 if ( fnew <= fold + c1_*alpha*sgold ) {
172 if ( ls_neval >= maxit_ ) {
177 bool curvcond =
false;
181 if (fnew >= fold + (1.0-c1_)*alpha*sgold) {
197 sgnew = -d_->dot(g_->dual());
200 sgnew = s.
dot(g_->dual());
205 && (sgnew >= c2_*sgold))
207 && (std::abs(sgnew) <= c2_*std::abs(sgold)))
209 && (c2_*sgold <= sgnew && sgnew <= -c3_*sgold))
211 && (c2_*sgold <= sgnew && sgnew <= (2.0*c1_ - 1.0)*sgold)) ) {
224 return ((armijo && curvcond) ||
itcond_);
227 return (armijo || itcond_);
231 return ((armijo && curvcond) ||
itcond_);
235 virtual void run( Real &alpha, Real &fval,
int &ls_neval,
int &ls_ngrad,
239 virtual Real
getInitialAlpha(
int &ls_neval,
int &ls_ngrad,
const Real fval,
const Real gs,
252 Real fnew = obj.
value(*d_,tol);
255 Real denom = (fnew - fval - gs);
256 Real alpha = ((denom >
ROL_EPSILON) ? -0.5*gs/denom : 1.0);
257 val = ((alpha > 1.e-1) ? alpha : 1.0);
292 if( itcond_ && acceptMin_ ) {
297 else if(itcond_ && !acceptMin_) {
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 setMaxitUpdate(Real &alpha, Real &fnew, const Real &fold)
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.