3

寻找一种在不同 GA 迭代中重用 50% 的先前种群最佳个体的方法。

例如,在进程内的当前迭代结束时,执行“population = ga.getPopulation()”。下一次迭代初始化该 pop 的 50%。

有谁知道如何处理人口结果?

4

3 回答 3

1

您可以使用该方法setElitismReplacement参见此处)来定义精英主义将使用的个人数量。

于 2013-10-22T11:38:23.143 回答
0

Just for the record. setElitismReplacement would be a good solution in case to specify number of individuals to elitism in 1 GA complete run. In every generation just that number of individuals will be selected for next generation.

What i've meant was in diferent running store best population achieved of all generations and reuse 50% of previous best results to initialize next run.

Anyway an example has been posted.

于 2013-10-23T10:31:14.917 回答
0

应用于此问题的代码片段。

所需功能:

def createOwnGen(self , ga_engine):
        gen = ga_engine.getCurrentGeneration()
        if gen == 0 and self.previous_population != []:
            population = ga_engine.getPopulation()
            popSize = len(population)
            for i in xrange(popSize/2):
                population[popSize/2+i] = self.previous_population[i]
            population.sort()
        return False

stepCallback (来自 pyevolve 的本机函数)在每一代中都被调用。

....
ga.stepCallback.set(self.createOwnGen)
....
bestIndividue = ga.bestIndividual()
population = ga.getPopulation()
self.previous_population = population.internalPop
....
于 2013-10-21T11:05:55.593 回答