8#ifndef EXAMPLE_NUMERICS_PS_CMA_ES_F15_CEC_FUN_HPP_
9#define EXAMPLE_NUMERICS_PS_CMA_ES_F15_CEC_FUN_HPP_
11#include "f15_cec_const.hpp"
15template<
unsigned int dim>
16void Job15(
int funcnr,Eigen::VectorXd & vars,
double & res)
19 double sum,sum1,sum2,prod,e1,e2;
23 const double a_c = 0.5;
24 const double b_c = 3.0;
31 for (
size_t i = 0 ; i < dim ; i++)
33 sum += vars(i)*vars(i);
34 sum -= 10.0*cos(2*M_PI*vars[i]);
46 for (
size_t i = 0 ; i < dim ; i++)
50 for (
size_t j = 0 ; j <= Kmax ; j++, a_k *= a_c,b_k *= b_c)
52 sum1 = sum1 + a_k * cos((M_PI)*2.0 * b_k * (vars(i)+0.5));
57 for (
size_t j = 0 ; j <= Kmax ; j++, a_k *= a_c, b_k *= b_c)
59 sum2 = sum2 + a_k * cos((M_PI)*2.0 * b_k * (0.5));
61 res = sum1 - sum2*dim;
68 for (
size_t i = 1 ; i <= dim ; i++)
70 sum=
sum + (vars(i-1)*vars(i-1))/4000.0;
71 prod=prod * cos(vars(i-1)/(sqrt(
double(i))));
80 for (
size_t i = 0 ; i < dim ; i++)
82 e1 = e1 + vars(i)*vars(i);
83 e2 = e2 + cos(2.0*M_PI*vars(i));
85 res = exp(1.0) + 20.0 - 20*exp(-0.2*sqrt(e1/dim));
86 res = res - exp(e2/dim);
88 else if (funcnr <= 10)
91 sum = vars.transpose() * vars;
96template<
unsigned int dim>
97double hybrid_composition(Eigen::VectorXd & vars)
102 double wMax,sumSqr,wSum,w1mMaxPow;
105 Eigen::VectorXd job_z[10];
107 for (
size_t i = 0 ; i < 10 ; i++)
108 {job_z[i].resize(dim);}
113 for (
size_t i = 0 ; i < dim ; i++)
115 if (vars[i] < -5.0 || vars[i] > 5.0)
116 {
return std::numeric_limits<double>::infinity();}
120 wMax = - std::numeric_limits<double>::max();
121 for (
size_t i = 0; i < 10 ; i++)
125 job_z[i] = vars - f15_o[i];
126 sumSqr += (job_z[i].transpose() * job_z[i]);
128 job_w[i] = exp(-1.0 * sumSqr / (2.0 * dim));
137 w1mMaxPow = 1.0 - wMax*wMax*wMax*wMax*wMax*wMax*wMax*wMax*wMax*wMax;
138 for (
size_t i = 0; i < 10 ; i++)
140 if (job_w[i] != wMax)
141 {job_w[i] = job_w[i]* w1mMaxPow;};
143 wSum = wSum + job_w[i];
147 for (
size_t i = 0; i < 10 ; i++)
152 for (
size_t i = 0; i < 10 ; i++)
154 job_z[i] = job_z[i] / job_lambda[i];
158 Job15<dim>(i,job_z[i],t_res);
160 sumF = sumF + job_w[i] * (2000.0*t_res/f15_max[i] + bias[i]);
168template<
unsigned int dim>
172 for (
size_t j = 0 ; j < 10 ; j++)
174 Eigen::VectorXd fmp(dim);
175 f15_o[j].resize(dim);
176 for (
size_t i = 0 ; i < dim ; i++)
178 f15_o[j](i) = f15_const[j][i];
179 fmp(i) = 5.0 / job_lambda[j];
183 Job15<dim>(j,fmp,result);
185 f15_max[j] = fabs(result);
It model an expression expr1 + ... exprn.