20 #ifndef ROL_ROSENBROCK_HPP
21 #define ROL_ROSENBROCK_HPP
31 template<
class Real,
class XPrim=StdVector<Real>,
class XDual=StdVector<Real> >
45 template<
class VectorType>
47 return dynamic_cast<const VectorType&
>((x)).getVector();
50 template<
class VectorType>
52 return dynamic_cast<VectorType&
>(x).
getVector();
61 ROL::Ptr<const vector> xp = getVector<XPrim>(x);
65 for(
uint i=0; i<n/2; i++ ) {
66 val +=
alpha_ * pow(pow((*xp)[2*i],2) - (*xp)[2*i+1], 2);
67 val += pow((*xp)[2*i] - 1.0, 2);
80 ROL::Ptr<const vector> xp = getVector<XPrim>(x);
81 ROL::Ptr<vector> gp = getVector<XDual>(g);
84 for(
uint i=0; i<n/2; i++ ) {
85 (*gp)[2*i] = 4.0*
alpha_*(pow((*xp)[2*i],2) - (*xp)[2*i+1])*(*xp)[2*i] + 2.0*((*xp)[2*i]-1.0);
86 (*gp)[2*i+1] = -2.0*
alpha_*(pow((*xp)[2*i],2) - (*xp)[2*i+1]);
99 ROL::Ptr<const vector> xp = getVector<XPrim>(x);
100 ROL::Ptr<const vector> vp = getVector<XPrim>(v);
101 ROL::Ptr<vector> hvp = getVector<XDual>(hv);
104 for(
uint i=0; i<n/2; i++ ) {
105 Real h11 = 4.0*
alpha_*(3.0*pow((*xp)[2*i],2)-(*xp)[2*i+1]) + 2.0;
106 Real h12 = -4.0*
alpha_*(*xp)[2*i];
109 (*hvp)[2*i] = h11*(*vp)[2*i] + h12*(*vp)[2*i+1];
110 (*hvp)[2*i+1] = h12*(*vp)[2*i] + h22*(*vp)[2*i+1];
118 ROL::Ptr<const vector> xp = getVector<XPrim>(x);
119 ROL::Ptr<const vector> vp = getVector<XDual>(v);
120 ROL::Ptr<vector> hvp = getVector<XPrim>(hv);
123 for(
uint i=0; i<n/2; i++ ) {
124 Real h11 = 4.0*
alpha_*(3.0*pow((*xp)[2*i],2)-(*xp)[2*i+1]) + 2.0;
125 Real h12 = -4.0*
alpha_*(*xp)[2*i];
128 (*hvp)[2*i] = (1.0/(h11*h22-h12*h12))*( h22*(*vp)[2*i] - h12*(*vp)[2*i+1]);
129 (*hvp)[2*i+1] = (1.0/(h11*h22-h12*h12))*(-h12*(*vp)[2*i] + h11*(*vp)[2*i+1]);
141 return ROL::makePtr<Objective_Rosenbrock<Real>>();
148 ROL::Ptr<std::vector<Real> > x0p = ROL::makePtr<std::vector<Real>>(n,0.0);
149 for (
int i = 0; i < n/2; i++ ) {
153 return ROL::makePtr<StdVector<Real>>(x0p);
160 ROL::Ptr<std::vector<Real> > xp = ROL::makePtr<std::vector<Real>>(n,0.0);
161 for (
int i = 0; i < n; i++ ) {
164 return ROL::makePtr<StdVector<Real>>(xp);
Provides the interface to evaluate objective functions.
typename PV< Real >::size_type size_type
Ptr< Vector< Real > > getSolution(const int i=0) const
std::vector< Real > vector
Rosenbrock's function.
ROL::Ptr< const vector > getVector(const V &x)
virtual void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply Hessian approximation to vector.
void invHessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply inverse Hessian approximation to vector.
ROL::Ptr< vector > getVector(V &x)
Defines the linear algebra or vector space interface.
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
Ptr< Objective< Real > > getObjective(void) const
Real value(const Vector< Real > &x, Real &tol)
Compute value.
Contains definitions of test objective functions.
Objective_Rosenbrock(Real alpha=100.0)
Ptr< Vector< Real > > getInitialGuess(void) const