我已经用Pyevolve做了一个优化,在查看了结果之后,我想添加一些代以获得更好的收敛性。由于评估时间很长,我想知道是否可以将优化恢复到上一代,并再添加大约20代。我希望一切都在数据库里,这样他才有可能。在
以下是我的GA属性(类似于第一个示例,但具有更复杂的求值函数):
# Genome instance, 1D List of 6 elements
genome = G1DList.G1DList(6)
# Sets the range max and min of the 1D List
genome.setParams(rangemin=1, rangemax=15)
# The evaluator function (evaluation function)
genome.evaluator.set(eval_func)
# Genetic Algorithm Instance
ga=GSimpleGA.GSimpleGA(genome)
# Set the Roulette Wheel selector method, the number of generations and
# the termination criteria
ga.selector.set(Selectors.GRouletteWheel)
ga.setGenerations(50)
ga.setPopulationSize(10)
ga.terminationCriteria.set(GSimpleGA.ConvergenceCriteria)
# Sets the DB Adapter, the resetDB flag will make the Adapter recreate
# the database and erase all data every run, you should use this flag
# just in the first time, after the pyevolve.db was created, you can
# omit it.
sqlite_adapter = DBAdapters.DBSQLite(identify="F-Beam-Optimization", resetDB=True)
ga.setDBAdapter(sqlite_adapter)
# Do the evolution, with stats dump
# frequency of 5 generations
ga.evolve(freq_stats=2)
有人有这个想法吗?在
您好,在查看了Pyevolve的文档之后,似乎没有任何方法可以根据您存储在数据库中的内容(奇怪的行为)来恢复演化。在
如果您想实现这种类型的机制,您可以考虑偶尔对您的种群进行酸洗,然后在Pyevolve中实现整个过程。在
或者,您可以尝试DEAP一个非常开放的框架,它允许您透明地查看和操作进化算法的各个方面。并且已经实现了一些检查点机制。在
下面是您的代码在DEAP中的样子。在
请注意,上述代码尚未测试。但它能满足你的要求。现在如何加载检查点并重新启动演化。在
^{pr2}$此外,DEAP有很好的文档记录,并且有超过25个不同的例子,帮助新用户快速提升,我还听说开发人员对问题的回答非常快。在
相关问题 更多 >
编程相关推荐