具有奇数个个体的DEAP简易算法

2024-06-13 19:21:09 发布

您现在位置:Python中文网/ 问答频道 /正文

documentation for the eaSimple algorithm表示父母被分成成对的连续个体,每对个体产生两个后代

First, the parental population Pp is duplicated using the toolbox.clone() method and the result is put into the offspring population Po. A first loop over Po is executed to mate pairs of consecutive individuals. According to the crossover probability cxpb, the individuals xi and xi+1 are mated using the toolbox.mate() method. The resulting children yi and yi+1 replace their respective parents in Po.

如何处理奇数个体群体中的最后一个个体?它是否从未与其他个体交配,只是发生了变异


Tags: andthetoisdocumentationtoolboxmethodpo
1条回答
网友
1楼 · 发布于 2024-06-13 19:21:09

the code来看,在人群中存在一个循环,该循环将个体配对以在varAnd中进行交叉:

for i in range(1, len(offspring), 2):

这意味着,如果有奇数个个体,一个个体将永远不会交配

突变的循环是

for i in range(len(offspring)):

所以每个人都会变异

结论:事实上,具有奇数个个体的群体中的最后一个个体可能发生突变,但永远不会用于交叉

相关问题 更多 >