
Eluding Local
Minima II
149
same time, the valuable gene pool must be protected from wanton
destruction. Thus, the probability of mutation should be tiny. A
subroutine for mutation is shown below:
void mutate (
double *child , // Input/Output of the child
int nvars , // Number of vars in objective function
double stddev , // Standard deviation of mutation
double pmutate // Probability of mutation
)
{
double rn ;
while (nvars-) {
rn = (double) rand 0 / ((double) RANDMAX + 1.0) ;// Random 0-1
if (rn < pmutate) { // Mutate this gene?
rn = (double) randO + (double) randO -
(double) randO - (double) randO ;
child[nvars] +=
rn * stddev * 3.46410161 ...