10 #ifndef ROL_STDOBJECTIVE_DEF_H
11 #define ROL_STDOBJECTIVE_DEF_H
15 template<
typename Real>
21 template<
typename Real>
27 template<
typename Real>
33 template<
typename Real>
35 const unsigned size = x.size();
36 std::vector<Real> y; y.assign(x.begin(),x.end());
37 const Real cbrteps = std::cbrt(ROL::ROL_EPSILON<Real>()), one(1);
39 const Real val =
value(x,tol);
40 for (
unsigned i = 0; i < size; ++i) {
42 h = cbrteps * std::max(std::abs(xi),one) * sgn(xi);
46 g[i] = (
value(y,tol) - val)/h;
52 template<
typename Real>
59 template<
typename Real>
61 ROL_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
62 ">>> ERROR (ROL::StdObjective): dirDeriv not implemented!");
65 template<
typename Real>
72 catch (std::exception &e) {
77 template<
typename Real>
79 ROL_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
80 ">>> ERROR (ROL::StdObjective): hessVec not implemented!");
83 template<
typename Real>
91 catch (std::exception &e) {
96 template<
typename Real>
98 ROL_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
99 ">>> ERROR (ROL::StdObjective): invHessVec not implemented!");
102 template<
typename Real>
110 template<
typename Real>
112 Pv.assign(v.begin(),v.end());
115 template<
typename Real>
123 template<
typename Real>
125 const Real
zero(0), one(1);
126 return (x <
zero ? -one : one);
virtual Real value(const std::vector< Real > &x, Real &tol)=0
virtual void update(const Vector< Real > &u, const Vector< Real > &z, bool flag=true, int iter=-1) override
virtual Real dirDeriv(const Vector< Real > &x, const Vector< Real > &d, Real &tol)
Compute directional derivative.
virtual void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply Hessian approximation to vector.
Ptr< const std::vector< Element > > getVector() const
ROL::Objective_SimOpt value
Defines the linear algebra or vector space interface.
virtual void hessVec(std::vector< Real > &hv, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0_ zero()
virtual void gradient(std::vector< Real > &g, const std::vector< Real > &x, Real &tol)
virtual void invHessVec(std::vector< Real > &hv, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
virtual void update(const std::vector< Real > &x, bool flag=true, int iter=-1)
virtual void precond(std::vector< Real > &Pv, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
virtual Real dirDeriv(const std::vector< Real > &x, const std::vector< Real > &d, Real &tol)