25 #include <boost/math/constants/constants.hpp>
26 #include <boost/lexical_cast.hpp>
35 #include "../exceptions.h"
41 #define E 2.7182818284590452353602874713526625
43 namespace pagmo {
namespace problem {
60 if (!(d==2||d==5||d==10||d==20||d==30||d==40||d==50||d==60||d==70||d==80||d==90||d==100))
62 pagmo_throw(value_error,
"Error: CEC2013 Test functions are only defined for dimensions 2,5,10,20,30,40,50,60,70,80,90,100.");
66 std::string data_file_name(dir);
67 data_file_name.append(
"M_D");
68 data_file_name.append(boost::lexical_cast<std::string>(d));
69 data_file_name.append(
".txt");
72 std::ifstream data_file(data_file_name.c_str());
73 if (!data_file.is_open()) {
74 pagmo_throw(io_error, std::string(
"Error: file not found. I was looking for (") + data_file_name.c_str() +
")");
76 std::istream_iterator<double> start(data_file), end;
77 m_rotation_matrix = std::vector<double>(start,end);
83 data_file_name.append(
"shift_data.txt");
86 std::ifstream data_file(data_file_name.c_str());
87 if (!data_file.is_open()) {
88 pagmo_throw(io_error, std::string(
"Error: file not found. I was looking for ").append(data_file_name.c_str()));
90 std::istream_iterator<double> start(data_file), end;
91 m_origin_shift = std::vector<double>(start,end);
108 switch(m_problem_number)
111 sphere_func(&x[0],&f[0],nx,&m_origin_shift[0],&m_rotation_matrix[0],0);
115 ellips_func(&x[0],&f[0],nx,&m_origin_shift[0],&m_rotation_matrix[0],1);
119 bent_cigar_func(&x[0],&f[0],nx,&m_origin_shift[0],&m_rotation_matrix[0],1);
123 discus_func(&x[0],&f[0],nx,&m_origin_shift[0],&m_rotation_matrix[0],1);
127 dif_powers_func(&x[0],&f[0],nx,&m_origin_shift[0],&m_rotation_matrix[0],0);
131 rosenbrock_func(&x[0],&f[0],nx,&m_origin_shift[0],&m_rotation_matrix[0],1);
135 schaffer_F7_func(&x[0],&f[0],nx,&m_origin_shift[0],&m_rotation_matrix[0],1);
139 ackley_func(&x[0],&f[0],nx,&m_origin_shift[0],&m_rotation_matrix[0],1);
143 weierstrass_func(&x[0],&f[0],nx,&m_origin_shift[0],&m_rotation_matrix[0],1);
147 griewank_func(&x[0],&f[0],nx,&m_origin_shift[0],&m_rotation_matrix[0],1);
151 rastrigin_func(&x[0],&f[0],nx,&m_origin_shift[0],&m_rotation_matrix[0],0);
155 rastrigin_func(&x[0],&f[0],nx,&m_origin_shift[0],&m_rotation_matrix[0],1);
159 step_rastrigin_func(&x[0],&f[0],nx,&m_origin_shift[0],&m_rotation_matrix[0],1);
163 schwefel_func(&x[0],&f[0],nx,&m_origin_shift[0],&m_rotation_matrix[0],0);
167 schwefel_func(&x[0],&f[0],nx,&m_origin_shift[0],&m_rotation_matrix[0],1);
171 katsuura_func(&x[0],&f[0],nx,&m_origin_shift[0],&m_rotation_matrix[0],1);
175 bi_rastrigin_func(&x[0],&f[0],nx,&m_origin_shift[0],&m_rotation_matrix[0],0);
179 bi_rastrigin_func(&x[0],&f[0],nx,&m_origin_shift[0],&m_rotation_matrix[0],1);
183 grie_rosen_func(&x[0],&f[0],nx,&m_origin_shift[0],&m_rotation_matrix[0],1);
187 escaffer6_func(&x[0],&f[0],nx,&m_origin_shift[0],&m_rotation_matrix[0],1);
191 cf01(&x[0],&f[0],nx,&m_origin_shift[0],&m_rotation_matrix[0],1);
195 cf02(&x[0],&f[0],nx,&m_origin_shift[0],&m_rotation_matrix[0],0);
199 cf03(&x[0],&f[0],nx,&m_origin_shift[0],&m_rotation_matrix[0],1);
203 cf04(&x[0],&f[0],nx,&m_origin_shift[0],&m_rotation_matrix[0],1);
207 cf05(&x[0],&f[0],nx,&m_origin_shift[0],&m_rotation_matrix[0],1);
211 cf06(&x[0],&f[0],nx,&m_origin_shift[0],&m_rotation_matrix[0],1);
215 cf07(&x[0],&f[0],nx,&m_origin_shift[0],&m_rotation_matrix[0],1);
219 cf08(&x[0],&f[0],nx,&m_origin_shift[0],&m_rotation_matrix[0],1);
223 pagmo_throw(value_error,
"Error: There are only 28 test functions in this test suite!");
231 std::string retval(
"CEC2013 - f");
232 retval.append(boost::lexical_cast<std::string>(m_problem_number));
233 switch(m_problem_number)
236 retval.append(
"(sphere_func)");
239 retval.append(
"(ellips_func)");
242 retval.append(
"(bent_cigar_func)");
245 retval.append(
"(discus_func)");
248 retval.append(
"(dif_powers_func_non_rotated)");
251 retval.append(
"(rosenbrock_func)");
254 retval.append(
"(schaffer_F7_func)");
257 retval.append(
"(ackley_func)");
260 retval.append(
"(weierstrass_func)");
263 retval.append(
"(griewank_func)");
266 retval.append(
"(rastrigin_func_non_rotated)");
269 retval.append(
"(rastrigin_func)");
272 retval.append(
"(step_rastrigin_func)");
275 retval.append(
"(schwefel_func_non_rotated)");
278 retval.append(
"(schwefel_func)");
281 retval.append(
"(katsuura_func)");
284 retval.append(
"(bi_rastrigin_func_non_rotated)");
287 retval.append(
"(bi_rastrigin_func)");
290 retval.append(
"(grie_rosen_func)");
293 retval.append(
"(escaffer6_func)");
296 retval.append(
"(cf01)");
299 retval.append(
"(cf02)");
302 retval.append(
"(cf03)");
305 retval.append(
"(cf04)");
308 retval.append(
"(cf05)");
311 retval.append(
"(cf06)");
314 retval.append(
"(cf07)");
317 retval.append(
"(cf08)");
320 pagmo_throw(value_error,
"Error: There are only 28 test functions in this test suite!");
327 void cec2013::sphere_func (
const double *x,
double *f,
int nx,
const double *Os,
const double *Mr,
int r_flag)
const
329 shiftfunc(x, &m_y[0], nx, Os);
331 rotatefunc(&m_y[0], &m_z[0], nx, Mr);
333 for (
int i=0; i<nx; i++)
336 for (
int i=0; i<nx; i++)
338 f[0] += m_z[i]*m_z[i];
342 void cec2013::ellips_func (
const double *x,
double *f,
int nx,
const double *Os,
const double *Mr,
int r_flag)
const
345 shiftfunc(x, &m_y[0], nx, Os);
347 rotatefunc(&m_y[0], &m_z[0], nx, Mr);
351 oszfunc (&m_z[0], &m_y[0], nx);
355 f[0] += pow(10.0,6.0*i/(nx-1))*m_y[i]*m_y[i];
359 void cec2013::bent_cigar_func (
const double *x,
double *f,
int nx,
const double *Os,
const double *Mr,
int r_flag)
const
363 shiftfunc(x, &m_y[0], nx, Os);
365 rotatefunc(&m_y[0], &m_z[0], nx, Mr);
369 asyfunc (&m_z[0], &m_y[0], nx,beta);
371 rotatefunc(&m_y[0], &m_z[0], nx, &Mr[nx*nx]);
376 f[0] = m_z[0]*m_z[0];
379 f[0] += pow(10.0,6.0)*m_z[i]*m_z[i];
383 void cec2013::discus_func (
const double *x,
double *f,
int nx,
const double *Os,
const double *Mr,
int r_flag)
const
386 shiftfunc(x, &m_y[0], nx, Os);
388 rotatefunc(&m_y[0], &m_z[0], nx, Mr);
392 oszfunc (&m_z[0], &m_y[0], nx);
394 f[0] = pow(10.0,6.0)*m_y[0]*m_y[0];
397 f[0] += m_y[i]*m_y[i];
401 void cec2013::dif_powers_func (
const double *x,
double *f,
int nx,
const double *Os,
const double *Mr,
int r_flag)
const
404 shiftfunc(x, &m_y[0], nx, Os);
406 rotatefunc(&m_y[0], &m_z[0], nx, Mr);
413 f[0] += pow(fabs(m_z[i]),2+4*i/(nx-1));
418 void cec2013::rosenbrock_func (
const double *x,
double *f,
int nx,
const double *Os,
const double *Mr,
int r_flag)
const
422 shiftfunc(x, &m_y[0], nx, Os);
425 m_y[i]=m_y[i]*2.048/100;
428 rotatefunc(&m_y[0], &m_z[0], nx, Mr);
438 for (i=0; i<nx-1; i++)
440 tmp1=m_z[i]*m_z[i]-m_z[i+1];
442 f[0] += 100.0*tmp1*tmp1 +tmp2*tmp2;
446 void cec2013::schaffer_F7_func (
const double *x,
double *f,
int nx,
const double *Os,
const double *Mr,
int r_flag)
const
450 shiftfunc(x, &m_y[0], nx, Os);
452 rotatefunc(&m_y[0], &m_z[0], nx, Mr);
456 asyfunc (&m_z[0], &m_y[0], nx, 0.5);
458 m_z[i] = m_y[i]*pow(10.0,1.0*i/(nx-1)/2.0);
460 rotatefunc(&m_z[0], &m_y[0], nx, &Mr[nx*nx]);
465 for (i=0; i<nx-1; i++)
466 m_z[i]=pow(m_y[i]*m_y[i]+m_y[i+1]*m_y[i+1],0.5);
468 for (i=0; i<nx-1; i++)
470 tmp=sin(50.0*pow(m_z[i],0.2));
471 f[0] += pow(m_z[i],0.5)+pow(m_z[i],0.5)*tmp*tmp ;
473 f[0] = f[0]*f[0]/(nx-1)/(nx-1);
476 void cec2013::ackley_func (
const double *x,
double *f,
int nx,
const double *Os,
const double *Mr,
int r_flag)
const
481 shiftfunc(x, &m_y[0], nx, Os);
483 rotatefunc(&m_y[0], &m_z[0], nx, Mr);
488 asyfunc (&m_z[0], &m_y[0], nx, 0.5);
490 m_z[i] = m_y[i]*pow(10.0,1.0*i/(nx-1)/2.0);
492 rotatefunc(&m_z[0], &m_y[0], nx, &Mr[nx*nx]);
501 sum1 += m_y[i]*m_y[i];
502 sum2 += cos(2.0*boost::math::constants::pi<double>()*m_y[i]);
504 sum1 = -0.2*sqrt(sum1/nx);
506 f[0] = E - 20.0*exp(sum1) - exp(sum2) +20.0;
509 void cec2013::weierstrass_func (
const double *x,
double *f,
int nx,
const double *Os,
const double *Mr,
int r_flag)
const
512 double sum=0,sum2=0, a, b;
514 shiftfunc(x, &m_y[0], nx, Os);
517 m_y[i]=m_y[i]*0.5/100;
520 rotatefunc(&m_y[0], &m_z[0], nx, Mr);
525 asyfunc (&m_z[0], &m_y[0], nx, 0.5);
527 m_z[i] = m_y[i]*pow(10.0,1.0*i/(nx-1)/2.0);
529 rotatefunc(&m_z[0], &m_y[0], nx, &Mr[nx*nx]);
542 for (j=0; j<=k_max; j++)
544 sum += pow(a,j)*cos(2.0*boost::math::constants::pi<double>()*pow(b,j)*(m_y[i]+0.5));
545 sum2 += pow(a,j)*cos(2.0*boost::math::constants::pi<double>()*pow(b,j)*0.5);
552 void cec2013::griewank_func (
const double *x,
double *f,
int nx,
const double *Os,
const double *Mr,
int r_flag)
const
557 shiftfunc(x, &m_y[0], nx, Os);
560 m_y[i]=m_y[i]*600.0/100.0;
563 rotatefunc(&m_y[0], &m_z[0], nx, Mr);
569 m_z[i] = m_z[i]*pow(100.0,1.0*i/(nx-1)/2.0);
577 p *= cos(m_z[i]/sqrt(1.0+i));
579 f[0] = 1.0 + s/4000.0 - p;
582 void cec2013::rastrigin_func (
const double *x,
double *f,
int nx,
const double *Os,
const double *Mr,
int r_flag)
const
585 double alpha=10.0,beta=0.2;
586 shiftfunc(x, &m_y[0], nx, Os);
589 m_y[i]=m_y[i]*5.12/100;
593 rotatefunc(&m_y[0], &m_z[0], nx, Mr);
598 oszfunc (&m_z[0], &m_y[0], nx);
599 asyfunc (&m_y[0], &m_z[0], nx, beta);
602 rotatefunc(&m_z[0], &m_y[0], nx, &Mr[nx*nx]);
609 m_y[i]*=pow(alpha,1.0*i/(nx-1)/2);
613 rotatefunc(&m_y[0], &m_z[0], nx, Mr);
621 f[0] += (m_z[i]*m_z[i] - 10.0*cos(2.0*boost::math::constants::pi<double>()*m_z[i]) + 10.0);
625 void cec2013::step_rastrigin_func (
const double *x,
double *f,
int nx,
const double *Os,
const double *Mr,
int r_flag)
const
628 double alpha=10.0,beta=0.2;
629 shiftfunc(x, &m_y[0], nx, Os);
632 m_y[i]=m_y[i]*5.12/100;
636 rotatefunc(&m_y[0], &m_z[0], nx, Mr);
643 if (fabs(m_z[i])>0.5)
644 m_z[i]=floor(2*m_z[i]+0.5)/2;
647 oszfunc (&m_z[0], &m_y[0], nx);
648 asyfunc (&m_y[0], &m_z[0], nx, beta);
651 rotatefunc(&m_z[0], &m_y[0], nx, &Mr[nx*nx]);
658 m_y[i]*=pow(alpha,1.0*i/(nx-1)/2);
662 rotatefunc(&m_y[0], &m_z[0], nx, Mr);
670 f[0] += (m_z[i]*m_z[i] - 10.0*cos(2.0*boost::math::constants::pi<double>()*m_z[i]) + 10.0);
674 void cec2013::schwefel_func (
const double *x,
double *f,
int nx,
const double *Os,
const double *Mr,
int r_flag)
const
678 shiftfunc(x, &m_y[0], nx, Os);
684 rotatefunc(&m_y[0], &m_z[0], nx, Mr);
690 m_y[i] = m_z[i]*pow(10.0,1.0*i/(nx-1)/2.0);
693 m_z[i] = m_y[i]+4.209687462275036e+002;
700 f[0]-=(500.0-fmod(m_z[i],500))*sin(pow(500.0-fmod(m_z[i],500),0.5));
701 tmp=(m_z[i]-500.0)/100;
704 else if (m_z[i]<-500)
706 f[0]-=(-500.0+fmod(fabs(m_z[i]),500))*sin(pow(500.0-fmod(fabs(m_z[i]),500),0.5));
707 tmp=(m_z[i]+500.0)/100;
711 f[0]-=m_z[i]*sin(pow(fabs(m_z[i]),0.5));
713 f[0]=4.189828872724338e+002*nx+f[0];
716 void cec2013::katsuura_func (
const double *x,
double *f,
int nx,
const double *Os,
const double *Mr,
int r_flag)
const
719 double temp,tmp1,tmp2,tmp3;
720 tmp3=pow(1.0*nx,1.2);
721 shiftfunc(x, &m_y[0], nx, Os);
727 rotatefunc(&m_y[0], &m_z[0], nx, Mr);
733 m_z[i] *=pow(100.0,1.0*i/(nx-1)/2.0);
736 rotatefunc(&m_z[0], &m_y[0], nx, &Mr[nx*nx]);
745 for (j=1; j<=32; j++)
749 temp += fabs(tmp2-floor(tmp2+0.5))/tmp1;
751 f[0] *= pow(1.0+(i+1)*temp,10.0/tmp3);
758 void cec2013::bi_rastrigin_func (
const double *x,
double *f,
int nx,
const double *Os,
const double *Mr,
int r_flag)
const
761 double mu0=2.5,d=1.0,s,mu1,tmp,tmp1,tmp2;
763 tmpx=(
double *)malloc(
sizeof(
double) * nx);
764 s=1.0-1.0/(2.0*pow(nx+20.0,0.5)-8.2);
765 mu1=-pow((mu0*mu0-d)/s,0.5);
767 shiftfunc(x, &m_y[0], nx, Os);
773 for (i = 0; i < nx; i++)
786 rotatefunc(&m_z[0], &m_y[0], nx, Mr);
792 m_y[i] *=pow(100.0,1.0*i/(nx-1)/2.0);
794 rotatefunc(&m_y[0], &m_z[0], nx, &Mr[nx*nx]);
812 tmp+=cos(2.0*boost::math::constants::pi<double>()*m_z[i]);
819 f[0] += 10.0*(nx-tmp);
823 void cec2013::grie_rosen_func (
const double *x,
double *f,
int nx,
const double *Os,
const double *Mr,
int r_flag)
const
826 double temp,tmp1,tmp2;
828 shiftfunc(x, &m_y[0], nx, Os);
834 rotatefunc(&m_y[0], &m_z[0], nx, Mr);
845 for (i=0; i<nx-1; i++)
847 tmp1 = m_z[i]*m_z[i]-m_z[i+1];
849 temp = 100.0*tmp1*tmp1 + tmp2*tmp2;
850 f[0] += (temp*temp)/4000.0 - cos(temp) + 1.0;
852 tmp1 = m_z[nx-1]*m_z[nx-1]-m_z[0];
853 tmp2 = m_z[nx-1]-1.0;
854 temp = 100.0*tmp1*tmp1 + tmp2*tmp2;;
855 f[0] += (temp*temp)/4000.0 - cos(temp) + 1.0 ;
858 void cec2013::escaffer6_func (
const double *x,
double *f,
int nx,
const double *Os,
const double *Mr,
int r_flag)
const
862 shiftfunc(x, &m_y[0], nx, Os);
864 rotatefunc(&m_y[0], &m_z[0], nx, Mr);
869 asyfunc (&m_z[0], &m_y[0], nx, 0.5);
871 rotatefunc(&m_y[0], &m_z[0], nx, &Mr[nx*nx]);
877 for (i=0; i<nx-1; i++)
879 temp1 = sin(sqrt(m_z[i]*m_z[i]+m_z[i+1]*m_z[i+1]));
881 temp2 = 1.0 + 0.001*(m_z[i]*m_z[i]+m_z[i+1]*m_z[i+1]);
882 f[0] += 0.5 + (temp1-0.5)/(temp2*temp2);
884 temp1 = sin(sqrt(m_z[nx-1]*m_z[nx-1]+m_z[0]*m_z[0]));
886 temp2 = 1.0 + 0.001*(m_z[nx-1]*m_z[nx-1]+m_z[0]*m_z[0]);
887 f[0] += 0.5 + (temp1-0.5)/(temp2*temp2);
890 void cec2013::cf01 (
const double *x,
double *f,
int nx,
const double *Os,
const double *Mr,
int r_flag)
const
894 double delta[5] = {10, 20, 30, 40, 50};
895 double bias[5] = {0, 100, 200, 300, 400};
898 rosenbrock_func(x,&fit[i],nx,&Os[i*nx],&Mr[i*nx*nx],r_flag);
899 fit[i]=10000*fit[i]/1e+4;
901 dif_powers_func(x,&fit[i],nx,&Os[i*nx],&Mr[i*nx*nx],r_flag);
902 fit[i]=10000*fit[i]/1e+10;
904 bent_cigar_func(x,&fit[i],nx,&Os[i*nx],&Mr[i*nx*nx],r_flag);
905 fit[i]=10000*fit[i]/1e+30;
907 discus_func(x,&fit[i],nx,&Os[i*nx],&Mr[i*nx*nx],r_flag);
908 fit[i]=10000*fit[i]/1e+10;
910 sphere_func(x,&fit[i],nx,&Os[i*nx],&Mr[i*nx*nx],0);
911 fit[i]=10000*fit[i]/1e+5;
912 cf_cal(x, f, nx, Os, delta,bias,fit,cf_num);
915 void cec2013::cf02 (
const double *x,
double *f,
int nx,
const double *Os,
const double *Mr,
int r_flag)
const
919 double delta[3] = {20,20,20};
920 double bias[3] = {0, 100, 200};
921 for(i=0;i<cf_num;i++)
923 schwefel_func(x,&fit[i],nx,&Os[i*nx],&Mr[i*nx*nx],r_flag);
925 cf_cal(x, f, nx, Os, delta,bias,fit,cf_num);
928 void cec2013::cf03 (
const double *x,
double *f,
int nx,
const double *Os,
const double *Mr,
int r_flag)
const
932 double delta[3] = {20,20,20};
933 double bias[3] = {0, 100, 200};
934 for(i=0;i<cf_num;i++)
936 schwefel_func(x,&fit[i],nx,&Os[i*nx],&Mr[i*nx*nx],r_flag);
938 cf_cal(x, f, nx, Os, delta,bias,fit,cf_num);
941 void cec2013::cf04 (
const double *x,
double *f,
int nx,
const double *Os,
const double *Mr,
int r_flag)
const
945 double delta[3] = {20,20,20};
946 double bias[3] = {0, 100, 200};
948 schwefel_func(x,&fit[i],nx,&Os[i*nx],&Mr[i*nx*nx],r_flag);
949 fit[i]=1000*fit[i]/4e+3;
951 rastrigin_func(x,&fit[i],nx,&Os[i*nx],&Mr[i*nx*nx],r_flag);
952 fit[i]=1000*fit[i]/1e+3;
954 weierstrass_func(x,&fit[i],nx,&Os[i*nx],&Mr[i*nx*nx],r_flag);
955 fit[i]=1000*fit[i]/400;
956 cf_cal(x, f, nx, Os, delta,bias,fit,cf_num);
959 void cec2013::cf05 (
const double *x,
double *f,
int nx,
const double *Os,
const double *Mr,
int r_flag)
const
963 double delta[3] = {10,30,50};
964 double bias[3] = {0, 100, 200};
966 schwefel_func(x,&fit[i],nx,&Os[i*nx],&Mr[i*nx*nx],r_flag);
967 fit[i]=1000*fit[i]/4e+3;
969 rastrigin_func(x,&fit[i],nx,&Os[i*nx],&Mr[i*nx*nx],r_flag);
970 fit[i]=1000*fit[i]/1e+3;
972 weierstrass_func(x,&fit[i],nx,&Os[i*nx],&Mr[i*nx*nx],r_flag);
973 fit[i]=1000*fit[i]/400;
974 cf_cal(x, f, nx, Os, delta,bias,fit,cf_num);
977 void cec2013::cf06 (
const double *x,
double *f,
int nx,
const double *Os,
const double *Mr,
int r_flag)
const
981 double delta[5] = {10,10,10,10,10};
982 double bias[5] = {0, 100, 200, 300, 400};
984 schwefel_func(x,&fit[i],nx,&Os[i*nx],&Mr[i*nx*nx],r_flag);
985 fit[i]=1000*fit[i]/4e+3;
987 rastrigin_func(x,&fit[i],nx,&Os[i*nx],&Mr[i*nx*nx],r_flag);
988 fit[i]=1000*fit[i]/1e+3;
990 ellips_func(x,&fit[i],nx,&Os[i*nx],&Mr[i*nx*nx],r_flag);
991 fit[i]=1000*fit[i]/1e+10;
993 weierstrass_func(x,&fit[i],nx,&Os[i*nx],&Mr[i*nx*nx],r_flag);
994 fit[i]=1000*fit[i]/400;
996 griewank_func(x,&fit[i],nx,&Os[i*nx],&Mr[i*nx*nx],r_flag);
997 fit[i]=1000*fit[i]/100;
998 cf_cal(x, f, nx, Os, delta,bias,fit,cf_num);
1002 void cec2013::cf07 (
const double *x,
double *f,
int nx,
const double *Os,
const double *Mr,
int r_flag)
const
1006 double delta[5] = {10,10,10,20,20};
1007 double bias[5] = {0, 100, 200, 300, 400};
1009 griewank_func(x,&fit[i],nx,&Os[i*nx],&Mr[i*nx*nx],r_flag);
1010 fit[i]=10000*fit[i]/100;
1012 rastrigin_func(x,&fit[i],nx,&Os[i*nx],&Mr[i*nx*nx],r_flag);
1013 fit[i]=10000*fit[i]/1e+3;
1015 schwefel_func(x,&fit[i],nx,&Os[i*nx],&Mr[i*nx*nx],r_flag);
1016 fit[i]=10000*fit[i]/4e+3;
1018 weierstrass_func(x,&fit[i],nx,&Os[i*nx],&Mr[i*nx*nx],r_flag);
1019 fit[i]=10000*fit[i]/400;
1021 sphere_func(x,&fit[i],nx,&Os[i*nx],&Mr[i*nx*nx],0);
1022 fit[i]=10000*fit[i]/1e+5;
1023 cf_cal(x, f, nx, Os, delta,bias,fit,cf_num);
1026 void cec2013::cf08 (
const double *x,
double *f,
int nx,
const double *Os,
const double *Mr,
int r_flag)
const
1030 double delta[5] = {10,20,30,40,50};
1031 double bias[5] = {0, 100, 200, 300, 400};
1033 grie_rosen_func(x,&fit[i],nx,&Os[i*nx],&Mr[i*nx*nx],r_flag);
1034 fit[i]=10000*fit[i]/4e+3;
1036 schaffer_F7_func(x,&fit[i],nx,&Os[i*nx],&Mr[i*nx*nx],r_flag);
1037 fit[i]=10000*fit[i]/4e+6;
1039 schwefel_func(x,&fit[i],nx,&Os[i*nx],&Mr[i*nx*nx],r_flag);
1040 fit[i]=10000*fit[i]/4e+3;
1042 escaffer6_func(x,&fit[i],nx,&Os[i*nx],&Mr[i*nx*nx],r_flag);
1043 fit[i]=10000*fit[i]/2e+7;
1045 sphere_func(x,&fit[i],nx,&Os[i*nx],&Mr[i*nx*nx],0);
1046 fit[i]=10000*fit[i]/1e+5;
1047 cf_cal(x, f, nx, Os, delta,bias,fit,cf_num);
1050 void cec2013::shiftfunc (
const double *x,
double *xshift,
int nx,
const double *Os)
const {
1052 for (i=0; i<nx; i++)
1054 xshift[i]=x[i]-Os[i];
1058 void cec2013::rotatefunc (
const double *x,
double *xrot,
int nx,
const double *Mr)
const
1061 for (i=0; i<nx; i++)
1064 for (j=0; j<nx; j++)
1066 xrot[i]=xrot[i]+x[j]*Mr[i*nx+j];
1071 void cec2013::asyfunc (
const double *x,
double *xasy,
int nx,
double beta)
const
1074 for (i=0; i<nx; i++)
1077 xasy[i]=pow(x[i],1.0+beta*i/(nx-1)*pow(x[i],0.5));
1081 void cec2013::oszfunc (
const double *x,
double *xosz,
int nx)
const
1085 for (i=0; i<nx; i++)
1107 xosz[i]=sx*exp(xx+0.049*(sin(c1*xx)+sin(c2*xx)));
1114 void cec2013::cf_cal(
const double *x,
double *f,
int nx,
const double *Os,
double * delta,
double * bias,
double * fit,
int cf_num)
const
1118 double w_max=0,w_sum=0;
1119 w=(
double *)malloc(cf_num *
sizeof(
double));
1120 for (i=0; i<cf_num; i++)
1124 for (j=0; j<nx; j++)
1126 w[i]+=pow(x[j]-Os[i*nx+j],2.0);
1129 w[i]=pow(1.0/w[i],0.5)*exp(-w[i]/2.0/nx/pow(delta[i],2.0));
1136 for (i=0; i<cf_num; i++)
1142 for (i=0; i<cf_num; i++)
1147 for (i=0; i<cf_num; i++)
1149 f[0]=f[0]+w[i]/w_sum*fit[i];
boost::shared_ptr< base > base_ptr
Alias for shared pointer to base problem.
std::vector< double > decision_vector
Decision vector type.
size_type get_dimension() const
Return global dimension.
std::string get_name() const
Get problem's name.
The CEC 2013 problems: Real-Parameter Single Objective Optimization Competition.
std::vector< double > fitness_vector
Fitness vector type.
cec2013(unsigned int=1, problem::base::size_type=30, const std::string &="input_data/")
Constructor.
void objfun_impl(fitness_vector &, const decision_vector &) const
Implementation of the objective function.
void set_bounds(const decision_vector &, const decision_vector &)
Bounds setter from pagmo::decision_vector.
decision_vector::size_type size_type
Problem's size type: the same as pagmo::decision_vector's size type.
base_ptr clone() const
Clone method.