问题描述
遗传算法是一种元启发式算法。声明是人口每一代都演变成更好(更合适)的解决方案。这是为什么?
我对 AI 还很陌生,但想逐步改进 ;-) 所以请帮助我理解这个算法。
在每次迭代中,都会创建新一代的种群。为什么它会包含一个同样适合或更适合的个人?
Create a population of Individuals
WHILE population does not have the optimal fittest OR not maximum number of generations
call: evoluate the population
print fittest of population
method: evoluate the population
Craete a new population
FOR the number of individuals in the population
Select a fittest individual out of 5 random Individuals
Select a fittest individual out of 5 random Individuals
Store the crossover of these (parent) Individuals in the new population
FOR the number of individuals in the population
mutate the individual
解决方法
它也可能包含一个不太合适的解决方案,以逃避局部最优。这就是为什么也必须记住全局最佳解决方案的原因,除非保证第一个个体能够控制它并存活下来。
,注意:为任何语法错误道歉。
问题:为什么它会包含一个同样适合或更适合的个人?
Ans:假设算法从一定数量(比如 30)的总体(个体/解决方案集)开始,并将运行一定数量(比如 30)代。
- 最初随机或使用适应度函数为每个人提供适应度分数。
- 在每一代中,所有个体都会经历一些步骤(选择、交叉、变异)。在选择步骤中,具有较高适应度值的个体更有可能被选中。在交叉过程中,具有较高适应度值的个体更有可能被选为父母。同样,在变异步骤中。 (注意:概率值用于选择、交叉、变异步骤。) 因此,在下一代中,新种群更有可能比上一代表现更好。
问题:下一个种群是否有可能包含一个不太合适的解决方案?
回答:是的。由于交叉和突变,一些后代(新个体)可能与他们最好的亲代个体(前一个被选择进行交叉/突变的个体)发生很大变化,他们可能不会给出最好的结果。 然而,在每一代人中,个体最终都会变得更好。