Artificial intelligence 哪些个体应该在遗传算法中交叉和/或变异?

Artificial intelligence 哪些个体应该在遗传算法中交叉和/或变异?,artificial-intelligence,genetic-algorithm,mutation,crossover,Artificial Intelligence,Genetic Algorithm,Mutation,Crossover,我目前正致力于用Python实现一种遗传算法,这是基于Andries p.Engelbrecht的《计算智能——简介,第二版》一书。我的理解是,每一代人都要进行体能计算、选择、克隆和变异 我目前的总体战略是: while not stopping_criteria(): next_population = [] # Step 1. Calculate Fitness for each individual in population: ca

我目前正致力于用Python实现一种遗传算法,这是基于Andries p.Engelbrecht的《计算智能——简介,第二版》一书。我的理解是,每一代人都要进行
体能计算、选择、克隆和变异

我目前的总体战略是:

while not stopping_criteria():
   next_population = []        

    # Step 1. Calculate Fitness
    for each individual in population:
        calculate_fitness()

    # Step 2. Grab some number of top performers to copy over
    top_performers = ellitism(population, 2) # Grab top 2 for instance
    next_population += top_performers

    # Step 3. Selection/Crossover/Mutation
    # While the next_population has fewer individuals than the current population
    while length(next_population) < length(population):
        # Step 3.1 tournament selection of tournament size 4, top 2
        parent1, parent2 = tournament_selection(population)

        # Step 3.2 Crossover using SBX
        child1, child2 = simulated_binary_crossover(parent1, parent2)

        # Step 3.3 Mutation of children?
        gaussian_mutation(child1, 0.05)
        gaussian_mutation(child2, 0.05)

        next_population += [child1, child2]
在不停止_条件()时:
下一个人口=[]
#第一步。计算适合度
对于人口中的每一个人:
计算_适应度()
#第二步。抓取一些表现最好的人进行复制
表现最好的=椭圆主义(人口,2)#例如,抓住前2名
下一个\u人口+=表现最好的\u
#第三步。选择/交叉/变异
#而下一个群体的个体数比当前群体的个体数少
而长度(下一个_总体)<长度(总体):
#步骤3.1锦标赛选择锦标赛规模4,前2名
parent1,parent2=选择(总体)
#步骤3.2使用SBX交叉
child1,child2=模拟的二进制交叉(parent1,parent2)
#步骤3.3儿童突变?
高斯突变(child1,0.05)
高斯突变(child2,0.05)
下一个_population+=[child1,child2]
我相信我正确地执行了步骤
1-3.1
。我的问题是:

  • 交叉正确吗?这是一个很好的选择比赛的方法吗?我想确保总体人口仍然具有一定的多样性,这样我就可以避免局部最优。这就是为什么我只想把前两名表演者复制过来(尽管,可能也太多了)

  • 关于交叉,给每个孩子一个小概率突变每个基因可以吗?根据当前人群的适应度给出一个可变的突变率会更好吗

  • 我已经在许多方程上测试了我的方法,但发现有时我仍然陷入局部极大值。随着
    f(x,y)=-|2x^2-1.05x^4+((x^6)/6)+xy+y^2 |
    (三峰骆驼函数从)我发现
    (0,0)
    大部分时间,但有时仍然会被卡在它附近。这就是为什么我想知道我的交叉/变异方法是否已经停止