19 #ifndef ROL_QUARTIC_HPP
20 #define ROL_QUARTIC_HPP
35 Real
value(
const std::vector<Real> &x, Real &tol ) {
37 return std::pow(x[0]-one, 4) + std::pow(x[1]-one, 4);
40 void gradient( std::vector<Real> &g,
const std::vector<Real> &x, Real &tol ) {
41 const Real one(1), four(4);
42 g[0] = four * std::pow(x[0]-one, 3);
43 g[1] = four * std::pow(x[1]-one, 3);
46 void hessVec( std::vector<Real> &hv,
const std::vector<Real> &v,
const std::vector<Real> &x, Real &tol ) {
47 const Real one(1), twelve(12);
48 hv[0] = twelve * std::pow(x[0]-one, 2) * v[0];
49 hv[1] = twelve * std::pow(x[1]-one, 2) * v[1];
59 void value( std::vector<Real> &c,
const std::vector<Real> &x, Real &tol ) {
61 c[0] = std::pow(x[0], 2) - half*x[1];
62 c[1] = std::pow(x[1], 2) - half*x[0];
65 void applyJacobian( std::vector<Real> &jv,
const std::vector<Real> &v,
const std::vector<Real> &x, Real &tol ) {
66 const Real half(0.5), two(2);
67 jv[0] = two*x[0]*v[0] - half*v[1];
68 jv[1] = two*x[1]*v[1] - half*v[0];
71 void applyAdjointJacobian( std::vector<Real> &ajv,
const std::vector<Real> &v,
const std::vector<Real> &x, Real &tol ) {
72 const Real half(0.5), two(2);
73 ajv[0] = two*x[0]*v[0] - half*v[1];
74 ajv[1] = two*x[1]*v[1] - half*v[0];
77 void applyAdjointHessian( std::vector<Real> &ahuv,
const std::vector<Real> &u,
const std::vector<Real> &v,
const std::vector<Real> &x, Real &tol ) {
79 ahuv[0] = two*u[0]*v[0];
80 ahuv[1] = two*u[1]*v[1];
91 return makePtr<Objective_Quartic<Real>>();
96 Ptr<std::vector<Real>> scale = makePtr<std::vector<Real>>(n,
static_cast<Real
>(1.0));
97 Ptr<std::vector<Real>> xp = makePtr<std::vector<Real>>(n,
static_cast<Real
>(1.0));
98 return makePtr<PrimalScaledStdVector<Real>>(xp,scale);
103 Ptr<std::vector<Real>> scale = makePtr<std::vector<Real>>(n,
static_cast<Real
>(1.0));
104 Ptr<std::vector<Real>> xp = makePtr<std::vector<Real>>(n,
static_cast<Real
>(0.5));
105 return makePtr<PrimalScaledStdVector<Real>>(xp,scale);
110 Ptr<std::vector<Real>> scale = makePtr<std::vector<Real>>(n,
static_cast<Real
>(1.0));
111 Ptr<std::vector<Real>> lp = makePtr<std::vector<Real>>(n,
static_cast<Real
>(0.0));
112 Ptr<std::vector<Real>> up = makePtr<std::vector<Real>>(n,
static_cast<Real
>(0.0));
113 (*lp)[0] =
static_cast<Real
>( 0.5);
114 (*lp)[1] =
static_cast<Real
>(-2.9);
115 (*up)[0] =
static_cast<Real
>( 5.8);
116 (*up)[1] =
static_cast<Real
>( 2.9);
117 Ptr<Vector<Real>> l = makePtr<PrimalScaledStdVector<Real>>(lp,scale);
118 Ptr<Vector<Real>> u = makePtr<PrimalScaledStdVector<Real>>(up,scale);
119 return makePtr<Bounds<Real>>(l,u);
123 return makePtr<Constraint_Quartic<Real>>();
127 Ptr<std::vector<Real>> scale = makePtr<std::vector<Real>>(2,
static_cast<Real
>(1.0));
128 Ptr<std::vector<Real>> lp = makePtr<std::vector<Real>>(2,
static_cast<Real
>(0.0));
129 return makePtr<DualScaledStdVector<Real>>(lp,scale);
133 Ptr<std::vector<Real>> scale = makePtr<std::vector<Real>>(2,
static_cast<Real
>(1.0));
134 Ptr<std::vector<Real>> up = makePtr<std::vector<Real>>(2,
static_cast<Real
>(0.0));
135 Ptr<Vector<Real>> u = makePtr<DualScaledStdVector<Real>>(up,scale);
136 return makePtr<Bounds<Real>>(*u,
false);
void applyJacobian(std::vector< Real > &jv, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
Ptr< Vector< Real > > getSolution(const int i=0) const
Ptr< BoundConstraint< Real > > getSlackBoundConstraint(void) const
Ptr< Vector< Real > > getInitialGuess(void) const
Ptr< Objective< Real > > getObjective(void) const
Defines the equality constraint operator interface for StdVectors.
void value(std::vector< Real > &c, const std::vector< Real > &x, Real &tol)
Ptr< Constraint< Real > > getInequalityConstraint(void) const
virtual 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 applyAdjointJacobian(std::vector< Real > &ajv, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
Ptr< Vector< Real > > getInequalityMultiplier(void) const
Contains definitions of test objective functions.
Ptr< BoundConstraint< Real > > getBoundConstraint(void) const
Real value(const std::vector< Real > &x, Real &tol)
void applyAdjointHessian(Vector< Real > &ahuv, const Vector< Real > &u, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply the derivative of the adjoint of the constraint Jacobian at to vector in direction ...
void gradient(std::vector< Real > &g, const std::vector< Real > &x, Real &tol)