72 y_.push_back(static_cast<Real>(1.5));
73 y_.push_back(static_cast<Real>(2.25));
74 y_.push_back(static_cast<Real>(2.625));
78 Ptr<const std::vector<Real> > ex
81 Real f1 =
static_cast<Real
>(1.5)-(*ex)[0]*(
static_cast<Real
>(1)-(*ex)[1]);
82 Real f2 =
static_cast<Real
>(2.25)-(*ex)[0]*(
static_cast<Real
>(1)-pow((*ex)[1],2));
83 Real f3 =
static_cast<Real
>(2.625)-(*ex)[0]*(
static_cast<Real
>(1)-pow((*ex)[1],3));
85 return pow(f1,2)+pow(f2,2)+pow(f3,2);
89 Ptr<std::vector<Real> > eg
91 Ptr<const std::vector<Real> > ex
94 Real f1 =
static_cast<Real
>(1.5)-(*ex)[0]*(
static_cast<Real
>(1)-(*ex)[1]);
95 Real f2 =
static_cast<Real
>(2.25)-(*ex)[0]*(
static_cast<Real
>(1)-pow((*ex)[1],2));
96 Real f3 =
static_cast<Real
>(2.625)-(*ex)[0]*(
static_cast<Real
>(1)-pow((*ex)[1],3));
97 Real df1dx = -(
static_cast<Real
>(1)-(*ex)[1]);
98 Real df1dy = (*ex)[0];
99 Real df2dx = -(
static_cast<Real
>(1)-pow((*ex)[1],2));
100 Real df2dy =
static_cast<Real
>(2)*(*ex)[0]*(*ex)[1];
101 Real df3dx = -(
static_cast<Real
>(1)-pow((*ex)[1],3));
102 Real df3dy =
static_cast<Real
>(3)*(*ex)[0]*pow((*ex)[1],2);
104 (*eg)[0] =
static_cast<Real
>(2)*df1dx*f1+static_cast<Real>(2)*df2dx*f2+
static_cast<Real
>(2)*df3dx*f3;
105 (*eg)[1] =
static_cast<Real
>(2)*df1dy*f1+static_cast<Real>(2)*df2dy*f2+
static_cast<Real
>(2)*df3dy*f3;
109 Ptr<std::vector<Real> > ehv
111 Ptr<const std::vector<Real> > ev
113 Ptr<const std::vector<Real> > ex
116 Real f1 =
static_cast<Real
>(1.5)-(*ex)[0]*(
static_cast<Real
>(1)-(*ex)[1]);
117 Real f2 =
static_cast<Real
>(2.25)-(*ex)[0]*(
static_cast<Real
>(1)-pow((*ex)[1],2));
118 Real f3 =
static_cast<Real
>(2.625)-(*ex)[0]*(
static_cast<Real
>(1)-pow((*ex)[1],3));
119 Real df1dx = -(
static_cast<Real
>(1)-(*ex)[1]);
120 Real df1dy = (*ex)[0];
121 Real df2dx = -(
static_cast<Real
>(1)-pow((*ex)[1],2));
122 Real df2dy =
static_cast<Real
>(2)*(*ex)[0]*(*ex)[1];
123 Real df3dx = -(
static_cast<Real
>(1)-pow((*ex)[1],3));
124 Real df3dy =
static_cast<Real
>(3)*(*ex)[0]*pow((*ex)[1],2);
125 Real d2f1dx2 =
static_cast<Real
>(0);
126 Real d2f1dy2 =
static_cast<Real
>(0);
127 Real d2f1dxdy =
static_cast<Real
>(1);
128 Real d2f2dx2 =
static_cast<Real
>(0);
129 Real d2f2dy2 =
static_cast<Real
>(2)*(*ex)[0];
130 Real d2f2dxdy =
static_cast<Real
>(2)*(*ex)[1];
131 Real d2f3dx2 =
static_cast<Real
>(0);
132 Real d2f3dy2 =
static_cast<Real
>(6)*(*ex)[0]*(*ex)[1];
133 Real d2f3dxdy =
static_cast<Real
>(3)*pow((*ex)[1],2);
135 Real H11 =
static_cast<Real
>(2)*(d2f1dx2*f1+df1dx*df1dx)+
static_cast<Real
>(2)*(d2f2dx2*f2+df2dx*df2dx)
136 +
static_cast<Real
>(2)*(d2f3dx2*f3+df3dx*df3dx);
137 Real H22 =
static_cast<Real
>(2)*(d2f1dy2*f1+df1dy*df1dy)+
static_cast<Real
>(2)*(d2f2dy2*f2+df2dy*df2dy)
138 +
static_cast<Real
>(2)*(d2f3dy2*f3+df3dy*df3dy);
139 Real H12 =
static_cast<Real
>(2)*(d2f1dxdy*f1 + df1dx*df1dy)+
static_cast<Real
>(2)*(d2f2dxdy*f2 + df2dx*df2dy)
140 +
static_cast<Real
>(2)*(d2f3dxdy*f3 + df3dx*df3dy);
142 (*ehv)[0] = H11*(*ev)[0]+H12*(*ev)[1];
143 (*ehv)[1] = H12*(*ev)[0]+H22*(*ev)[1];
147 Ptr<std::vector<Real> > ehv
149 Ptr<const std::vector<Real> > ev
151 Ptr<const std::vector<Real> > ex
154 Real f1 =
static_cast<Real
>(1.5)-(*ex)[0]*(
static_cast<Real
>(1)-(*ex)[1]);
155 Real f2 =
static_cast<Real
>(2.25)-(*ex)[0]*(
static_cast<Real
>(1)-pow((*ex)[1],2));
156 Real f3 =
static_cast<Real
>(2.625)-(*ex)[0]*(
static_cast<Real
>(1)-pow((*ex)[1],3));
157 Real df1dx = -(
static_cast<Real
>(1)-(*ex)[1]);
158 Real df1dy = (*ex)[0];
159 Real df2dx = -(
static_cast<Real
>(1)-pow((*ex)[1],2));
160 Real df2dy =
static_cast<Real
>(2)*(*ex)[0]*(*ex)[1];
161 Real df3dx = -(
static_cast<Real
>(1)-pow((*ex)[1],3));
162 Real df3dy =
static_cast<Real
>(3)*(*ex)[0]*pow((*ex)[1],2);
163 Real d2f1dx2 =
static_cast<Real
>(0);
164 Real d2f1dy2 =
static_cast<Real
>(0);
165 Real d2f1dxdy =
static_cast<Real
>(1);
166 Real d2f2dx2 =
static_cast<Real
>(0);
167 Real d2f2dy2 =
static_cast<Real
>(2)*(*ex)[0];
168 Real d2f2dxdy =
static_cast<Real
>(2)*(*ex)[1];
169 Real d2f3dx2 =
static_cast<Real
>(0);
170 Real d2f3dy2 =
static_cast<Real
>(6)*(*ex)[0]*(*ex)[1];
171 Real d2f3dxdy =
static_cast<Real
>(3)*pow((*ex)[1],2);
173 Real H11 =
static_cast<Real
>(2)*(d2f1dx2*f1+df1dx*df1dx)+
static_cast<Real
>(2)*(d2f2dx2*f2+df2dx*df2dx)
174 +
static_cast<Real
>(2)*(d2f3dx2*f3+df3dx*df3dx);
175 Real H22 =
static_cast<Real
>(2)*(d2f1dy2*f1+df1dy*df1dy)+
static_cast<Real
>(2)*(d2f2dy2*f2+df2dy*df2dy)
176 +
static_cast<Real
>(2)*(d2f3dy2*f3+df3dy*df3dy);
177 Real H12 =
static_cast<Real
>(2)*(d2f1dxdy*f1 + df1dx*df1dy)+
static_cast<Real
>(2)*(d2f2dxdy*f2 + df2dx*df2dy)
178 +
static_cast<Real
>(2)*(d2f3dxdy*f3 + df3dx*df3dy);
180 (*ehv)[0] = (
static_cast<Real
>(1)/(H11*H22-H12*H12))*( H22*(*ev)[0] - H12*(*ev)[1]);
181 (*ehv)[1] = (
static_cast<Real
>(1)/(H11*H22-H12*H12))*(-H12*(*ev)[0] + H11*(*ev)[1]);
191 return makePtr<Objective_Beale<Real>>();
197 Ptr<std::vector<Real> > scale = makePtr<std::vector<Real>>(n,
static_cast<Real
>(0));
198 (*scale)[0] =
static_cast<Real
>(1.e-1);
199 (*scale)[1] =
static_cast<Real
>(1.e1);
202 Ptr<std::vector<Real> > x0p = makePtr<std::vector<Real>>(n,
static_cast<Real
>(0));
203 (*x0p)[0] =
static_cast<Real
>(1);
204 (*x0p)[1] =
static_cast<Real
>(1);
206 return makePtr<PrimalScaledStdVector<Real>>(x0p,scale);
212 Ptr<std::vector<Real> > scale = makePtr<std::vector<Real>>(n,
static_cast<Real
>(0));
213 (*scale)[0] =
static_cast<Real
>(1.e-1);
214 (*scale)[1] =
static_cast<Real
>(1.e1);
217 Ptr<std::vector<Real> > xp = makePtr<std::vector<Real>>(n,
static_cast<Real
>(0));
218 (*xp)[0] =
static_cast<Real
>(3);
219 (*xp)[1] =
static_cast<Real
>(0.5);
221 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.