13#ifndef OPTIMIST_COST_FUNCTION_SCHAFFER2_HH
14#define OPTIMIST_COST_FUNCTION_SCHAFFER2_HH
36 template <
typename Real>
52 for (Real x{-100}; x < 100 + EPSILON; x += 100/25.0) {
53 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)));
89 Real xx_0_m_xx_1{xx_0 - xx_1};
90 Real xx_0_p_xx_1{xx_0 + xx_1};
91 Real tmp{1.0 + 0.001*(xx_0_p_xx_1)};
92 Real tmp2{tmp*tmp}, tmp3{tmp2*tmp};
93 out(0) = 2.0*x(0)*std::sin(xx_0_m_xx_1) / tmp2 -
94 2.0*0.001*x(0)*std::cos(xx_0_m_xx_1) / tmp3;
95 out(1) = -2.0*x(1)*std::sin(xx_0_m_xx_1) / tmp2 +
96 2.0*0.001*x(1)*std::cos(xx_0_m_xx_1) / tmp3;
106 Real xx_0{x(0)*x(0)};
107 Real xx_1{x(1)*x(1)};
108 Real xx_0_m_xx_1{xx_0 - xx_1};
109 Real xx_0_p_xx_1{xx_0 + xx_1};
110 Real tmp{1.0 + 0.001*(xx_0_p_xx_1)};
111 Real tmp2{tmp*tmp}, tmp3{tmp2*tmp}, tmp4{tmp2*tmp2};
112 out(0, 0) = 2.0*std::sin(xx_0_m_xx_1) / tmp2 -
113 4.0*x(0)*x(0)*std::sin(xx_0_m_xx_1) / tmp3 +
114 6.0*0.001*x(0)*x(0)*std::cos(xx_0_m_xx_1) / tmp4;
115 out(0, 1) = -2.0*x(0)*x(1)*std::sin(xx_0_m_xx_1) / tmp3 +
116 6.0*0.001*x(0)*x(1)*std::cos(xx_0_m_xx_1) / tmp4;
117 out(1, 0) = out(0, 1);
118 out(1, 1) = 2.0*std::sin(xx_0_m_xx_1) / tmp2 -
119 4.0*x(1)*x(1)*std::sin(xx_0_m_xx_1) / tmp3 +
120 6.0*0.001*x(1)*x(1)*std::cos(xx_0_m_xx_1) / tmp4;
#define OPTIMIST_BASIC_CONSTANTS(Real)
Definition Optimist.hh:70
CostFunction()
Definition CostFunction.hh:51
std::vector< InputType > m_solutions
Definition Function.hh:52
std::vector< InputType > m_guesses
Definition Function.hh:53
void first_derivative_impl(const Vector &x, RowVector &out) const
Definition Schaffer2.hh:85
typename CostFunction< Real, 2, Schaffer2< Real > >::Matrix Matrix
Definition Schaffer2.hh:42
void evaluate_impl(const Vector &x, Real &out) const
Definition Schaffer2.hh:70
void second_derivative_impl(const Vector &x, Matrix &out) const
Definition Schaffer2.hh:104
typename CostFunction< Real, 2, Schaffer2< Real > >::Vector Vector
Definition Schaffer2.hh:40
std::string name_impl() const
Definition Schaffer2.hh:63
typename CostFunction< Real, 2, Schaffer2< Real > >::RowVector RowVector
Definition Schaffer2.hh:41
Schaffer2()
Definition Schaffer2.hh:49
Namespace for the Optimist library.
Definition Optimist.hh:87