遗传算法中的锦标赛选择

Far*_*adi 1 genetic-algorithm

我为遗传算法中的锦标赛选择做了这个程序:

从人口中选择k个随机个体,并从这些k个体中选择两个最佳个体作为父母.

这是对的吗?

Set*_*sak 7

赛事选择:

  • 锦标赛选择是一种从个体群体中选择个体的方法。
  • 锦标赛选择涉及在从人群中随机选择的几个个体中运行几个“锦标赛”。
  • 每场比赛的获胜者(身体素质最好的那个)被选中进行交叉。
  • 当锦标赛规模较小时,锦标赛选择也为所有个体提供了被选择的机会,因此它保持了多样性,尽管保持多样性可能会降低收敛速度。
  • 但是如果锦标赛规模较大,弱个体被选中的机会较小,从而导致多样性的丧失。

伪代码:

choose k (the tournament size) individuals from the population at random
choose the best individual from pool/tournament with probability p
choose the second best individual with probability p*(1-p)
choose the third best individual with probability p*((1-p)^2)
and so on...
Run Code Online (Sandbox Code Playgroud)

确定性锦标赛选择在任何锦标赛中选择最佳个人(当 p = 1 时)。单向锦标赛 (k = 1) 选择等效于随机选择。如果需要,可以从进行选择的群体中移除所选择的个体,否则可以多次为下一代选择个体。与(随机)适应度比例选择方法相比,锦标赛选择由于缺乏随机噪声而在实践中经常实施。

MatLab 中的比赛选择:

Matepool=randi(PopLength,PopLength,2);%%select two individuals randomly for tournament and chooose the one with best fitness value
%% number of tournament is equal to the number of population size
for i=1:PopLength
    if Fitness(Matepool(i,1))>= Fitness(Matepool(i,2))
        SelectedPop(i,1:IndLength)=CurrentPop(Matepool(i,1),1:IndLength);
    else
        SelectedPop(i,1:IndLength)=CurrentPop(Matepool(i,2),1:IndLength);
    end
end
Run Code Online (Sandbox Code Playgroud)

  • 很好的复制粘贴维基百科页面 Setu(伪代码部分)。 (2认同)

boz*_*mob 5

考虑到您正在使用健身标准,这里有一个可以帮助您的伪代码.

func tournament_selection(pop, k):
best = null
for i=1 to k
    ind = pop[random(1, N)]
    if (best == null) or fitness(ind) > fitness(best)
        best = ind
return best
Run Code Online (Sandbox Code Playgroud)

所以基本上你所遵循的方法很好.虽然有更多的交叉和东西,我想你已经照顾它了.

具有出色解决方案的参考链接 - 遗传算法中的锦标赛选择


要扩展它,请使用另一个变量'better'.做类似的事情 -

better = best
best = ind
Run Code Online (Sandbox Code Playgroud)

返回时,返回一个对象,这是一对这两个变量.

或者另一种方法是 - 两次调用相同的函数实例,它将返回BEST和BEST-1.代码中需要进行一些调整才能处理Sample.

PS:这可能不是最佳方法.