break;
default:
String outputStr = "Invalid value for parameter, or parameter not found.\n" + "Acceptable values are:\n";
for (i = 0; i < noiseTypes.length; i++)
outputStr += noiseTypes[i] + "\n";
state.output.fatal(outputStr, new Parameter(P_NOISE));
break;
}
value += fAdd;
fit = (-value);
((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
break;
case ELLIPSOIDAL:// f2
/*
* separable ellipsoid with monotone transformation with noiseless
* condition 1e6 and noisy condition 1e4
*/
fAdd = fOpt;
if (noise == NONE)
{
condition = 1e6;
for (i = 0; i < genomeSize; i++)
{
tmx[i] = genome[i] - xOpt[i];
}
}
else
{
condition = 1e4;
fAdd = fOpt;
/* BOUNDARY HANDLING */
for (i = 0; i < genomeSize; i++)
{
tmp = Math.abs(genome[i]) - 5.;
if (tmp > 0.)
{
fPen += tmp * tmp;
}
}
fAdd += 100. * fPen;
/* TRANSFORMATION IN SEARCH SPACE */
for (i = 0; i < genomeSize; i++)
{
tmx[i] = 0.;
for (j = 0; j < genomeSize; j++)
{
tmx[i] += rotation[i][j] * (genome[j] - xOpt[j]);
}
}
}
monotoneTFosc(tmx);
/* COMPUTATION core */
for (i = 0; i < genomeSize; i++)
{
value += Math.pow(condition, ((double) i) / ((double) (genomeSize - 1))) * tmx[i] * tmx[i];
}
switch (noise)
{
case NONE:
break;
case GAUSSIAN:
value = fGauss(value, 1.0, state.random[threadnum]);
break;
case UNIFORM:
value = fUniform(value, 0.49 + 1.0 / genomeSize, 1.0, state.random[threadnum]);
break;
case CAUCHY:
value = fCauchy(value, 1.0, 0.2, state.random[threadnum]);
break;
default:
String outputStr = "Invalid value for parameter, or parameter not found.\n" + "Acceptable values are:\n";
for (i = 0; i < 4; i++)
outputStr += noiseTypes[i] + "\n";
state.output.fatal(outputStr, new Parameter(P_NOISE));
break;
}
value += fAdd;
fit = (-value);
((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
break;
case RASTRIGIN:// f3
/* Rastrigin with monotone transformation separable "condition" 10 */
condition = 10;
beta = 0.2;
fAdd = fOpt;
for (i = 0; i < genomeSize; i++)
{
tmx[i] = genome[i] - xOpt[i];
}
monotoneTFosc(tmx);
for (i = 0; i < genomeSize; i++)
{
tmp = ((double) i) / ((double) (genomeSize - 1));
if (tmx[i] > 0)
tmx[i] = Math.pow(tmx[i], 1 + beta * tmp * Math.sqrt(tmx[i]));
tmx[i] = Math.pow(Math.sqrt(condition), tmp) * tmx[i];
}
/* COMPUTATION core */
tmp = 0;
tmp2 = 0;
for (i = 0; i < genomeSize; i++)
{
tmp += Math.cos(2 * Math.PI * tmx[i]);
tmp2 += tmx[i] * tmx[i];
}
value = 10 * (genomeSize - tmp) + tmp2;
value += fAdd;
fit = (-value);
((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
break;
case BUCHE_RASTRIGIN:// f4
/* skew Rastrigin-Bueche, condition 10, skew-"condition" 100 */
condition = 10.0;
alpha = 100;
fAdd = fOpt;
for (i = 0; i < genomeSize; i++)
{
tmp = Math.abs(genome[i]) - 5.;
if (tmp > 0.)
fPen += tmp * tmp;
}
fPen *= 1e2;
fAdd += fPen;
for (i = 0; i < genomeSize; i++)
{
tmx[i] = genome[i] - xOpt[i];
}
monotoneTFosc(tmx);
for (i = 0; i < genomeSize; i++)
{
if (i % 2 == 0 && tmx[i] > 0)
tmx[i] = Math.sqrt(alpha) * tmx[i];
tmx[i] = Math.pow(Math.sqrt(condition), ((double) i) / ((double) (genomeSize - 1))) * tmx[i];
}
/* COMPUTATION core */
tmp = 0.0;
tmp2 = 0.0;
for (i = 0; i < genomeSize; i++)
{
tmp += Math.cos(2 * Math.PI * tmx[i]);
tmp2 += tmx[i] * tmx[i];
}
value = 10 * (genomeSize - tmp) + tmp2;
value += fAdd;
fit = (-value);
((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
break;
case LINEAR_SLOPE:// f5
/* linear slope */
alpha = 100;
fAdd = fOpt;
/* BOUNDARY HANDLING */
/* move "too" good coordinates back into domain */
for (i = 0; i < genomeSize; i++)
{
if ((xOpt[i] == 5.) && (genome[i] > 5))
tmx[i] = 5.;
else if ((xOpt[i] == -5.) && (genome[i] < -5))
tmx[i] = -5.;
else
tmx[i] = genome[i];
}
/* COMPUTATION core */
for (i = 0; i < genomeSize; i++)
{
if (xOpt[i] > 0)
{
value -= Math.pow(Math.sqrt(alpha), ((double) i) / ((double) (genomeSize - 1))) * tmx[i];
}
else
{
value += Math.pow(Math.sqrt(alpha), ((double) i) / ((double) (genomeSize - 1))) * tmx[i];
}
}
value += fAdd;
fit = (-value);
((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
break;
case ATTRACTIVE_SECTOR:// f6
/* attractive sector function */
alpha = 100.0;
fAdd = fOpt;
/* BOUNDARY HANDLING */
/* TRANSFORMATION IN SEARCH SPACE */
for (i = 0; i < genomeSize; i++)
{
tmx[i] = 0.0;
for (j = 0; j < genomeSize; j++)
{
tmx[i] += linearTF[i][j] * (genome[j] - xOpt[j]);
}
}
/* COMPUTATION core */
for (i = 0; i < genomeSize; i++)
{
if (tmx[i] * xOpt[i] > 0)
tmx[i] *= alpha;
value += tmx[i] * tmx[i];
}
/* monotoneTFosc... */
if (value > 0)
{
value = Math.pow(Math.exp(Math.log(value) / 0.1 + 0.49 * (Math.sin(Math.log(value) / 0.1) + Math.sin(0.79 * Math.log(value) / 0.1))), 0.1);
}
else if (value < 0)
{
value = -Math.pow(Math.exp(Math.log(-value) / 0.1 + 0.49 * (Math.sin(0.55 * Math.log(-value) / 0.1) + Math.sin(0.31 * Math.log(-value) / 0.1))), 0.1);
}
value = Math.pow(value, 0.9);
value += fAdd;
fit = (-value);
((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
break;
case STEP_ELLIPSOIDAL:// f7
/* step-ellipsoid, condition 100 */
condition = 100.0;
alpha = 10.0;
fAdd = fOpt;
/* BOUNDARY HANDLING */
for (i = 0; i < genomeSize; i++)
{
tmp = Math.abs(genome[i]) - 5.0;
if (tmp > 0.0)
{
fPen += tmp * tmp;
}
}
if (noise == NONE)
fAdd += fPen;
else
fAdd += 100. * fPen;
/* TRANSFORMATION IN SEARCH SPACE */
for (i = 0; i < genomeSize; i++)
{
tmpvect[i] = 0.0;
tmp = Math.sqrt(Math.pow(condition / 10., ((double) i) / ((double) (genomeSize - 1))));
for (j = 0; j < genomeSize; j++)
{
tmpvect[i] += tmp * rot2[i][j] * (genome[j] - xOpt[j]);
}
}
x1 = tmpvect[0];
for (i = 0; i < genomeSize; i++)
{
if (Math.abs(tmpvect[i]) > 0.5)
tmpvect[i] = Math.round(tmpvect[i]);
else
tmpvect[i] = Math.round(alpha * tmpvect[i]) / alpha;
}
for (i = 0; i < genomeSize; i++)
{
tmx[i] = 0.0;
for (j = 0; j < genomeSize; j++)
{
tmx[i] += rotation[i][j] * tmpvect[j];
}
}
/* COMPUTATION core */
for (i = 0; i < genomeSize; i++)
{
value += Math.pow(condition, ((double) i) / ((double) (genomeSize - 1))) * tmx[i] * tmx[i];
}
value = 0.1 * Math.max(1e-4 * Math.abs(x1), value);
switch (noise)
{
case NONE:
break;
case GAUSSIAN:
value = fGauss(value, 1.0, state.random[threadnum]);
break;
case UNIFORM:
value = fUniform(value, 0.49 + 1.0 / genomeSize, 1.0, state.random[threadnum]);
break;
case CAUCHY:
value = fCauchy(value, 1.0, 0.2, state.random[threadnum]);
break;
default:
String outputStr = "Invalid value for parameter, or parameter not found.\n" + "Acceptable values are:\n";
for (i = 0; i < 4; i++)
outputStr += noiseTypes[i] + "\n";
state.output.fatal(outputStr, new Parameter(P_NOISE));
break;
}
value += fAdd;
fit = (-value);
((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
break;
case ROSENBROCK:// f8
/* Rosenbrock, non-rotated */
fAdd = fOpt;
if (noise == NONE)
{
/* TRANSFORMATION IN SEARCH SPACE */
for (i = 0; i < genomeSize; i++)
{
tmx[i] = scales * (genome[i] - xOpt[i]) + 1;
}
}
else
{
/* BOUNDARY HANDLING */
for (i = 0; i < genomeSize; i++)
{
tmp = Math.abs(genome[i]) - 5.;
if (tmp > 0.)
{
fPen += tmp * tmp;
}
}
fAdd += 100.0 * fPen;
/* TRANSFORMATION IN SEARCH SPACE */
for (i = 0; i < genomeSize; i++)
{
tmx[i] = scales * (genome[i] - 0.75 * xOpt[i]) + 1;
}
}
/* COMPUTATION core */
for (i = 0; i < genomeSize - 1; i++)
{
tmp = (tmx[i] * tmx[i] - tmx[i + 1]);
value += tmp * tmp;
}
value *= 1e2;
for (i = 0; i < genomeSize - 1; i++)
{
tmp = (tmx[i] - 1.);
value += tmp * tmp;
}
switch (noise)
{
case NONE:
break;
case GAUSSIAN:
value = fGauss(value, 1.0, state.random[threadnum]);
break;
case UNIFORM:
value = fUniform(value, 0.49 + 1.0 / genomeSize, 1.0, state.random[threadnum]);
break;
case CAUCHY:
value = fCauchy(value, 1.0, 0.2, state.random[threadnum]);
break;
case GAUSSIAN_MODERATE:
value = fGauss(value, 0.01, state.random[threadnum]);
break;
case UNIFORM_MODERATE:
value = fUniform(value, 0.01 * (0.49 + 1. / genomeSize), 0.01, state.random[threadnum]);
break;
case CAUCHY_MODERATE:
value = fCauchy(value, 0.01, 0.05, state.random[threadnum]);
break;
default:
String outputStr = "Invalid value for parameter, or parameter not found.\n" + "Acceptable values are:\n";
for (i = 0; i < noiseTypes.length; i++)
outputStr += noiseTypes[i] + "\n";
state.output.fatal(outputStr, new Parameter(P_NOISE));
break;
}
value += fAdd;
fit = (-value);
((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
break;
case ROSENBROCK_ROTATED:// f9
/* Rosenbrock, rotated */
fAdd = fOpt;
/* BOUNDARY HANDLING */
/* TRANSFORMATION IN SEARCH SPACE */
for (i = 0; i < genomeSize; i++)
{
tmx[i] = 0.5;
for (j = 0; j < genomeSize; j++)
{
tmx[i] += linearTF[i][j] * genome[j];
}
}
/* COMPUTATION core */
for (i = 0; i < genomeSize - 1; i++)
{
tmp = (tmx[i] * tmx[i] - tmx[i + 1]);
value += tmp * tmp;
}
value *= 1e2;
for (i = 0; i < genomeSize - 1; i++)
{
tmp = (tmx[i] - 1.);
value += tmp * tmp;
}
value += fAdd;
fit = (-value);
((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
break;
case ELLIPSOIDAL_2:// f10
/* ellipsoid with monotone transformation, condition 1e6 */
condition = 1e6;
fAdd = fOpt;
/* BOUNDARY HANDLING */
/* TRANSFORMATION IN SEARCH SPACE */
for (i = 0; i < genomeSize; i++)
{
tmx[i] = 0.0;
for (j = 0; j < genomeSize; j++)
{
tmx[i] += rotation[i][j] * (genome[j] - xOpt[j]);
}
}
monotoneTFosc(tmx);
/* COMPUTATION core */
for (i = 0; i < genomeSize; i++)
{
fAdd += Math.pow(condition, ((double) i) / ((double) (genomeSize - 1))) * tmx[i] * tmx[i];
}
value = fAdd;
fit = (-value);
((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
break;
case DISCUS:// f11
/* DISCUS (tablet) with monotone transformation, condition 1e6 */
condition = 1e6;
fAdd = fOpt;
/* BOUNDARY HANDLING */
/* TRANSFORMATION IN SEARCH SPACE */
for (i = 0; i < genomeSize; i++)
{
tmx[i] = 0.0;
for (j = 0; j < genomeSize; j++)
{
tmx[i] += rotation[i][j] * (genome[j] - xOpt[j]);
}
}
monotoneTFosc(tmx);
/* COMPUTATION core */
value = condition * tmx[0] * tmx[0];
for (i = 1; i < genomeSize; i++)
{
value += tmx[i] * tmx[i];
}
value += fAdd; /* without noise */
fit = (-value);
((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
break;
case BENT_CIGAR:// f12
/* bent cigar with asymmetric space distortion, condition 1e6 */
condition = 1e6;
beta = 0.5;
fAdd = fOpt;
/* BOUNDARY HANDLING */
/* TRANSFORMATION IN SEARCH SPACE */
for (i = 0; i < genomeSize; i++)
{
tmpvect[i] = 0.0;
for (j = 0; j < genomeSize; j++)
{
tmpvect[i] += rotation[i][j] * (genome[j] - xOpt[j]);
}
if (tmpvect[i] > 0)
{
tmpvect[i] = Math.pow(tmpvect[i], 1 + beta * ((double) i) / ((double) (genomeSize - 1)) * Math.sqrt(tmpvect[i]));
}
}
for (i = 0; i < genomeSize; i++)
{
tmx[i] = 0.0;
for (j = 0; j < genomeSize; j++)
{
tmx[i] += rotation[i][j] * tmpvect[j];
}
}
/* COMPUTATION core */
value = tmx[0] * tmx[0];
for (i = 1; i < genomeSize; i++)
{
value += condition * tmx[i] * tmx[i];
}
value += fAdd;
fit = (-value);
((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
break;
case SHARP_RIDGE:// f13
/* sharp ridge */
condition = 10.0;
alpha = 100.0;
fAdd = fOpt;
/* BOUNDARY HANDLING */
/* TRANSFORMATION IN SEARCH SPACE */
for (i = 0; i < genomeSize; i++)
{
tmx[i] = 0.0;
for (j = 0; j < genomeSize; j++)
{
tmx[i] += linearTF[i][j] * (genome[j] - xOpt[j]);
}
}
/* COMPUTATION core */
for (i = 1; i < genomeSize; i++)
{
value += tmx[i] * tmx[i];
}
value = alpha * Math.sqrt(value);
value += tmx[0] * tmx[0];
value += fAdd;
fit = (-value);
((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
break;
case DIFFERENT_POWERS:// f14
/* sum of different powers, between x^2 and x^6 */
alpha = 4.0;
fAdd = fOpt;
if (noise != NONE)
{
/* BOUNDARY HANDLING */
for (i = 0; i < genomeSize; i++)
{
tmp = Math.abs(genome[i]) - 5.;
if (tmp > 0.)
{
fPen += tmp * tmp;
}
}
fAdd += 100. * fPen;
}
/* TRANSFORMATION IN SEARCH SPACE */
for (i = 0; i < genomeSize; i++)
{
tmx[i] = 0.0;
for (j = 0; j < genomeSize; j++)
{
tmx[i] += rotation[i][j] * (genome[j] - xOpt[j]);
}
}
/* COMPUTATION core */
for (i = 0; i < genomeSize; i++)
{
value += Math.pow(Math.abs(tmx[i]), 2. + alpha * ((double) i) / ((double) (genomeSize - 1)));
}
value = Math.sqrt(value);
switch (noise)
{
case NONE:
break;
case GAUSSIAN:
value = fGauss(value, 1.0, state.random[threadnum]);
break;
case UNIFORM:
value = fUniform(value, 0.49 + 1.0 / genomeSize, 1.0, state.random[threadnum]);
break;
case CAUCHY:
value = fCauchy(value, 1.0, 0.2, state.random[threadnum]);
break;
default:
String outputStr = "Invalid value for parameter, or parameter not found.\n" + "Acceptable values are:\n";
for (i = 0; i < 4; i++)
outputStr += noiseTypes[i] + "\n";
state.output.fatal(outputStr, new Parameter(P_NOISE));
break;
}
value += fAdd;
fit = (-value);
((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
break;
case RASTRIGIN_2:// f15
/* Rastrigin with asymmetric non-linear distortion, "condition" 10 */
condition = 10.0;
beta = 0.2;
tmp = tmp2 = 0;
fAdd = fOpt;
/* BOUNDARY HANDLING */
/* TRANSFORMATION IN SEARCH SPACE */
for (i = 0; i < genomeSize; i++)
{
tmpvect[i] = 0.0;
for (j = 0; j < genomeSize; j++)
{
tmpvect[i] += rotation[i][j] * (genome[j] - xOpt[j]);
}
}
monotoneTFosc(tmpvect);
for (i = 0; i < genomeSize; i++)
{
if (tmpvect[i] > 0)
tmpvect[i] = Math.pow(tmpvect[i], 1 + beta * ((double) i) / ((double) (genomeSize - 1)) * Math.sqrt(tmpvect[i]));
}
for (i = 0; i < genomeSize; i++)
{
tmx[i] = 0.0;
for (j = 0; j < genomeSize; j++)
{
tmx[i] += linearTF[i][j] * tmpvect[j];
}
}
/* COMPUTATION core */
for (i = 0; i < genomeSize; i++)
{
tmp += Math.cos(2. * Math.PI * tmx[i]);
tmp2 += tmx[i] * tmx[i];
}
value = 10. * ((double) genomeSize - tmp) + tmp2;
value += fAdd;
fit = (-value);
((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
break;
case WEIERSTRASS:// f16
/* Weierstrass, condition 100 */
condition = 100.0;
fPen = 0;
fAdd = fOpt;
/* BOUNDARY HANDLING */
for (i = 0; i < genomeSize; i++)
{
tmp = Math.abs(genome[i]) - 5.;
if (tmp > 0.)
{
fPen += tmp * tmp;
}
}
fAdd += 10. / (double) genomeSize * fPen;
/* TRANSFORMATION IN SEARCH SPACE */
for (i = 0; i < genomeSize; i++)
{
tmpvect[i] = 0.0;
for (j = 0; j < genomeSize; j++)
{
tmpvect[i] += rotation[i][j] * (genome[j] - xOpt[j]);
}
}
monotoneTFosc(tmpvect);
for (i = 0; i < genomeSize; i++)
{
tmx[i] = 0.0;
for (j = 0; j < genomeSize; j++)
{
tmx[i] += linearTF[i][j] * tmpvect[j];
}
}
/* COMPUTATION core */
for (i = 0; i < genomeSize; i++)
{
tmp = 0.0;
for (j = 0; j < 12; j++)
{
tmp += Math.cos(2 * Math.PI * (tmx[i] + 0.5) * bK[j]) * aK[j];
}
value += tmp;
}
value = 10. * Math.pow(value / (double) genomeSize - f0, 3.);
value += fAdd;
;
fit = (-value);
((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
break;
case SCHAFFERS_F7:// f17
/*
* Schaffers F7 with asymmetric non-linear transformation, condition
* 10
*/
condition = 10.0;
beta = 0.5;
fAdd = fOpt;
/* BOUNDARY HANDLING */
for (i = 0; i < genomeSize; i++)
{
tmp = Math.abs(genome[i]) - 5.;
if (tmp > 0.)
{
fPen += tmp * tmp;
}
}
fAdd += 10. * fPen;
/* TRANSFORMATION IN SEARCH SPACE */
for (i = 0; i < genomeSize; i++)
{
tmpvect[i] = 0.0;
for (j = 0; j < genomeSize; j++)
{
tmpvect[i] += rotation[i][j] * (genome[j] - xOpt[j]);
}
if (tmpvect[i] > 0)
tmpvect[i] = Math.pow(tmpvect[i], 1 + beta * ((double) i) / ((double) (genomeSize - 1)) * Math.sqrt(tmpvect[i]));
}
for (i = 0; i < genomeSize; i++)
{
tmx[i] = 0.0;
tmp = Math.pow(Math.sqrt(condition), ((double) i) / ((double) (genomeSize - 1)));
for (j = 0; j < genomeSize; j++)
{
tmx[i] += tmp * rot2[i][j] * tmpvect[j];
}
}
/* COMPUTATION core */
for (i = 0; i < genomeSize - 1; i++)
{
tmp = tmx[i] * tmx[i] + tmx[i + 1] * tmx[i + 1];
value += Math.pow(tmp, 0.25) * (Math.pow(Math.sin(50 * Math.pow(tmp, 0.1)), 2.0) + 1.0);
}
value = Math.pow(value / (double) (genomeSize - 1), 2.);
switch (noise)
{
case NONE:
break;
case GAUSSIAN:
value = fGauss(value, 1.0, state.random[threadnum]);
break;
case UNIFORM:
value = fUniform(value, 0.49 + 1.0 / genomeSize, 1.0, state.random[threadnum]);
break;
case CAUCHY:
value = fCauchy(value, 1.0, 0.2, state.random[threadnum]);
break;
default:
String outputStr = "Invalid value for parameter, or parameter not found.\n" + "Acceptable values are:\n";
for (i = 0; i < 4; i++)
outputStr += noiseTypes[i] + "\n";
state.output.fatal(outputStr, new Parameter(P_NOISE));
break;
}
value += fAdd;
fit = (-value);
((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
break;
case SCHAFFERS_F7_2:// f18
/*
* Schaffers F7 with asymmetric non-linear transformation, condition
* 1000
*/
condition = 1e3;
beta = 0.5;
fPen = 0.0;
fAdd = fOpt;
/* BOUNDARY HANDLING */
for (i = 0; i < genomeSize; i++)
{
tmp = Math.abs(genome[i]) - 5.;
if (tmp > 0.)
{
fPen += tmp * tmp;
}
}
fAdd += 10. * fPen;
/* TRANSFORMATION IN SEARCH SPACE */
for (i = 0; i < genomeSize; i++)
{
tmpvect[i] = 0.0;
for (j = 0; j < genomeSize; j++)
{
tmpvect[i] += rotation[i][j] * (genome[j] - xOpt[j]);
}
if (tmpvect[i] > 0)
tmpvect[i] = Math.pow(tmpvect[i], 1. + beta * ((double) i) / ((double) (genomeSize - 1)) * Math.sqrt(tmpvect[i]));
}
for (i = 0; i < genomeSize; i++)
{
tmx[i] = 0.0;
tmp = Math.pow(Math.sqrt(condition), ((double) i) / ((double) (genomeSize - 1)));
for (j = 0; j < genomeSize; j++)
{
tmx[i] += tmp * rot2[i][j] * tmpvect[j];
}
}
/* COMPUTATION core */
for (i = 0; i < genomeSize - 1; i++)
{
tmp = tmx[i] * tmx[i] + tmx[i + 1] * tmx[i + 1];
value += Math.pow(tmp, 0.25) * (Math.pow(Math.sin(50. * Math.pow(tmp, 0.1)), 2.) + 1.);
}
value = Math.pow(value / (double) (genomeSize - 1), 2.);
value += fAdd;
fit = (-value);
((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
break;
case GRIEWANK_ROSENBROCK:// f19
/* F8f2 sum of Griewank-Rosenbrock 2-D blocks */
fAdd = fOpt;
if (noise == NONE)
{
/* TRANSFORMATION IN SEARCH SPACE */
for (i = 0; i < genomeSize; i++)
{
tmx[i] = 0.5;
for (j = 0; j < genomeSize; j++)
{
tmx[i] += linearTF[i][j] * genome[j];
}
}
/* COMPUTATION core */
for (i = 0; i < genomeSize - 1; i++)
{
tmp2 = tmx[i] * tmx[i] - tmx[i + 1];
f2 = 100. * tmp2 * tmp2;
tmp2 = 1 - tmx[i];
f2 += tmp2 * tmp2;
tmp += f2 / 4000. - Math.cos(f2);
}
value = 10. + 10. * tmp / (double) (genomeSize - 1);
}
else
{
/* BOUNDARY HANDLING */
for (i = 0; i < genomeSize; i++)
{
tmp = Math.abs(genome[i]) - 5.0;
if (tmp > 0.0)
{
fPen += tmp * tmp;
}
}
fAdd += 100.0 * fPen;
/* TRANSFORMATION IN SEARCH SPACE */
for (i = 0; i < genomeSize; i++)
{
tmx[i] = 0.5;
for (j = 0; j < genomeSize; j++)
{
tmx[i] += scales * rotation[i][j] * genome[j];
}
}
/* COMPUTATION core */
tmp = 0.;
for (i = 0; i < genomeSize - 1; i++)
{
f2 = 100. * (tmx[i] * tmx[i] - tmx[i + 1]) * (tmx[i] * tmx[i] - tmx[i + 1]) + (1 - tmx[i]) * (1 - tmx[i]);
tmp += f2 / 4000. - Math.cos(f2);
}
value = 1. + 1. * tmp / (double) (genomeSize - 1);
}
switch (noise)
{
case NONE:
break;
case GAUSSIAN:
value = fGauss(value, 1.0, state.random[threadnum]);
break;
case UNIFORM:
value = fUniform(value, 0.49 + 1.0 / genomeSize, 1.0, state.random[threadnum]);
break;
case CAUCHY:
value = fCauchy(value, 1.0, 0.2, state.random[threadnum]);
break;
default:
String outputStr = "Invalid value for parameter, or parameter not found.\n" + "Acceptable values are:\n";
for (i = 0; i < 4; i++)
outputStr += noiseTypes[i] + "\n";
state.output.fatal(outputStr, new Parameter(P_NOISE));
break;
}
value += fAdd;
fit = (-value);
((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
break;
case SCHWEFEL:// f20
/* Schwefel with tridiagonal variable transformation */
condition = 10.0;
fPen = 0.0;
fAdd = fOpt;
/* TRANSFORMATION IN SEARCH SPACE */
for (i = 0; i < genomeSize; i++)
{
tmpvect[i] = 2. * genome[i];
if (xOpt[i] < 0.)
tmpvect[i] *= -1.;
}
tmx[0] = tmpvect[0];
for (i = 1; i < genomeSize; i++)
{
tmx[i] = tmpvect[i] + 0.25 * (tmpvect[i - 1] - 2. * Math.abs(xOpt[i - 1]));
}
for (i = 0; i < genomeSize; i++)
{
tmx[i] -= 2 * Math.abs(xOpt[i]);
tmx[i] *= Math.pow(Math.sqrt(condition), ((double) i) / ((double) (genomeSize - 1)));
tmx[i] = 100. * (tmx[i] + 2 * Math.abs(xOpt[i]));
}
/* BOUNDARY HANDLING */
for (i = 0; i < genomeSize; i++)
{
tmp = Math.abs(tmx[i]) - 500.0;
if (tmp > 0.)
{
fPen += tmp * tmp;
}
}
fAdd += 0.01 * fPen;
/* COMPUTATION core */
for (i = 0; i < genomeSize; i++)
{
value += tmx[i] * Math.sin(Math.sqrt(Math.abs(tmx[i])));
}
value = 0.01 * ((418.9828872724339) - value / (double) genomeSize);
value += fAdd;/* without noise */
fit = (-value);
((SimpleFitness) (ind.fitness)).setFitness(state, fit, fit == 0.0);
break;
case GALLAGHER_GAUSSIAN_101ME:// f21
/*
* Gallagher with 101 Gaussian peaks, condition up to 1000, one
* global rotation
*/
a = 0.1;
fac = -0.5 / (double) genomeSize;
fAdd = fOpt;
/* BOUNDARY HANDLING */
for (i = 0; i < genomeSize; i++)
{
tmp = Math.abs(genome[i]) - 5.;
if (tmp > 0.)
{
fPen += tmp * tmp;
}
}
if (noise == NONE)
fAdd += fPen;
else
fAdd += 100. * fPen;
/* TRANSFORMATION IN SEARCH SPACE */
for (i = 0; i < genomeSize; i++)
{
tmx[i] = 0.0;
for (j = 0; j < genomeSize; j++)
{
tmx[i] += rotation[i][j] * genome[j];
}
}
/* COMPUTATION core */
if (noise == NONE)
for (i = 0; i < NHIGHPEAKS21; i++)
{
tmp2 = 0.0;
for (j = 0; j < genomeSize; j++)
{
tmp = (tmx[j] - xLocal[j][i]);
tmp2 += arrScales[i][j] * tmp * tmp;
}
tmp2 = peakvalues[i] * Math.exp(fac * tmp2);
f = Math.max(f, tmp2);
}
else
/* COMPUTATION core */
for (i = 0; i < NHIGHPEAKS21; i++)
{
tmp2 = 0.;
for (j = 0; j < genomeSize; j++)
{
tmp2 += arrScales[i][j] * (tmx[j] - xLocal[j][i]) * (tmx[j] - xLocal[j][i]);
}
tmp2 = peakvalues[i] * Math.exp(fac * tmp2);
f = Math.max(f, tmp2);
}
f = 10.0 - f;
/* monotoneTFosc */
if (f > 0)
{
value = Math.log(f) / a;
value = Math.pow(Math.exp(value + 0.49 * (Math.sin(value) + Math.sin(0.79 * value))), a);
}
else if (f < 0)
{
value = Math.log(-f) / a;
value = -Math.pow(Math.exp(value + 0.49 * (Math.sin(0.55 * value) + Math.sin(0.31 * value))), a);
}
else
value = f;
value *= value;
switch (noise)
{
case NONE:
break;
case GAUSSIAN:
value = fGauss(value, 1.0, state.random[threadnum]);
break;
case UNIFORM:
value = fUniform(value, 0.49 + 1.0 / genomeSize, 1.0, state.random[threadnum]);
break;
case CAUCHY:
value = fCauchy(value, 1.0, 0.2, state.random[threadnum]);
break;
default:
String outputStr = "Invalid value for parameter, or parameter not found.\n" + "Acceptable values are:\n";
for (i = 0; i < 4; i++)
outputStr += noiseTypes[i] + "\n";
state.output.fatal(outputStr, new Parameter(P_NOISE));
break;
}
value += fAdd;
; /* without noise */