本文整理汇总了Python中Population.Population.getBestChromosome方法的典型用法代码示例。如果您正苦于以下问题:Python Population.getBestChromosome方法的具体用法?Python Population.getBestChromosome怎么用?Python Population.getBestChromosome使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Population.Population
的用法示例。
在下文中一共展示了Population.getBestChromosome方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Population
# 需要导入模块: from Population import Population [as 别名]
# 或者: from Population.Population import getBestChromosome [as 别名]
from time import time
from Population import Population
from settings import settings
p = Population(settings)
best_chromosome = False
best_chromosome_population = 0
t0 = time()
t1 = 0
while True:
temp = p.getBestChromosome()
if best_chromosome == False or temp.rate > best_chromosome.rate:
best_chromosome_population = p.population_number
best_chromosome = temp
if settings['max_populations_amount'] >= 0 and \
p.population_number > settings['max_populations_amount']:
break
if settings['max_chromosome_length'] >= 0 and \
p.chromosome_length > settings['max_chromosome_length']:
break
t1 = time()
if settings['max_time'] >= 0 and t1 - t0 > settings['max_time']:
break
if p.getBestRate() == settings['target_rate']:
break