TwoDoubles f4(double* x) { /* skew Rastrigin-Bueche, condition 10, skew-"condition" 100*/ int i, rseed; /*Loop over dim*/ static unsigned int funcId = 4; static double condition = 10.; static double alpha = 100.; double tmp, tmp2, Fadd, Fval, Fpen = 0., Ftrue = 0.; TwoDoubles res; if (!isInitDone) { rseed = 3 + 10000 * trialid; /* Not the same as before.*/ /*INITIALIZATION*/ Fopt = computeFopt(funcId, trialid); computeXopt(rseed, DIM); for (i = 0; i < DIM; i += 2) Xopt[i] = fabs(Xopt[i]); /*Skew*/ isInitDone = 1; } Fadd = Fopt; for (i = 0; i < DIM; i++) { tmp = fabs(x[i]) - 5.; if (tmp > 0.) Fpen += tmp * tmp; } Fpen *= 1e2; Fadd += Fpen; for (i = 0; i < DIM; i++) { tmx[i] = x[i] - Xopt[i]; } monotoneTFosc(tmx); for (i = 0; i < DIM; i++) { if (i % 2 == 0 && tmx[i] > 0) tmx[i] = sqrt(alpha) * tmx[i]; tmx[i] = pow(sqrt(condition), ((double)i)/((double)(DIM-1))) * tmx[i]; } /* COMPUTATION core*/ tmp = 0.; tmp2 = 0.; for (i = 0; i < DIM; i++) { tmp += cos(2*M_PI*tmx[i]); tmp2 += tmx[i]*tmx[i]; } Ftrue = 10 * (DIM - tmp) + tmp2; Ftrue += Fadd; Fval = Ftrue; /* without noise*/ res.Fval = Fval; res.Ftrue = Ftrue; return res; }
TwoDoubles f118(double* x) { /* ellipsoid with Cauchy noise, monotone x-transformation, condition 1e4*/ int i, j, rseed; /*Loop over dim*/ static int funcId = 118; static int rrseed = 10; static double condition = 1e4; double Fadd, Fval, tmp, Fpen = 0., Ftrue = 0.; TwoDoubles res; if (!isInitDone) { rseed = rrseed + 10000 * trialid; /*INITIALIZATION*/ Fopt = computeFopt(funcId, trialid); computeXopt(rseed, DIM); computeRotation(rotation, rseed + 1000000, DIM); isInitDone = 1; } Fadd = Fopt; /* BOUNDARY HANDLING*/ for (i = 0; i < DIM; i++) { tmp = fabs(x[i]) - 5.; if (tmp > 0.) { Fpen += tmp * tmp; } } Fadd += 100. * Fpen; /* TRANSFORMATION IN SEARCH SPACE*/ for (i = 0; i < DIM; i++) { tmx[i] = 0.; for (j = 0; j < DIM; j++) { tmx[i] += rotation[i][j] * (x[j] - Xopt[j]); } } monotoneTFosc(tmx); /* COMPUTATION core*/ for (i = 0; i < DIM; i++) { Ftrue += pow(condition, ((double)i)/((double)(DIM-1))) * tmx[i] * tmx[i]; } Fval = FCauchy(Ftrue, 1., 0.2); Ftrue += Fadd; Fval += Fadd; res.Fval = Fval; res.Ftrue = Ftrue; return res; }
TwoDoubles f3(double* x) { /* Rastrigin with monotone transformation separable "condition" 10*/ int i, rseed; /*Loop over dim*/ static unsigned int funcId = 3; static double condition = 10.; static double beta = 0.2; double tmp, tmp2, Fadd, Fval, Ftrue = 0.; TwoDoubles res; if (!isInitDone) { rseed = funcId + 10000 * trialid; /*INITIALIZATION*/ Fopt = computeFopt(funcId, trialid); computeXopt(rseed, DIM); isInitDone = 1; } Fadd = Fopt; for (i = 0; i < DIM; i++) { tmx[i] = x[i] - Xopt[i]; } monotoneTFosc(tmx); for (i = 0; i < DIM; i++) { tmp = ((double)i)/((double)(DIM-1)); if (tmx[i] > 0) tmx[i] = pow(tmx[i], 1 + beta * tmp * sqrt(tmx[i])); tmx[i] = pow(sqrt(condition), tmp) * tmx[i]; } /* COMPUTATION core*/ tmp = 0.; tmp2 = 0.; for (i = 0; i < DIM; i++) { tmp += cos(2*M_PI*tmx[i]); tmp2 += tmx[i]*tmx[i]; } Ftrue = 10 * (DIM - tmp) + tmp2; Ftrue += Fadd; Fval = Ftrue; /* without noise*/ res.Fval = Fval; res.Ftrue = Ftrue; return res; }
TwoDoubles f11(double* x) { /* discus (tablet) with monotone transformation, condition 1e6*/ int i, j, rseed; /*Loop over dim*/ static unsigned int funcId = 11; static double condition = 1e6; double Fadd, Fval, Ftrue; TwoDoubles res; if (!isInitDone) { rseed = funcId + 10000 * trialid; /*INITIALIZATION*/ Fopt = computeFopt(funcId, trialid); computeXopt(rseed, DIM); computeRotation(rotation, rseed + 1000000, DIM); isInitDone = 1; } Fadd = Fopt; /* BOUNDARY HANDLING*/ /* TRANSFORMATION IN SEARCH SPACE*/ for (i = 0; i < DIM; i++) { tmx[i] = 0.; for (j = 0; j < DIM; j++) { tmx[i] += rotation[i][j] * (x[j] - Xopt[j]); } } monotoneTFosc(tmx); /* COMPUTATION core*/ Ftrue = condition * tmx[0] * tmx[0]; for (i = 1; i < DIM; i++) { Ftrue += tmx[i] * tmx[i]; } Ftrue += Fadd; Fval = Ftrue; /* without noise*/ res.Fval = Fval; res.Ftrue = Ftrue; return res; }
TwoDoubles f2(double* x) { /* separable ellipsoid with monotone transformation, condition 1e6*/ int i, rseed; /*Loop over dim*/ static double condition = 1e6; static unsigned int funcId = 2; double Fadd, Fval, Ftrue = 0.; TwoDoubles res; if (!isInitDone) { rseed = funcId + 10000 * trialid; /*INITIALIZATION*/ Fopt = computeFopt(funcId, trialid); computeXopt(rseed, DIM); isInitDone = 1; } Fadd = Fopt; for (i = 0; i < DIM; i++) { tmx[i] = x[i] - Xopt[i]; } monotoneTFosc(tmx); /* COMPUTATION core*/ for (i = 0; i < DIM; i++) { Ftrue += pow(condition, ((double)i)/((double)(DIM-1))) * tmx[i] * tmx[i]; } Ftrue += Fadd; Fval = Ftrue; /* without noise*/ res.Fval = Fval; res.Ftrue = Ftrue; return res; }
TwoDoubles f16(double* x) { /* Weierstrass, condition 100*/ int i, j, k, rseed; /*Loop over dim*/ static unsigned int funcId = 16; static double condition = 100.; static double aK[12]; static double bK[12]; static double F0; double tmp, Fadd, Fval, Fpen = 0., Ftrue = 0.; TwoDoubles res; if (!isInitDone) { rseed = funcId + 10000 * trialid; /*INITIALIZATION*/ Fopt = computeFopt(funcId, trialid); computeXopt(rseed, DIM); computeRotation(rotation, rseed + 1000000, DIM); computeRotation(rot2, rseed, DIM); for (i = 0; i < DIM; i++) { for (j = 0; j < DIM; j++) { linearTF[i][j] = 0.; for (k = 0; k < DIM; k++) { linearTF[i][j] += rotation[i][k] * pow(1./sqrt(condition), ((double)k)/((double)(DIM-1))) * rot2[k][j]; } } } F0 = 0.; for (i = 0; i < 12; i ++) /* number of summands, 20 in CEC2005, 10/12 saves 30% of time*/ { aK[i] = pow(0.5, (double)i); bK[i] = pow(3., (double)i); F0 += aK[i] * cos(2 * M_PI * bK[i] * 0.5); } isInitDone = 1; } Fadd = Fopt; /* BOUNDARY HANDLING*/ for (i = 0; i < DIM; i++) { tmp = fabs(x[i]) - 5.; if (tmp > 0.) { Fpen += tmp * tmp; } } Fadd += 10./(double)DIM * Fpen; /* TRANSFORMATION IN SEARCH SPACE*/ for (i = 0; i < DIM; i++) { tmpvect[i] = 0.; for (j = 0; j < DIM; j++) { tmpvect[i] += rotation[i][j] * (x[j] - Xopt[j]); } } monotoneTFosc(tmpvect); for (i = 0; i < DIM; i++) { tmx[i] = 0.; for (j = 0; j < DIM; j++) { tmx[i] += linearTF[i][j] * tmpvect[j]; } } /* COMPUTATION core*/ for (i = 0; i < DIM; i++) { tmp = 0.; for (j = 0; j < 12; j++) { tmp += cos(2 * M_PI * (tmx[i] + 0.5) * bK[j]) * aK[j]; } Ftrue += tmp; } Ftrue = 10. * pow(Ftrue/(double)DIM - F0, 3.); Ftrue += Fadd; Fval = Ftrue; /* without noise*/ res.Fval = Fval; res.Ftrue = Ftrue; return res; }
TwoDoubles f15(double* x) { /* Rastrigin with asymmetric non-linear distortion, "condition" 10*/ int i, j, k, rseed; /*Loop over dim*/ static unsigned int funcId = 15; static double condition = 10.; static double beta = 0.2; double tmp = 0., tmp2 = 0., Fadd, Fval, Ftrue; TwoDoubles res; if (!isInitDone) { rseed = funcId + 10000 * trialid; /*INITIALIZATION*/ Fopt = computeFopt(funcId, trialid); computeXopt(rseed, DIM); computeRotation(rotation, rseed + 1000000, DIM); computeRotation(rot2, rseed, DIM); for (i = 0; i < DIM; i++) { for (j = 0; j < DIM; j++) { linearTF[i][j] = 0.; for (k = 0; k < DIM; k++) { linearTF[i][j] += rotation[i][k] * pow(sqrt(condition), ((double)k)/((double)(DIM-1))) * rot2[k][j]; } } } isInitDone = 1; } Fadd = Fopt; /* BOUNDARY HANDLING*/ /* TRANSFORMATION IN SEARCH SPACE*/ for (i = 0; i < DIM; i++) { tmpvect[i] = 0.; for (j = 0; j < DIM; j++) { tmpvect[i] += rotation[i][j] * (x[j] - Xopt[j]); } } monotoneTFosc(tmpvect); for (i = 0; i < DIM; i++) { if (tmpvect[i] > 0) tmpvect[i] = pow(tmpvect[i], 1 + beta * ((double)i)/((double)(DIM-1)) * sqrt(tmpvect[i])); } for (i = 0; i < DIM; i++) { tmx[i] = 0.; for (j = 0; j < DIM; j++) { tmx[i] += linearTF[i][j] * tmpvect[j]; } } /* COMPUTATION core*/ for (i = 0; i < DIM; i++) { tmp += cos(2. * M_PI * tmx[i]); tmp2 += tmx[i] * tmx[i]; } Ftrue = 10. * ((double)DIM - tmp) + tmp2; Ftrue += Fadd; Fval = Ftrue; /* without noise*/ res.Fval = Fval; res.Ftrue = Ftrue; return res; }