19#ifndef ROL_PARABOLOIDCIRCLE_HPP
20#define ROL_PARABOLOIDCIRCLE_HPP
24#include "ROL_LinearAlgebra.hpp"
32 template<
class Real,
class XPrim=StdVector<Real>,
class XDual=StdVector<Real> >
38 typedef typename vector::size_type
uint;
43 template<
class VectorType>
46 return dynamic_cast<const VectorType&
>(x).
getVector();
49 template<
class VectorType>
52 return dynamic_cast<VectorType&
>(x).
getVector();
64 ROL_TEST_FOR_EXCEPTION( (n != 2), std::invalid_argument,
">>> ERROR (ROL_ParaboloidCircle, objective value): "
65 "Primal vector x must be of length 2.");
70 Real val = x1*x1 + x2*x2;
82 ROL_TEST_FOR_EXCEPTION( (n != 2), std::invalid_argument,
">>> ERROR (ROL_ParaboloidCircle, objective gradient): "
83 " Primal vector x must be of length 2.");
86 ROL_TEST_FOR_EXCEPTION( (n != 2), std::invalid_argument,
">>> ERROR (ROL_ParaboloidCircle, objective gradient): "
87 "Gradient vector g must be of length 2.");
106 ROL_TEST_FOR_EXCEPTION( (n != 2), std::invalid_argument,
">>> ERROR (ROL_ParaboloidCircle, objective hessVec): "
107 "Primal vector x must be of length 2.");
110 ROL_TEST_FOR_EXCEPTION( (n != 2), std::invalid_argument,
">>> ERROR (ROL_ParaboloidCircle, objective hessVec): "
111 "Input vector v must be of length 2.");
114 ROL_TEST_FOR_EXCEPTION( (n != 2), std::invalid_argument,
">>> ERROR (ROL_ParaboloidCircle, objective hessVec): "
115 "Output vector hv must be of length 2.");
131 template<
class Real,
class XPrim=StdVector<Real>,
class XDual=StdVector<Real>,
class CPrim=StdVector<Real>,
class CDual=StdVector<Real> >
137 typedef typename vector::size_type
uint;
140 template<
class VectorType>
143 return dynamic_cast<const VectorType&
>(x).
getVector();
146 template<
class VectorType>
149 return dynamic_cast<VectorType&
>(x).
getVector();
162 ROL_TEST_FOR_EXCEPTION( (n != 2), std::invalid_argument,
">>> ERROR (ROL_ParaboloidCircle, constraint value): "
163 "Primal vector x must be of length 2.");
166 ROL_TEST_FOR_EXCEPTION( (m != 1), std::invalid_argument,
">>> ERROR (ROL_ParaboloidCircle, constraint value): "
167 "Constraint vector c must be of length 1.");
174 (*cp)[0] = (x1-two)*(x1-two) + x2*x2 - one;
185 ROL_TEST_FOR_EXCEPTION( (n != 2), std::invalid_argument,
">>> ERROR (ROL_ParaboloidCircle, constraint applyJacobian): "
186 "Primal vector x must be of length 2.");
189 ROL_TEST_FOR_EXCEPTION( (d != 2), std::invalid_argument,
">>> ERROR (ROL_ParaboloidCircle, constraint applyJacobian): "
190 "Input vector v must be of length 2.");
192 ROL_TEST_FOR_EXCEPTION( (d != 1), std::invalid_argument,
">>> ERROR (ROL_ParaboloidCircle, constraint applyJacobian): "
193 "Output vector jv must be of length 1.");
203 (*jvp)[0] = two*(x1-two)*v1 + two*x2*v2;
214 ROL_TEST_FOR_EXCEPTION( (n != 2), std::invalid_argument,
">>> ERROR (ROL_ParaboloidCircle, constraint applyAdjointJacobian): "
215 "Primal vector x must be of length 2.");
218 ROL_TEST_FOR_EXCEPTION( (d != 1), std::invalid_argument,
">>> ERROR (ROL_ParaboloidCircle, constraint applyAdjointJacobian): "
219 "Input vector v must be of length 1.");
222 ROL_TEST_FOR_EXCEPTION( (d != 2), std::invalid_argument,
">>> ERROR (ROL_ParaboloidCircle, constraint applyAdjointJacobian): "
223 "Output vector ajv must be of length 2.");
232 (*ajvp)[0] = two*(x1-two)*v1;
233 (*ajvp)[1] = two*x2*v1;
252 ROL_TEST_FOR_EXCEPTION( (n != 2), std::invalid_argument,
">>> ERROR (ROL_ParaboloidCircle, constraint applyAdjointHessian): "
253 "Primal vector x must be of length 2.");
256 ROL_TEST_FOR_EXCEPTION( (n != 2), std::invalid_argument,
">>> ERROR (ROL_ParaboloidCircle, constraint applyAdjointHessian): "
257 "Direction vector v must be of length 2.");
260 ROL_TEST_FOR_EXCEPTION( (n != 2), std::invalid_argument,
">>> ERROR (ROL_ParaboloidCircle, constraint applyAdjointHessian): "
261 "Output vector ahuv must be of length 2.");
263 ROL_TEST_FOR_EXCEPTION( (d != 1), std::invalid_argument,
">>> ERROR (ROL_ParaboloidCircle, constraint applyAdjointHessian): "
264 "Dual constraint vector u must be of length 1.");
273 (*ahuvp)[0] = two*u1*v1;
274 (*ahuvp)[1] = two*u1*v2;
281 template<
class Real,
class XPrim=StdVector<Real>,
class XDual=StdVector<Real>,
class CPrim=StdVector<Real>,
class CDual=StdVector<Real> >
284 typedef typename vector::size_type
uint;
290 return ROL::makePtr<Objective_ParaboloidCircle<Real,XPrim,XDual>>();
296 ROL::Ptr<vector> x0p = makePtr<vector>(n,0.0);
297 (*x0p)[0] =
static_cast<Real
>(rand())/
static_cast<Real
>(RAND_MAX);
298 (*x0p)[1] =
static_cast<Real
>(rand())/
static_cast<Real
>(RAND_MAX);
299 return makePtr<XPrim>(x0p);
305 Real
zero(0), one(1);
306 ROL::Ptr<vector> solp = makePtr<vector>(n,0.0);
309 return makePtr<XPrim>(solp);
314 return ROL::makePtr<Constraint_ParaboloidCircle<Real,XPrim,XDual,CPrim,CDual>>();
318 ROL::Ptr<vector> lp = makePtr<vector>(1,0.0);
319 return makePtr<CDual>(lp);
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0 zero)()
Contains definitions of test objective functions.
virtual 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 ,...
Defines the linear algebra or vector space interface.
void value(Vector< Real > &c, const Vector< Real > &x, Real &tol)
Constraint_ParaboloidCircle()
ROL::Ptr< vector > getVector(V &x)
void applyJacobian(Vector< Real > &jv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
ROL::Ptr< const vector > getVector(const V &x)
void applyAdjointJacobian(Vector< Real > &ajv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
std::vector< Real > vector
void applyAdjointHessian(Vector< Real > &ahuv, const Vector< Real > &u, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Objective_ParaboloidCircle()
std::vector< Real > vector
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
ROL::Ptr< vector > getVector(V &x)
Real value(const Vector< Real > &x, Real &tol)
ROL::Ptr< const vector > getVector(const V &x)
Ptr< Vector< Real > > getSolution(const int i=0) const
Ptr< Constraint< Real > > getEqualityConstraint(void) const
getParaboloidCircle(void)
Ptr< Objective< Real > > getObjective(void) const
Ptr< Vector< Real > > getEqualityMultiplier(void) const
Ptr< Vector< Real > > getInitialGuess(void) const
std::vector< Real > vector