38 y_.push_back(static_cast<Real>(1.5));
39 y_.push_back(static_cast<Real>(2.25));
40 y_.push_back(static_cast<Real>(2.625));
44 Ptr<const std::vector<Real> > ex
47 Real f1 =
static_cast<Real
>(1.5)-(*ex)[0]*(
static_cast<Real
>(1)-(*ex)[1]);
48 Real f2 =
static_cast<Real
>(2.25)-(*ex)[0]*(
static_cast<Real
>(1)-pow((*ex)[1],2));
49 Real f3 =
static_cast<Real
>(2.625)-(*ex)[0]*(
static_cast<Real
>(1)-pow((*ex)[1],3));
51 return pow(f1,2)+pow(f2,2)+pow(f3,2);
55 Ptr<std::vector<Real> > eg
57 Ptr<const std::vector<Real> > ex
60 Real f1 =
static_cast<Real
>(1.5)-(*ex)[0]*(
static_cast<Real
>(1)-(*ex)[1]);
61 Real f2 =
static_cast<Real
>(2.25)-(*ex)[0]*(
static_cast<Real
>(1)-pow((*ex)[1],2));
62 Real f3 =
static_cast<Real
>(2.625)-(*ex)[0]*(
static_cast<Real
>(1)-pow((*ex)[1],3));
63 Real df1dx = -(
static_cast<Real
>(1)-(*ex)[1]);
64 Real df1dy = (*ex)[0];
65 Real df2dx = -(
static_cast<Real
>(1)-pow((*ex)[1],2));
66 Real df2dy =
static_cast<Real
>(2)*(*ex)[0]*(*ex)[1];
67 Real df3dx = -(
static_cast<Real
>(1)-pow((*ex)[1],3));
68 Real df3dy =
static_cast<Real
>(3)*(*ex)[0]*pow((*ex)[1],2);
70 (*eg)[0] =
static_cast<Real
>(2)*df1dx*f1+static_cast<Real>(2)*df2dx*f2+
static_cast<Real
>(2)*df3dx*f3;
71 (*eg)[1] =
static_cast<Real
>(2)*df1dy*f1+static_cast<Real>(2)*df2dy*f2+
static_cast<Real
>(2)*df3dy*f3;
75 Ptr<std::vector<Real> > ehv
77 Ptr<const std::vector<Real> > ev
79 Ptr<const std::vector<Real> > ex
82 Real f1 =
static_cast<Real
>(1.5)-(*ex)[0]*(
static_cast<Real
>(1)-(*ex)[1]);
83 Real f2 =
static_cast<Real
>(2.25)-(*ex)[0]*(
static_cast<Real
>(1)-pow((*ex)[1],2));
84 Real f3 =
static_cast<Real
>(2.625)-(*ex)[0]*(
static_cast<Real
>(1)-pow((*ex)[1],3));
85 Real df1dx = -(
static_cast<Real
>(1)-(*ex)[1]);
86 Real df1dy = (*ex)[0];
87 Real df2dx = -(
static_cast<Real
>(1)-pow((*ex)[1],2));
88 Real df2dy =
static_cast<Real
>(2)*(*ex)[0]*(*ex)[1];
89 Real df3dx = -(
static_cast<Real
>(1)-pow((*ex)[1],3));
90 Real df3dy =
static_cast<Real
>(3)*(*ex)[0]*pow((*ex)[1],2);
91 Real d2f1dx2 =
static_cast<Real
>(0);
92 Real d2f1dy2 =
static_cast<Real
>(0);
93 Real d2f1dxdy =
static_cast<Real
>(1);
94 Real d2f2dx2 =
static_cast<Real
>(0);
95 Real d2f2dy2 =
static_cast<Real
>(2)*(*ex)[0];
96 Real d2f2dxdy =
static_cast<Real
>(2)*(*ex)[1];
97 Real d2f3dx2 =
static_cast<Real
>(0);
98 Real d2f3dy2 =
static_cast<Real
>(6)*(*ex)[0]*(*ex)[1];
99 Real d2f3dxdy =
static_cast<Real
>(3)*pow((*ex)[1],2);
101 Real H11 =
static_cast<Real
>(2)*(d2f1dx2*f1+df1dx*df1dx)+
static_cast<Real
>(2)*(d2f2dx2*f2+df2dx*df2dx)
102 +
static_cast<Real
>(2)*(d2f3dx2*f3+df3dx*df3dx);
103 Real H22 =
static_cast<Real
>(2)*(d2f1dy2*f1+df1dy*df1dy)+
static_cast<Real
>(2)*(d2f2dy2*f2+df2dy*df2dy)
104 +
static_cast<Real
>(2)*(d2f3dy2*f3+df3dy*df3dy);
105 Real H12 =
static_cast<Real
>(2)*(d2f1dxdy*f1 + df1dx*df1dy)+
static_cast<Real
>(2)*(d2f2dxdy*f2 + df2dx*df2dy)
106 +
static_cast<Real
>(2)*(d2f3dxdy*f3 + df3dx*df3dy);
108 (*ehv)[0] = H11*(*ev)[0]+H12*(*ev)[1];
109 (*ehv)[1] = H12*(*ev)[0]+H22*(*ev)[1];
113 Ptr<std::vector<Real> > ehv
115 Ptr<const std::vector<Real> > ev
117 Ptr<const std::vector<Real> > ex
120 Real f1 =
static_cast<Real
>(1.5)-(*ex)[0]*(
static_cast<Real
>(1)-(*ex)[1]);
121 Real f2 =
static_cast<Real
>(2.25)-(*ex)[0]*(
static_cast<Real
>(1)-pow((*ex)[1],2));
122 Real f3 =
static_cast<Real
>(2.625)-(*ex)[0]*(
static_cast<Real
>(1)-pow((*ex)[1],3));
123 Real df1dx = -(
static_cast<Real
>(1)-(*ex)[1]);
124 Real df1dy = (*ex)[0];
125 Real df2dx = -(
static_cast<Real
>(1)-pow((*ex)[1],2));
126 Real df2dy =
static_cast<Real
>(2)*(*ex)[0]*(*ex)[1];
127 Real df3dx = -(
static_cast<Real
>(1)-pow((*ex)[1],3));
128 Real df3dy =
static_cast<Real
>(3)*(*ex)[0]*pow((*ex)[1],2);
129 Real d2f1dx2 =
static_cast<Real
>(0);
130 Real d2f1dy2 =
static_cast<Real
>(0);
131 Real d2f1dxdy =
static_cast<Real
>(1);
132 Real d2f2dx2 =
static_cast<Real
>(0);
133 Real d2f2dy2 =
static_cast<Real
>(2)*(*ex)[0];
134 Real d2f2dxdy =
static_cast<Real
>(2)*(*ex)[1];
135 Real d2f3dx2 =
static_cast<Real
>(0);
136 Real d2f3dy2 =
static_cast<Real
>(6)*(*ex)[0]*(*ex)[1];
137 Real d2f3dxdy =
static_cast<Real
>(3)*pow((*ex)[1],2);
139 Real H11 =
static_cast<Real
>(2)*(d2f1dx2*f1+df1dx*df1dx)+
static_cast<Real
>(2)*(d2f2dx2*f2+df2dx*df2dx)
140 +
static_cast<Real
>(2)*(d2f3dx2*f3+df3dx*df3dx);
141 Real H22 =
static_cast<Real
>(2)*(d2f1dy2*f1+df1dy*df1dy)+
static_cast<Real
>(2)*(d2f2dy2*f2+df2dy*df2dy)
142 +
static_cast<Real
>(2)*(d2f3dy2*f3+df3dy*df3dy);
143 Real H12 =
static_cast<Real
>(2)*(d2f1dxdy*f1 + df1dx*df1dy)+
static_cast<Real
>(2)*(d2f2dxdy*f2 + df2dx*df2dy)
144 +
static_cast<Real
>(2)*(d2f3dxdy*f3 + df3dx*df3dy);
146 (*ehv)[0] = (
static_cast<Real
>(1)/(H11*H22-H12*H12))*( H22*(*ev)[0] - H12*(*ev)[1]);
147 (*ehv)[1] = (
static_cast<Real
>(1)/(H11*H22-H12*H12))*(-H12*(*ev)[0] + H11*(*ev)[1]);
157 return makePtr<Objective_Beale<Real>>();
163 Ptr<std::vector<Real> > scale = makePtr<std::vector<Real>>(n,
static_cast<Real
>(0));
164 (*scale)[0] =
static_cast<Real
>(1.e-1);
165 (*scale)[1] =
static_cast<Real
>(1.e1);
168 Ptr<std::vector<Real> > x0p = makePtr<std::vector<Real>>(n,
static_cast<Real
>(0));
169 (*x0p)[0] =
static_cast<Real
>(1);
170 (*x0p)[1] =
static_cast<Real
>(1);
172 return makePtr<PrimalScaledStdVector<Real>>(x0p,scale);
178 Ptr<std::vector<Real> > scale = makePtr<std::vector<Real>>(n,
static_cast<Real
>(0));
179 (*scale)[0] =
static_cast<Real
>(1.e-1);
180 (*scale)[1] =
static_cast<Real
>(1.e1);
183 Ptr<std::vector<Real> > xp = makePtr<std::vector<Real>>(n,
static_cast<Real
>(0));
184 (*xp)[0] =
static_cast<Real
>(3);
185 (*xp)[1] =
static_cast<Real
>(0.5);
187 return makePtr<PrimalScaledStdVector<Real>>(xp,scale);
Provides the interface to evaluate objective functions.
Ptr< Vector< Real > > getInitialGuess(void) const
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
Ptr< Objective< Real > > getObjective(void) const
virtual void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply Hessian approximation to vector.
Defines the linear algebra or vector space interface.
Contains definitions of test objective functions.
Real value(const Vector< Real > &x, Real &tol)
Compute value.
Ptr< Vector< Real > > getSolution(const int i=0) const
void invHessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply inverse Hessian approximation to vector.