71 Real
value(
const std::vector<Real> &x, Real &tol ) {
72 const Real c2(2), c4(4);
73 return std::pow(x[0]-x[1],c2) + std::pow(x[1]-x[2],c2)
74 + std::pow(x[2]-x[3],c4) + std::pow(x[3]-x[4],c2);
77 void gradient( std::vector<Real> &g,
const std::vector<Real> &x, Real &tol ) {
78 const Real c2(2), c3(3), c4(4);
79 g[0] = c2*(x[0]-x[1]);
80 g[1] = c2*(x[1]-x[0]) + c2*(x[1]-x[2]);
81 g[2] = c2*(x[2]-x[1]) + c4*std::pow(x[2]-x[3],c3);
82 g[3] = c4*std::pow(x[3]-x[2],c3) + c2*(x[3]-x[4]);
83 g[4] = c2*(x[4]-x[3]);
86 void hessVec( std::vector<Real> &hv,
const std::vector<Real> &v,
const std::vector<Real> &x, Real &tol ) {
87 const Real c2(2), c3(3), c4(4);
88 hv[0] = c2*v[0] - c2*v[1];
89 hv[1] = (c2+c2)*v[1] - c2*v[0] - c2*v[2];
90 hv[2] = (c2 + c4*c3*std::pow(x[2]-x[3],c2))*v[2] - c2*v[1] - c4*c3*std::pow(x[3]-x[2],c2)*v[3];
91 hv[3] = (c4*c3*std::pow(x[3]-x[2],c2) + c2)*v[3] - c4*c3*std::pow(x[2]-x[3],c2)*v[2] - c2*v[4];
92 hv[4] = c2*v[4] - c2*v[3];
101 void value( std::vector<Real> &c,
const std::vector<Real> &x, Real &tol ) {
102 const Real c2(2), c3(3), c6(6);
103 c[0] = x[0]+c2*x[1]+c3*x[2]-c6;
104 c[1] = x[1]+c2*x[2]+c3*x[3]-c6;
105 c[2] = x[2]+c2*x[3]+c3*x[4]-c6;
109 const std::vector<Real> &x, Real &tol) {
110 const Real c2(2), c3(3);
111 jv[0] = v[0]+c2*v[1]+c3*v[2];
112 jv[1] = v[1]+c2*v[2]+c3*v[3];
113 jv[2] = v[2]+c2*v[3]+c3*v[4];
117 const std::vector<Real> &x, Real &tol ) {
118 const Real c2(2), c3(3);
120 ajv[1] = c2*v[0] + v[1];
121 ajv[2] = c3*v[0] + c2*v[1] + v[2];
122 ajv[3] = c3*v[1] + c2*v[2];
127 const std::vector<Real> &v,
const std::vector<Real> &x,
129 ahuv.assign(ahuv.size(),
static_cast<Real
>(0));
141 return ROL::makePtr<Objective_HS50<Real>>();
146 ROL::Ptr<std::vector<Real>> xp = ROL::makePtr<std::vector<Real>>(n,0.0);
147 (*xp)[0] =
static_cast<Real
>(35);
148 (*xp)[1] =
static_cast<Real
>(-31);
149 (*xp)[2] =
static_cast<Real
>(11);
150 (*xp)[3] =
static_cast<Real
>(5);
151 (*xp)[4] =
static_cast<Real
>(-5);
152 return ROL::makePtr<StdVector<Real>>(xp);
157 return ROL::makePtr<StdVector<Real>>(n,1.0);
161 return ROL::makePtr<Constraint_HS50<Real>>();
166 return ROL::makePtr<StdVector<Real>>(n,0.0);
Real value(const std::vector< Real > &x, Real &tol)
Ptr< Constraint< Real > > getEqualityConstraint(void) const
Contains definitions of custom data types in ROL.
Ptr< Vector< Real > > getInitialGuess(void) const
Defines the equality constraint operator interface for StdVectors.
void hessVec(std::vector< Real > &hv, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
Specializes the ROL::Objective interface for objective functions that operate on ROL::StdVector's.
void applyJacobian(std::vector< Real > &jv, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
Contains definitions of test objective functions.
W. Hock and K. Schittkowski 50th test function.
void applyAdjointJacobian(std::vector< Real > &ajv, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
void gradient(std::vector< Real > &g, const std::vector< Real > &x, Real &tol)
Ptr< Vector< Real > > getEqualityMultiplier(void) const
void value(std::vector< Real > &c, const std::vector< Real > &x, Real &tol)
Ptr< Objective< Real > > getObjective(void) const
void applyAdjointHessian(std::vector< Real > &ahuv, const std::vector< Real > &u, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
Ptr< Vector< Real > > getSolution(const int i=0) const