void mutate() {
int i, j;
double lbound, hbound;
double x;
for (i = 0; i < POPSIZE; i++) {
for (j = 0; j < NVARS; j++) {
x = java.lang.Math.random();
if (x < PMUTATION) {
/* find the bounds on the variable to be mutated */
lbound = population[i].lower[j];
hbound = population[i].upper[j];
population[i].gene[j] = randval(lbound, hbound);
}
}
}
}
void report() {
int i;
double best_val; /* best population fitness */
double avg; /* avg population fitness */
double stddev; /* std. deviation of population fitness */
double sum_square; /* sum of square for std. calc */
double square_sum; /* square of sum for std. calc */
double sum; /* total population fitness */
sum = 0.0;
sum_square = 0.0;
for (i = 0; i < POPSIZE; i++) {
sum += population[i].fitness;