遗传算法是一种元启发式算法。该算法的核心思想是每一代的种群都会进化成更好的(更适应的)解决方案。为什么会这样呢?
我对AI还比较新手,但希望一步一步地提高;-)所以请帮助我理解这个算法。
在每次迭代中,会创建新一代的种群。为什么新一代会包含一个相同或更适应的个体呢?
Create a population of IndividualsWHILE population does not have the optimal fittest OR not maximum number of generations call: evoluate the populationprint fittest of populationmethod: 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
下一代种群是否可能包含一个适应性较差的解决方案?
回答:
注:对任何语法错误表示歉意。
问:为什么新一代会包含一个相同或更适应的个体?
答:假设算法从一定数量(比如30个)的种群(个体/解决方案集)开始,并将运行一定数量(比如30代)的代数。
- 最初,每个个体被随机赋予一个适应度分数,或者使用适应度函数来评估。
- 在每一代中,所有个体都会经历一些步骤(选择、交叉、变异)。在选择步骤中,适应度值较高的个体更有可能被选中。在交叉过程中,适应度值较高的个体更有可能被选为父本。同样,在变异步骤中也是如此。(注意:在选择、交叉、变异步骤中使用了概率值。)因此,在下一代中,新种群更有可能比上一代表现得更好。
问:下一代种群是否可能包含一个适应性较差的解决方案?
答:是的。由于交叉和变异,一些后代(新个体)可能会与其最佳父本个体(之前选中进行交叉/变异的个体)有很大不同,以至于它们可能无法提供最佳结果。然而,在每一代中,个体的适应性最终会得到改善。