我用java写的遗传算法的严重问题,程序没错,但不知道为什么结果总和预想的不同,实在是困惑,请帮忙啊!!!!
源程序如下:
import
java.io.IOException;
import java.io.File;
import java.io.FileReader;
import java.io.*;
public class GeneticAlgorithm {
static int POPSIZE = 5; /* population size */
static int MAXGENS = 5; /* max. number of generations */
static int NVARS = 3; /* no. of problem variables */
static float PXOVER = 0.8f; /* probability of crossover */
static float PMUTATION = 0.3f; /* probability of mutation */
int E = 6;
int T = 120;
int generation; /* current generation no. */
int cur_best; /* best individual */
BufferedReader infile;
FileReader in;
BufferedWriter outfile;
FileWriter out;
Genotype population[];
Genotype newpopulation[];
int p[][][] = { { {0, 1, 1}, {0, 0, 0}, {0, 1, 1}, {0, 0, 0}
}, { {1, 0, 0}, {0, 0, 0}, {1, 0, 0}, {0, 0, 0}
}, { {0, 0, 0}, {0, 1, 1}, {0, 0, 0}, {0, 1, 1}
}, { {0, 0, 0}, {1, 0, 0}, {0, 0, 0}, {1, 0, 0}
}
};
double a[][][] = { { {10, 1, 1}, {10, 2, 4}, {1, 2.3, 1}, {3, 5, 1}
}, { {1, 3, 0.8}, {2, 3, 1.5}, {1, 1, 2}, {2, 0.7, 4}
}, { {2.5, 1.2, 3.4}, {10, 1, 1}, {1, 0.8, 13}, {1.9, 1, 1}
}, { {0.4, 3, 2.3}, {1, 2.1, 4}, {3.2, 1, 0.5}, {1, 1.4, 1.6}
}
};
double u[][][] = { { {2, 1, 1}, {3, 2, 4}, {1, 2.3, 1}, {3, 2, 1}
}, { {1, 3, 0.8}, {2, 3, 1.5}, {1, 1, 0.9}, {2, 0.7, 4}
}, { {0.7, 1.2, 3.4}, {0.5, 1, 1}, {1, 0.8, 0.9}, {1.9, 1, 1}