TwoDoubles f1(double* x) { /*Sphere function*/ int i, rseed; /*Loop over dim*/ static unsigned int funcId = 1; double Fadd, r, Fval, Ftrue = 0.; TwoDoubles res; if (!isInitDone) { rseed = funcId + 10000 * trialid; /*INITIALIZATION*/ Fopt = computeFopt(funcId, trialid); computeXopt(rseed, DIM); isInitDone = 1; } Fadd = Fopt; /* COMPUTATION core*/ for (i = 0; i < DIM; i++) { r = x[i] - Xopt[i]; Ftrue += r * r; } Ftrue += Fadd; Fval = Ftrue; /* without noise*/ res.Ftrue = Ftrue; res.Fval = Fval; return res; }
TwoDoubles f5(double* x) { /* linear slope*/ int i, rseed; /*Loop over dim*/ static unsigned int funcId = 5; static double alpha = 100.; static double Fadd; /*Treatment is different from other functions.*/ double tmp, Fval, Ftrue = 0.; TwoDoubles res; if (!isInitDone) { rseed = funcId + 10000 * trialid; /*INITIALIZATION*/ Fopt = computeFopt(funcId, trialid); Fadd = Fopt; computeXopt(rseed, DIM); for (i = 0; i < DIM; i ++) { tmp = pow(sqrt(alpha), ((double)i)/((double)(DIM-1))); if (Xopt[i] > 0) { Xopt[i] = 5.; } else if (Xopt[i] < 0) { Xopt[i] = -5.; } Fadd += 5. * tmp; } isInitDone = 1; } /* BOUNDARY HANDLING*/ /* move "too" good coordinates back into domain*/ for (i = 0; i < DIM; i++) { if ((Xopt[i] == 5.) && (x[i] > 5)) tmx[i] = 5.; else if ((Xopt[i] == -5.) && (x[i] < -5)) tmx[i] = -5.; else tmx[i] = x[i]; } /* COMPUTATION core*/ for (i = 0; i < DIM; i++) { if (Xopt[i] > 0) { Ftrue -= pow(sqrt(alpha), ((double)i)/((double)(DIM-1))) * tmx[i]; } else { Ftrue += pow(sqrt(alpha), ((double)i)/((double)(DIM-1))) * tmx[i]; } } Ftrue += Fadd; Fval = Ftrue; /* without noise*/ res.Fval = Fval; res.Ftrue = Ftrue; return res; }
TwoDoubles f104(double* x) { /* Rosenbrock non-rotated with moderate Gauss noise*/ int i, rseed; /*Loop over dim*/ static int funcId = 104; static int rrseed = 8; static double scales; double Fadd, Fval, tmp, Fpen = 0., Ftrue = 0.; TwoDoubles res; if (!isInitDone) { rseed = rrseed + 10000 * trialid; /*INITIALIZATION*/ Fopt = computeFopt(funcId, trialid); computeXopt(rseed, DIM); scales = fmax(1., sqrt((double)DIM) / 8.); 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] = scales * (x[i] - 0.75 * Xopt[i]) + 1; } /* COMPUTATION core*/ Ftrue = 0.; for (i = 0; i < DIM - 1; i++) { tmp = (tmx[i] * tmx[i] - tmx[i+1]); Ftrue += tmp * tmp; } Ftrue *= 1e2; for (i = 0; i < DIM - 1; i ++) { tmp = (tmx[i] - 1); Ftrue += tmp * tmp; } Fval = FGauss(Ftrue, 0.01); Ftrue += Fadd; Fval += Fadd; res.Fval = Fval; res.Ftrue = Ftrue; return res; }
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 f13(double* x) { /* sharp ridge*/ int i, j, k, rseed; /*Loop over dim*/ static unsigned int funcId = 13; static double condition = 10.; static double alpha = 100.; double Fadd, Fval, 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(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++) { tmx[i] = 0.; for (j = 0; j < DIM; j++) { tmx[i] += linearTF[i][j] * (x[j] - Xopt[j]); } } /* COMPUTATION core*/ for (i = 1; i < DIM; i++) { Ftrue += tmx[i] * tmx[i]; } Ftrue = alpha * sqrt(Ftrue); Ftrue += tmx[0] * tmx[0]; 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 f121(double* x) { /* sum of different powers with seldom Cauchy Noise, between x^2 and x^6*/ int i, j, rseed; /*Loop over dim*/ static int funcId = 121; static int rrseed = 14; static double alpha = 4.; 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]); } } /* COMPUTATION core*/ for (i = 0; i < DIM; i++) { Ftrue += pow(fabs(tmx[i]), 2 + alpha * ((double)i)/((double)(DIM-1))); } Ftrue = sqrt(Ftrue); Fval = FCauchy(Ftrue, 1., 0.2); Ftrue += Fadd; Fval += Fadd; res.Fval = Fval; res.Ftrue = Ftrue; return res; }
TwoDoubles f12(double* x) { /* bent cigar with asymmetric space distortion, condition 1e6*/ int i, j, rseed; /*Loop over dim*/ static unsigned int funcId = 12; static double condition = 1e6; static double beta = 0.5; double Fadd, Fval, Ftrue; TwoDoubles res; if (!isInitDone) { rseed = funcId + 10000 * trialid; /*INITIALIZATION*/ Fopt = computeFopt(funcId, trialid); computeXopt(rseed + 1000000, DIM); computeRotation(rotation, rseed + 1000000, DIM); 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]); } 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] += rotation[i][j] * tmpvect[j]; } } /* COMPUTATION core*/ Ftrue = tmx[0] * tmx[0]; for (i = 1; i < DIM; i++) { Ftrue += condition * tmx[i] * tmx[i]; } Ftrue += Fadd; Fval = Ftrue; /* without noise*/ 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 f8(double* x) { /* Rosenbrock, non-rotated*/ static unsigned int funcId = 8; int i, rseed; /*Loop over dim*/ static double scales; double tmp, Fadd, Fval, Ftrue = 0.; TwoDoubles res; if (!isInitDone) { rseed = funcId + 10000 * trialid; scales = fmax(1., sqrt(DIM) / 8.); /*INITIALIZATION*/ Fopt = computeFopt(funcId, trialid); computeXopt(rseed, DIM); for (i = 0; i < DIM; i ++) Xopt[i] *= 0.75; isInitDone = 1; } Fadd = Fopt; /* BOUNDARY HANDLING*/ /* TRANSFORMATION IN SEARCH SPACE*/ for (i = 0; i < DIM; i++) { tmx[i] = scales * (x[i] - Xopt[i]) + 1; } /* COMPUTATION core*/ for (i = 0; i < DIM - 1; i++) { tmp = (tmx[i] * tmx[i] - tmx[i+1]); Ftrue += tmp * tmp; } Ftrue *= 1e2; for (i = 0; i < DIM - 1; i ++) { tmp = (tmx[i] - 1.); Ftrue += tmp * tmp; } Ftrue += Fadd; Fval = Ftrue; /* without noise*/ res.Fval = Fval; res.Ftrue = Ftrue; return res; }
TwoDoubles f101(double* x) { /*sphere with moderate Gauss noise*/ int i, rseed; /*Loop over dim*/ static unsigned int funcId = 101; static unsigned int rrseed = 1; double Fadd, Fval, tmp, Fpen = 0., Ftrue = 0.; TwoDoubles res; if (!isInitDone) { rseed = rrseed + 10000 * trialid; Fopt = computeFopt(funcId, trialid); computeXopt(rseed, 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; /* COMPUTATION core*/ for (i = 0; i < DIM; i++) { tmp = (x[i] - Xopt[i]); Ftrue += tmp * tmp; } Fval = FGauss(Ftrue, 0.01); Ftrue += Fadd; Fval += Fadd; res.Fval = Fval; res.Ftrue = Ftrue; return res; }
TwoDoubles f14(double* x) { /* sum of different powers, between x^2 and x^6*/ int i, j, rseed; static unsigned int funcId = 14; static double alpha = 4.; double Fadd, Fval, Ftrue = 0.; 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]); } } /* COMPUTATION core*/ for (i = 0; i < DIM; i++) { Ftrue += pow(fabs(tmx[i]), 2. + alpha * ((double)i)/((double)(DIM-1))); } Ftrue = sqrt(Ftrue); 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 f115(double* x) { /* step-ellipsoid with Cauchy noise, condition 100*/ int i, j, rseed; /*Loop over dim*/ static int funcId = 115; static int rrseed = 7; static double condition = 100.; static double alpha = 10.; double x1, 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); computeRotation(rot2, rseed, 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++) { tmpvect[i] = 0.; tmp = sqrt(pow(condition/10., ((double)i)/((double)(DIM-1)))); for (j = 0; j < DIM; j++) { tmpvect[i] += tmp * rot2[i][j] * (x[j] - Xopt[j]); } } x1 = tmpvect[0]; for (i = 0; i < DIM; i++) { if (fabs(tmpvect[i]) > 0.5) { tmpvect[i] = round(tmpvect[i]); } else { tmpvect[i] = round(alpha * tmpvect[i])/alpha; } } for (i = 0; i < DIM; i++) { tmx[i] = 0.; for (j = 0; j < DIM; j++) { tmx[i] += rotation[i][j] * tmpvect[j]; } } /* COMPUTATION core*/ for (i = 0; i < DIM; i++) { Ftrue += pow(condition, ((double)i)/((double)(DIM-1))) * tmx[i] * tmx[i]; } Ftrue = 0.1 * fmax(1e-4 * fabs(x1), Ftrue); Fval = FCauchy(Ftrue, 1., 0.2); Ftrue += Fadd; Fval += Fadd; res.Fval = Fval; res.Ftrue = Ftrue; return res; }
TwoDoubles f6(double* x) { /* attractive sector function*/ int i, j, k, rseed; /*Loop over dim*/ static unsigned int funcId = 6; static double alpha = 100.; double Fadd, Fval, Ftrue = 0.; TwoDoubles res; if (!isInitDone) { static double condition = 10.; rseed = funcId + 10000 * trialid; /*INITIALIZATION*/ Fopt = computeFopt(funcId, trialid); computeXopt(rseed, DIM); computeRotation(rotation, rseed + 1000000, DIM); computeRotation(rot2, rseed, DIM); /* decouple scaling from function definition*/ 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++) { tmx[i] = 0.; for (j = 0; j < DIM; j++) { tmx[i] += linearTF[i][j] * (x[j] - Xopt[j]); } } /* COMPUTATION core*/ for (i = 0; i < DIM; i++) { if (tmx[i] * Xopt[i] > 0) tmx[i] *= alpha; Ftrue += tmx[i] * tmx[i]; } /*MonotoneTFosc...*/ if (Ftrue > 0) { Ftrue = pow(exp(log(Ftrue)/0.1 + 0.49*(sin(log(Ftrue)/0.1) + sin(0.79*log(Ftrue)/0.1))), 0.1); } else if (Ftrue < 0) { Ftrue = -pow(exp(log(-Ftrue)/0.1 + 0.49*(sin(0.55 * log(-Ftrue)/0.1) + sin(0.31*log(-Ftrue)/0.1))), 0.1); } Ftrue = pow(Ftrue, 0.9); Ftrue += Fadd; Fval = Ftrue; /* without noise*/ res.Fval = Fval; res.Ftrue = Ftrue; return res; }
TwoDoubles f124(double* x) { /* Schaffers F7 with seldom Cauchy noise, with asymmetric non-linear transformation, condition 10*/ int i, j, rseed; /*Loop over dim*/ static int funcId = 124; static int rrseed = 17; static double condition = 10.; static double beta = 0.5; 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); computeRotation(rot2, rseed, 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++) { tmpvect[i] = 0.; for (j = 0; j < DIM; j++) { tmpvect[i] += rotation[i][j] * (x[j] - Xopt[j]); } 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.; tmp = pow(sqrt(condition), ((double)i)/((double)(DIM-1))); for (j = 0; j < DIM; j++) { tmx[i] += tmp * rot2[i][j] * tmpvect[j]; } } /* COMPUTATION core*/ for (i = 0; i < DIM - 1; i++) { tmp = tmx[i] * tmx[i] + tmx[i+1] * tmx[i+1]; Ftrue += pow(tmp, 0.25) * (pow(sin(50. * pow(tmp, 0.1)), 2.) + 1.); } Ftrue = pow(Ftrue/(double)(DIM - 1), 2.); Fval = FCauchy(Ftrue, 1., 0.2); Ftrue += Fadd; Fval += Fadd; 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; }
TwoDoubles f23(double* x) { /* Katsuura function*/ int i, j, k, rseed; /*Loop over dim*/ static unsigned int funcId = 23; static double condition = 100.; double Fadd = 0., Fpen = 0., tmp, Ftrue = 0., arr, prod = 1., tmp2, Fval; double *ptmx, *plinTF, *ptmp; 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*/ for (i = 0; i < DIM; i++) { tmp = fabs(x[i]) - 5.; if (tmp > 0.) { Fpen += tmp * tmp; } } Fadd += Fpen; /* TRANSFORMATION IN SEARCH SPACE*/ /* write rotated difference vector into tmx*/ for (j = 0; j < DIM; j++) /* store difference vector*/ tmpvect[j] = x[j] - Xopt[j]; for (i = 0; i < DIM; i++) { tmx[i] = 0.; ptmx = &tmx[i]; plinTF = linearTF[i]; ptmp = tmpvect; for (j = 0; j < DIM; j++) { *ptmx += *plinTF++ * *ptmp++; } } /* for (i = 0; i < DIM; i++) { tmx[i] = 0.; for (j = 0; j < DIM; j++) { tmx[i] += linearTF[i][j] * (x[j] - Xopt[j]); } }*/ /* COMPUTATION core*/ for (i = 0; i < DIM; i++) { tmp = 0.; for (j = 1; j < 33; j++) { tmp2 = pow(2., (double)j); arr = tmx[i] * tmp2; tmp += fabs(arr - round(arr)) / tmp2; } tmp = 1. + tmp * (double)(i + 1); prod *= tmp; } Ftrue = 10./(double)DIM/(double)DIM * (-1. + pow(prod, 10./pow((double)DIM, 1.2))); Ftrue += Fadd; Fval = Ftrue; /* without noise*/ res.Fval = Fval; res.Ftrue = Ftrue; return res; }