44 #ifndef ROL_ScalarMinimizationLineSearch_H 45 #define ROL_ScalarMinimizationLineSearch_H 53 #include "ROL_BrentsScalarMinimization.hpp" 54 #include "ROL_BisectionScalarMinimization.hpp" 55 #include "ROL_GoldenSectionScalarMinimization.hpp" 56 #include "ROL_ScalarFunction.hpp" 57 #include "ROL_Bracketing.hpp" 64 Teuchos::RCP<Vector<Real> >
xnew_;
65 Teuchos::RCP<Vector<Real> >
g_;
66 Teuchos::RCP<ScalarMinimization<Real> >
sm_;
67 Teuchos::RCP<Bracketing<Real> >
br_;
68 Teuchos::RCP<ScalarFunction<Real> >
sf_;
76 class Phi :
public ScalarFunction<Real> {
78 const Teuchos::RCP<Vector<Real> >
xnew_;
79 const Teuchos::RCP<Vector<Real> >
g_;
80 const Teuchos::RCP<const Vector<Real> >
x_;
81 const Teuchos::RCP<const Vector<Real> >
s_;
82 const Teuchos::RCP<Objective<Real> >
obj_;
83 const Teuchos::RCP<BoundConstraint<Real> >
con_;
88 if (
con_->isActivated() ) {
110 return s_->dot(
g_->dual());
116 Teuchos::RCP<ScalarFunction<Real> >
phi_;
130 const Real c1,
const Real c2,
const Real c3,
132 const Teuchos::RCP<ScalarFunction<Real> > &phi)
136 bool check(Real &x, Real &fx, Real &gx,
137 int &nfval,
int &ngval,
const bool deriv =
false) {
141 bool curvcond =
false;
145 curvcond = (fx >=
f0_ + (one-
c1_)*x*
g0_);
152 gx =
phi_->deriv(x); ngval++;
155 curvcond = (gx >=
c2_*
g0_);
158 curvcond = (std::abs(gx) <=
c2_*std::abs(
g0_));
164 curvcond = (
c2_*
g0_ <= gx && gx <= (two*
c1_ - one)*
g0_);
169 return (armijo && curvcond);
176 const Teuchos::RCP<ScalarMinimization<Real> > &sm = Teuchos::null,
177 const Teuchos::RCP<Bracketing<Real> > &br = Teuchos::null,
178 const Teuchos::RCP<ScalarFunction<Real> > &sf = Teuchos::null )
180 Real zero(0), p4(0.4), p6(0.6), p9(0.9), oem4(1.e-4), oem10(1.e-10), one(1);
181 Teuchos::ParameterList &list0 = parlist.sublist(
"Step").sublist(
"Line Search");
182 Teuchos::ParameterList &list = list0.sublist(
"Line-Search Method");
184 if( br == Teuchos::null ) {
185 br_ = Teuchos::rcp(
new Bracketing<Real>());
191 std::string type = list.get(
"Type",
"Brent's");
192 Real tol = list.sublist(type).get(
"Tolerance",oem10);
193 int niter = list.sublist(type).get(
"Iteration Limit",1000);
194 Teuchos::ParameterList plist;
195 plist.sublist(
"Scalar Minimization").set(
"Type",type);
196 plist.sublist(
"Scalar Minimization").sublist(type).set(
"Tolerance",tol);
197 plist.sublist(
"Scalar Minimization").sublist(type).set(
"Iteration Limit",niter);
199 if( sm == Teuchos::null ) {
201 if ( type ==
"Brent's" ) {
202 sm_ = Teuchos::rcp(
new BrentsScalarMinimization<Real>(plist));
204 else if ( type ==
"Bisection" ) {
205 sm_ = Teuchos::rcp(
new BisectionScalarMinimization<Real>(plist));
207 else if ( type ==
"Golden Section" ) {
208 sm_ = Teuchos::rcp(
new GoldenSectionScalarMinimization<Real>(plist));
211 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
212 ">>> (ROL::ScalarMinimizationLineSearch): Undefined ScalarMinimization type!");
224 max_nfval_ = list0.get(
"Function Evaluation Limit",20);
225 c1_ = list0.get(
"Sufficient Decrease Tolerance",oem4);
226 c2_ = list0.sublist(
"Curvature Condition").get(
"General Parameter",p9);
227 c3_ = list0.sublist(
"Curvature Condition").get(
"Generalized Wolfe Parameter",p6);
251 void run( Real &alpha, Real &fval,
int &ls_neval,
int &ls_ngrad,
254 ls_neval = 0; ls_ngrad = 0;
260 Teuchos::RCP<const Vector<Real> > x_ptr = Teuchos::rcpFromRef(x);
261 Teuchos::RCP<const Vector<Real> > s_ptr = Teuchos::rcpFromRef(s);
262 Teuchos::RCP<Objective<Real> > obj_ptr = Teuchos::rcpFromRef(obj);
263 Teuchos::RCP<BoundConstraint<Real> > bnd_ptr = Teuchos::rcpFromRef(con);
266 Teuchos::RCP<ScalarFunction<Real> > phi;
268 if(
sf_ == Teuchos::null ) {
269 phi = Teuchos::rcp(
new Phi(
xnew_,
g_,x_ptr,s_ptr,obj_ptr,bnd_ptr));
275 Teuchos::RCP<ScalarMinimizationStatusTest<Real> > test
279 int nfval = 0, ngrad = 0;
280 Real A(0), fA = fval;
281 Real B = alpha, fB = phi->value(B);
282 br_->run(alpha,fval,A,fA,B,fB,nfval,ngrad,*phi,*test);
284 ls_neval += nfval; ls_ngrad += ngrad;
287 nfval = 0, ngrad = 0;
288 sm_->run(fval, alpha, nfval, ngrad, *phi, A, B, *test);
289 ls_neval += nfval; ls_ngrad += ngrad;
Provides the interface to evaluate objective functions.
void initialize(const Vector< Real > &x, const Vector< Real > &s, const Vector< Real > &g, Objective< Real > &obj, BoundConstraint< Real > &con)
Real deriv(const Real alpha)
Phi(const Teuchos::RCP< Vector< Real > > &xnew, const Teuchos::RCP< Vector< Real > > &g, const Teuchos::RCP< const Vector< Real > > &x, const Teuchos::RCP< const Vector< Real > > &s, const Teuchos::RCP< Objective< Real > > &obj, const Teuchos::RCP< 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)
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)
const Teuchos::RCP< Vector< Real > > g_
Teuchos::RCP< ScalarMinimization< Real > > sm_
Teuchos::RCP< ScalarFunction< Real > > phi_
const Teuchos::RCP< Vector< Real > > xnew_
virtual Teuchos::RCP< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
Defines the linear algebra or vector space interface.
Teuchos::RCP< Vector< Real > > g_
ScalarMinimizationLineSearch(Teuchos::ParameterList &parlist, const Teuchos::RCP< ScalarMinimization< Real > > &sm=Teuchos::null, const Teuchos::RCP< Bracketing< Real > > &br=Teuchos::null, const Teuchos::RCP< ScalarFunction< Real > > &sf=Teuchos::null)
const Teuchos::RCP< BoundConstraint< Real > > con_
const ECurvatureCondition econd_
EDescent StringToEDescent(std::string s)
Provides interface for and implements line searches.
bool check(Real &x, Real &fx, Real &gx, int &nfval, int &ngval, const bool deriv=false)
Teuchos::RCP< Bracketing< Real > > br_
LineSearchStatusTest(const Real f0, const Real g0, const Real c1, const Real c2, const Real c3, const int max_nfval, ECurvatureCondition econd, const Teuchos::RCP< ScalarFunction< Real > > &phi)
ECurvatureCondition econd_
Provides the interface to apply upper and lower bound constraints.
const Teuchos::RCP< const Vector< Real > > s_
Teuchos::RCP< ScalarFunction< Real > > sf_
void updateIterate(Real alpha)
Teuchos::RCP< Vector< Real > > xnew_
ECurvatureCondition
Enumeration of line-search curvature conditions.
ECurvatureCondition StringToECurvatureCondition(std::string s)
const Teuchos::RCP< Objective< Real > > obj_
Real value(const Real alpha)
Real ROL_EPSILON(void)
Platform-dependent machine epsilon.
Implements line search methods that attempt to minimize the scalar function .
EDescent
Enumeration of descent direction types.
const Teuchos::RCP< const Vector< Real > > x_
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)