Continuous Valued Multimodality Generator for Evolutionary Algorithms
/*
Continuous multimodal test functions coded by James Kennedy
kennedy_jim@bls.gov June 20, 1997, based on William Spears' binary functions.
*/
/*
Here is some code for the continuous-valued multimodal test functions.
These were done in Borland C / C++, and may have functions specific to
that compiler, though I don't think so.
initialization() creates j peaks on i dimensions, uniformly distributed
through the interval [0.0, 1.0]. Of course that interval can be
adjusted easily. I have the function print the variables, too --
optional of course.
multeval(z) evaluates the performance of individual z. In this version,
xx[z][k] is restricted to [0.0, 1.0] with a logistic transformation,
included as sigmoid(). Others may prefer to allow xx[][] to range
wider. The multeval() function returns a value to be minimized, which
is the squared sum of the differences between sigmoid(xx[z][k]) and
landscape[k]; it also writes a global variable, target[], which
indicates which peak the individual was closest to. I use target[] in
my trials to observe the convergence of neighboring individuals on a
single peak.
*/
void initialization()
{
int i, j;
printf("Landscape\n");
for(i = 0; i < NUMBEROFPEAKS; i++)
{
for(j = 0; j < DIMENSION; j++)
{
landscape[i][j] = rand() / 32767.0;
printf("%4.3f ",landscape[i][j]);
}
printf("\n");
}
printf("\nPress any key to continue");
getche();
}
/*
This is the evaluation function. Individuals are
stored in a 2D array xx[][]. This code evaluates the zth
individual xx[z][].
*/
double multeval (z)
int z;
{
int j, k;
double score, temp;
temp = score = (double) DIMENSION;
for (j = 0; j < NUMBEROFPEAKS; j++)
{
score=0.0;
for (k = 0; k < DIMENSION; k++)
{
score = score +
((sigmoid(xx[z][k]) - landscape[j][k]) *
(sigmoid(xx[z][k]) - landscape[j][k]));
}
if (score < temp)
{
temp = score;
target[z]=j;
}
}
return(temp / (double) DIMENSION);
}
float sigmoid(float a)
{
float sig;
sig = 1 / (1 + exp(-a));
return sig;
}
For more information, please contact
William M. Spears.
Last modified: 07/29/99