10 #ifndef ROL_ScalarMinimizationLineSearch_H
11 #define ROL_ScalarMinimizationLineSearch_H
19 #include "ROL_BrentsScalarMinimization.hpp"
20 #include "ROL_BisectionScalarMinimization.hpp"
21 #include "ROL_GoldenSectionScalarMinimization.hpp"
22 #include "ROL_ScalarFunction.hpp"
23 #include "ROL_Bracketing.hpp"
31 ROL::Ptr<Vector<Real> >
g_;
32 ROL::Ptr<ScalarMinimization<Real> >
sm_;
33 ROL::Ptr<Bracketing<Real> >
br_;
34 ROL::Ptr<ScalarFunction<Real> >
sf_;
42 class Phi :
public ScalarFunction<Real> {
44 const ROL::Ptr<Vector<Real> >
xnew_;
45 const ROL::Ptr<Vector<Real> >
g_;
46 const ROL::Ptr<const Vector<Real> >
x_;
47 const ROL::Ptr<const Vector<Real> >
s_;
48 const ROL::Ptr<Objective<Real> >
obj_;
49 const ROL::Ptr<BoundConstraint<Real> >
con_;
54 if (
con_->isActivated() ) {
76 return s_->dot(
g_->dual());
82 ROL::Ptr<ScalarFunction<Real> >
phi_;
96 const Real c1,
const Real c2,
const Real c3,
98 const ROL::Ptr<ScalarFunction<Real> > &phi)
102 bool check(Real &x, Real &fx, Real &gx,
103 int &nfval,
int &ngval,
const bool deriv =
false) {
107 bool curvcond =
false;
111 curvcond = (fx >=
f0_ + (one-
c1_)*x*
g0_);
118 gx =
phi_->deriv(x); ngval++;
121 curvcond = (gx >=
c2_*
g0_);
124 curvcond = (std::abs(gx) <=
c2_*std::abs(
g0_));
130 curvcond = (
c2_*
g0_ <= gx && gx <= (two*
c1_ - one)*g0_);
135 return (armijo && curvcond);
142 const ROL::Ptr<ScalarMinimization<Real> > &sm = ROL::nullPtr,
143 const ROL::Ptr<Bracketing<Real> > &br = ROL::nullPtr,
144 const ROL::Ptr<ScalarFunction<Real> > &sf = ROL::nullPtr )
146 Real
zero(0), p4(0.4), p6(0.6), p9(0.9), oem4(1.e-4), oem10(1.e-10), one(1);
147 ROL::ParameterList &list0 = parlist.sublist(
"Step").sublist(
"Line Search");
148 ROL::ParameterList &list = list0.sublist(
"Line-Search Method");
150 if( br == ROL::nullPtr ) {
151 br_ = ROL::makePtr<Bracketing<Real>>();
157 std::string type = list.get(
"Type",
"Brent's");
158 Real tol = list.sublist(type).get(
"Tolerance",oem10);
159 int niter = list.sublist(type).get(
"Iteration Limit",1000);
160 ROL::ParameterList plist;
161 plist.sublist(
"Scalar Minimization").set(
"Type",type);
162 plist.sublist(
"Scalar Minimization").sublist(type).set(
"Tolerance",tol);
163 plist.sublist(
"Scalar Minimization").sublist(type).set(
"Iteration Limit",niter);
165 if( sm == ROL::nullPtr ) {
167 if ( type ==
"Brent's" ) {
168 sm_ = ROL::makePtr<BrentsScalarMinimization<Real>>(plist);
170 else if ( type ==
"Bisection" ) {
171 sm_ = ROL::makePtr<BisectionScalarMinimization<Real>>(plist);
173 else if ( type ==
"Golden Section" ) {
174 sm_ = ROL::makePtr<GoldenSectionScalarMinimization<Real>>(plist);
177 ROL_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
178 ">>> (ROL::ScalarMinimizationLineSearch): Undefined ScalarMinimization type!");
189 std::string condName = list0.sublist(
"Curvature Condition").get(
"Type",
"Strong Wolfe Conditions");
191 max_nfval_ = list0.get(
"Function Evaluation Limit",20);
192 c1_ = list0.get(
"Sufficient Decrease Tolerance",oem4);
193 c2_ = list0.sublist(
"Curvature Condition").get(
"General Parameter",p9);
194 c3_ = list0.sublist(
"Curvature Condition").get(
"Generalized Wolfe Parameter",p6);
203 std::string descentName = list0.sublist(
"Descent Method").get(
"Type",
"Quasi-Newton Method");
207 c3_ = std::min(one-c2_,c3_);
219 void run( Real &alpha, Real &fval,
int &ls_neval,
int &ls_ngrad,
222 ls_neval = 0; ls_ngrad = 0;
228 ROL::Ptr<const Vector<Real> > x_ptr = ROL::makePtrFromRef(x);
229 ROL::Ptr<const Vector<Real> > s_ptr = ROL::makePtrFromRef(s);
230 ROL::Ptr<Objective<Real> > obj_ptr = ROL::makePtrFromRef(obj);
231 ROL::Ptr<BoundConstraint<Real> > bnd_ptr = ROL::makePtrFromRef(con);
234 ROL::Ptr<ScalarFunction<Real> > phi;
236 if(
sf_ == ROL::nullPtr ) {
237 phi = ROL::makePtr<Phi>(
xnew_,
g_,x_ptr,s_ptr,obj_ptr,bnd_ptr);
243 ROL::Ptr<ScalarMinimizationStatusTest<Real> > test
247 int nfval = 0, ngrad = 0;
248 Real A(0), fA = fval;
249 Real B = alpha, fB = phi->value(B);
250 br_->run(alpha,fval,A,fA,B,fB,nfval,ngrad,*phi,*test);
252 ls_neval += nfval; ls_ngrad += ngrad;
255 nfval = 0, ngrad = 0;
256 sm_->run(fval, alpha, nfval, ngrad, *phi, A, B, *test);
257 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)
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.
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)
ROL::Ptr< Bracketing< Real > > br_
const ROL::Ptr< const Vector< Real > > x_
Defines the linear algebra or vector space interface.
Phi(const ROL::Ptr< Vector< Real > > &xnew, const ROL::Ptr< Vector< Real > > &g, const ROL::Ptr< const Vector< Real > > &x, const ROL::Ptr< const Vector< Real > > &s, const ROL::Ptr< Objective< Real > > &obj, const ROL::Ptr< BoundConstraint< Real > > &con)
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0_ zero()
const ROL::Ptr< Vector< Real > > xnew_
const ROL::Ptr< Vector< Real > > g_
const ECurvatureCondition econd_
EDescent StringToEDescent(std::string s)
ROL::Ptr< ScalarFunction< Real > > sf_
Provides interface for and implements line searches.
ROL::Ptr< Vector< Real > > xnew_
const ROL::Ptr< const Vector< Real > > s_
ScalarMinimizationLineSearch(ROL::ParameterList &parlist, const ROL::Ptr< ScalarMinimization< Real > > &sm=ROL::nullPtr, const ROL::Ptr< Bracketing< Real > > &br=ROL::nullPtr, const ROL::Ptr< ScalarFunction< Real > > &sf=ROL::nullPtr)
const ROL::Ptr< Objective< Real > > obj_
bool check(Real &x, Real &fx, Real &gx, int &nfval, int &ngval, const bool deriv=false)
const ROL::Ptr< BoundConstraint< Real > > con_
ROL::Ptr< ScalarFunction< Real > > phi_
ECurvatureCondition econd_
Provides the interface to apply upper and lower bound constraints.
ROL::Ptr< ScalarMinimization< Real > > sm_
void updateIterate(Real alpha)
ECurvatureCondition
Enumeration of line-search curvature conditions.
ECurvatureCondition StringToECurvatureCondition(std::string s)
LineSearchStatusTest(const Real f0, const Real g0, const Real c1, const Real c2, const Real c3, const int max_nfval, ECurvatureCondition econd, const ROL::Ptr< ScalarFunction< Real > > &phi)
Real value(const Real alpha)
Real ROL_EPSILON(void)
Platform-dependent machine epsilon.
Implements line search methods that attempt to minimize the scalar function .
ROL::Ptr< Vector< Real > > g_
EDescent
Enumeration of descent direction types.
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)