13#ifndef OPTIMIST_TESTSET_SCHAFFER2_HH
14#define OPTIMIST_TESTSET_SCHAFFER2_HH
35 template <
typename Real>
51 for (Real x{-100}; x < 100 + EPSILON; x += 100/25.0) {
52 for (Real y{-100}; y < 100 + EPSILON; y += 100/25.0) {
74 Real xx_0_m_xx_1{xx_0 - xx_1};
75 Real xx_0_p_xx_1{xx_0 + xx_1};
76 out = 0.5 + (std::sin(xx_0_m_xx_1)*std::sin(xx_0_m_xx_1) - 0.5) /
77 ((1.0 + 0.001*(xx_0_p_xx_1))*(1.0 + 0.001*(xx_0_p_xx_1)));
78 return std::isfinite(out);
91 Real xx_0_m_xx_1{xx_0 - xx_1};
92 Real xx_0_p_xx_1{xx_0 + xx_1};
93 Real tmp{1.0 + 0.001*(xx_0_p_xx_1)};
94 Real tmp2{tmp*tmp}, tmp3{tmp2*tmp};
95 out(0) = 2.0*x(0)*std::sin(xx_0_m_xx_1) / tmp2 -
96 2.0*0.001*x(0)*std::cos(xx_0_m_xx_1) / tmp3;
97 out(1) = -2.0*x(1)*std::sin(xx_0_m_xx_1) / tmp2 +
98 2.0*0.001*x(1)*std::cos(xx_0_m_xx_1) / tmp3;
99 return out.allFinite();
110 Real xx_0{x(0)*x(0)};
111 Real xx_1{x(1)*x(1)};
112 Real xx_0_m_xx_1{xx_0 - xx_1};
113 Real xx_0_p_xx_1{xx_0 + xx_1};
114 Real tmp{1.0 + 0.001*(xx_0_p_xx_1)};
115 Real tmp2{tmp*tmp}, tmp3{tmp2*tmp}, tmp4{tmp2*tmp2};
116 out(0, 0) = 2.0*std::sin(xx_0_m_xx_1) / tmp2 -
117 4.0*x(0)*x(0)*std::sin(xx_0_m_xx_1) / tmp3 +
118 6.0*0.001*x(0)*x(0)*std::cos(xx_0_m_xx_1) / tmp4;
119 out(0, 1) = -2.0*x(0)*x(1)*std::sin(xx_0_m_xx_1) / tmp3 +
120 6.0*0.001*x(0)*x(1)*std::cos(xx_0_m_xx_1) / tmp4;
121 out(1, 0) = out(0, 1);
122 out(1, 1) = 2.0*std::sin(xx_0_m_xx_1) / tmp2 -
123 4.0*x(1)*x(1)*std::sin(xx_0_m_xx_1) / tmp3 +
124 6.0*0.001*x(1)*x(1)*std::cos(xx_0_m_xx_1) / tmp4;
125 return out.allFinite();
#define OPTIMIST_BASIC_CONSTANTS(Real)
Definition Optimist.hh:71
std::vector< InputType > m_guesses
Definition Function.hh:66
std::vector< InputType > m_solutions
Definition Function.hh:65
Function()
Definition Function.hh:209
typename FunctionBase< Real, N, M, Schaffer2< Real >, false >::FirstDerivativeType Matrix
Definition Function.hh:203
bool first_derivative_impl(Vector const &x, RowVector &out) const
Definition Schaffer2.hh:87
bool second_derivative_impl(Vector const &x, Matrix &out) const
Definition Schaffer2.hh:108
std::string name_impl() const
Definition Schaffer2.hh:62
bool evaluate_impl(Vector const &x, Real &out) const
Definition Schaffer2.hh:70
Schaffer2()
Definition Schaffer2.hh:48
Namespace for the Optimist library.
Definition Optimist.hh:88