我已經實現瞭如下的一點交叉; public void onePointCrossover(Individual indi) {
if (SGA.rand.nextDouble() < pc) {
int xoverpoint = SGA.rand.nextInt(length);
int tmp;
for (int i=xoverpoint; i
我在Java中實現統一交叉時遇到問題。這是算法; // Uniform Crossover
public void UniformCrossover(Individual indi) {
if (RVGA.rand.nextDouble() < pc) {
// Put your implementation of uniform crossover here
我一直在嘗試編寫遺傳算法中兩點交叉操作的代碼。首先選擇兩個隨機基因位置。之後,兩條染色體交換它們的基因,這些基因位於稱爲genelocation1和genelocatıon2的隨機數。 for example First Gene [0.3,0.2,0.4,0,0.1,0.5,0.7]
Second Gene [0.25,0.6,0.45,0.15,0.80,0.9,0.85]