53 #ifndef ROL_QUARTIC_HPP
54 #define ROL_QUARTIC_HPP
69 Real
value(
const std::vector<Real> &x, Real &tol ) {
71 return std::pow(x[0]-one, 4) + std::pow(x[1]-one, 4);
74 void gradient( std::vector<Real> &g,
const std::vector<Real> &x, Real &tol ) {
75 const Real one(1), four(4);
76 g[0] = four * std::pow(x[0]-one, 3);
77 g[1] = four * std::pow(x[1]-one, 3);
80 void hessVec( std::vector<Real> &hv,
const std::vector<Real> &v,
const std::vector<Real> &x, Real &tol ) {
81 const Real one(1), twelve(12);
82 hv[0] = twelve * std::pow(x[0]-one, 2) * v[0];
83 hv[1] = twelve * std::pow(x[1]-one, 2) * v[1];
93 void value( std::vector<Real> &c,
const std::vector<Real> &x, Real &tol ) {
95 c[0] = std::pow(x[0], 2) - half*x[1];
96 c[1] = std::pow(x[1], 2) - half*x[0];
99 void applyJacobian( std::vector<Real> &jv,
const std::vector<Real> &v,
const std::vector<Real> &x, Real &tol ) {
100 const Real half(0.5), two(2);
101 jv[0] = two*x[0]*v[0] - half*v[1];
102 jv[1] = two*x[1]*v[1] - half*v[0];
105 void applyAdjointJacobian( std::vector<Real> &ajv,
const std::vector<Real> &v,
const std::vector<Real> &x, Real &tol ) {
106 const Real half(0.5), two(2);
107 ajv[0] = two*x[0]*v[0] - half*v[1];
108 ajv[1] = two*x[1]*v[1] - half*v[0];
111 void applyAdjointHessian( std::vector<Real> &ahuv,
const std::vector<Real> &u,
const std::vector<Real> &v,
const std::vector<Real> &x, Real &tol ) {
113 ahuv[0] = two*u[0]*v[0];
114 ahuv[1] = two*u[1]*v[1];
125 return makePtr<Objective_Quartic<Real>>();
130 Ptr<std::vector<Real>> scale = makePtr<std::vector<Real>>(n,
static_cast<Real
>(1.0));
131 Ptr<std::vector<Real>> xp = makePtr<std::vector<Real>>(n,
static_cast<Real
>(1.0));
132 return makePtr<PrimalScaledStdVector<Real>>(xp,scale);
137 Ptr<std::vector<Real>> scale = makePtr<std::vector<Real>>(n,
static_cast<Real
>(1.0));
138 Ptr<std::vector<Real>> xp = makePtr<std::vector<Real>>(n,
static_cast<Real
>(0.5));
139 return makePtr<PrimalScaledStdVector<Real>>(xp,scale);
144 Ptr<std::vector<Real>> scale = makePtr<std::vector<Real>>(n,
static_cast<Real
>(1.0));
145 Ptr<std::vector<Real>> lp = makePtr<std::vector<Real>>(n,
static_cast<Real
>(0.0));
146 Ptr<std::vector<Real>> up = makePtr<std::vector<Real>>(n,
static_cast<Real
>(0.0));
147 (*lp)[0] =
static_cast<Real
>( 0.5);
148 (*lp)[1] =
static_cast<Real
>(-2.9);
149 (*up)[0] =
static_cast<Real
>( 5.8);
150 (*up)[1] =
static_cast<Real
>( 2.9);
151 Ptr<Vector<Real>> l = makePtr<PrimalScaledStdVector<Real>>(lp,scale);
152 Ptr<Vector<Real>> u = makePtr<PrimalScaledStdVector<Real>>(up,scale);
153 return makePtr<Bounds<Real>>(l,u);
157 return makePtr<Constraint_Quartic<Real>>();
161 Ptr<std::vector<Real>> scale = makePtr<std::vector<Real>>(2,
static_cast<Real
>(1.0));
162 Ptr<std::vector<Real>> lp = makePtr<std::vector<Real>>(2,
static_cast<Real
>(0.0));
163 return makePtr<DualScaledStdVector<Real>>(lp,scale);
167 Ptr<std::vector<Real>> scale = makePtr<std::vector<Real>>(2,
static_cast<Real
>(1.0));
168 Ptr<std::vector<Real>> up = makePtr<std::vector<Real>>(2,
static_cast<Real
>(0.0));
169 Ptr<Vector<Real>> u = makePtr<DualScaledStdVector<Real>>(up,scale);
170 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
virtual void hessVec(std::vector< Real > &hv, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
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
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)
void applyAdjointHessian(Vector< Real > &ahuv, const Vector< Real > &u, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply the derivative of the adjoint of the constraint Jacobian at to vector in direction ...
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 gradient(std::vector< Real > &g, const std::vector< Real > &x, Real &tol)