54 #ifndef ROL_ROSENBROCK_HPP
55 #define ROL_ROSENBROCK_HPP
65 template<
class Real,
class XPrim=StdVector<Real>,
class XDual=StdVector<Real> >
79 template<
class VectorType>
81 return dynamic_cast<const VectorType&
>((x)).getVector();
84 template<
class VectorType>
86 return dynamic_cast<VectorType&
>(x).
getVector();
95 ROL::Ptr<const vector> xp = getVector<XPrim>(x);
99 for(
uint i=0; i<n/2; i++ ) {
100 val +=
alpha_ * pow(pow((*xp)[2*i],2) - (*xp)[2*i+1], 2);
101 val += pow((*xp)[2*i] - 1.0, 2);
114 ROL::Ptr<const vector> xp = getVector<XPrim>(x);
115 ROL::Ptr<vector> gp = getVector<XDual>(g);
118 for(
uint i=0; i<n/2; i++ ) {
119 (*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);
120 (*gp)[2*i+1] = -2.0*
alpha_*(pow((*xp)[2*i],2) - (*xp)[2*i+1]);
133 ROL::Ptr<const vector> xp = getVector<XPrim>(x);
134 ROL::Ptr<const vector> vp = getVector<XPrim>(v);
135 ROL::Ptr<vector> hvp = getVector<XDual>(hv);
138 for(
uint i=0; i<n/2; i++ ) {
139 Real h11 = 4.0*
alpha_*(3.0*pow((*xp)[2*i],2)-(*xp)[2*i+1]) + 2.0;
140 Real h12 = -4.0*
alpha_*(*xp)[2*i];
143 (*hvp)[2*i] = h11*(*vp)[2*i] + h12*(*vp)[2*i+1];
144 (*hvp)[2*i+1] = h12*(*vp)[2*i] + h22*(*vp)[2*i+1];
152 ROL::Ptr<const vector> xp = getVector<XPrim>(x);
153 ROL::Ptr<const vector> vp = getVector<XDual>(v);
154 ROL::Ptr<vector> hvp = getVector<XPrim>(hv);
157 for(
uint i=0; i<n/2; i++ ) {
158 Real h11 = 4.0*
alpha_*(3.0*pow((*xp)[2*i],2)-(*xp)[2*i+1]) + 2.0;
159 Real h12 = -4.0*
alpha_*(*xp)[2*i];
162 (*hvp)[2*i] = (1.0/(h11*h22-h12*h12))*( h22*(*vp)[2*i] - h12*(*vp)[2*i+1]);
163 (*hvp)[2*i+1] = (1.0/(h11*h22-h12*h12))*(-h12*(*vp)[2*i] + h11*(*vp)[2*i+1]);
175 return ROL::makePtr<Objective_Rosenbrock<Real>>();
182 ROL::Ptr<std::vector<Real> > x0p = ROL::makePtr<std::vector<Real>>(n,0.0);
183 for (
int i = 0; i < n/2; i++ ) {
187 return ROL::makePtr<StdVector<Real>>(x0p);
194 ROL::Ptr<std::vector<Real> > xp = ROL::makePtr<std::vector<Real>>(n,0.0);
195 for (
int i = 0; i < n; i++ ) {
198 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