matingpool.parents[i].father = matingpool.randompop();
}
//交叉后创建新的集团
population.clean();
foreach parent in matingpool.parents
{
//注意在copy 双亲的染色体时在某个基因座上发生的变异未表现.
child1 = parent.mother.divheader + parent.father.divend;
child2 = parent.father.divheader + parent.mother.divend;
population.push(child1);
population.push(child2);
}
}
小结:
遗传算法中最重要的过程就是选择和交叉。
选择要能够合理的反映"适者生存"的自然法则,而交叉必须将由利的基因尽量遗传给下一代(这个算法很关键!)