本文整理汇总了Python中Population.Population.evolve方法的典型用法代码示例。如果您正苦于以下问题:Python Population.evolve方法的具体用法?Python Population.evolve怎么用?Python Population.evolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Population.Population
的用法示例。
在下文中一共展示了Population.evolve方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: range
# 需要导入模块: from Population import Population [as 别名]
# 或者: from Population.Population import evolve [as 别名]
REPETION_NUMBER = 1
POPULATION_SIZE_DEFAULT = 100
WAIT_FOR_GENERATIONS = True
TYPE = None
SURVIVOR_MODE = Population.SURVIVOR_GENERATION
GENERATION_LIMIT = 10000
tournament_settings = {'size': 20, 'reallocation':True}
if __name__ == '__main__':
generation_per_repetion = []
elite_counter_per_repetion = []
for i in range(REPETION_NUMBER):
pop = Population(POPULATION_SIZE_DEFAULT, 8, WAIT_FOR_GENERATIONS, TYPE, SURVIVOR_MODE, tournament = tournament_settings, generation_limit = GENERATION_LIMIT)
ans = pop.evolve()
bestInd = ans[0]
number_generation = ans[1]
means = ans[2]
elite_counter = ans[3]
selection_pressure = ans[4]
if SURVIVOR_MODE == Population.SURVIVOR_GENERATION:
elite_counter_per_repetion.append(str(2*elite_counter/(number_generation*POPULATION_SIZE_DEFAULT)))
generation_per_repetion.append(str(number_generation*POPULATION_SIZE_DEFAULT))
else:
elite_counter_per_repetion.append(str(elite_counter/number_generation))
generation_per_repetion.append(str(number_generation))
#print(bestInd, bestInd.count_collisions, bestInd.fitness, number_generation)
示例2: Dataset
# 需要导入模块: from Population import Population [as 别名]
# 或者: from Population.Population import evolve [as 别名]
from Population import Population
from Dataset import Dataset
if __name__ == '__main__':
dataset = Dataset()
pop = Population(dataset, 10, 2, dimension_limit=2)
print('Init evolve')
(best, max_fit, mean_fit, elitism_degree, selection_pressure) = pop.evolve()
print(best, best.fitness)
File.save('max_fitness.data', [str(v) for v in max_fit])
File.save('mean_fitness.data', [str(v) for v in mean_fit])
File.save('elitism_degree.data', str(elitism_degree))
File.save('selection_pressure.data', [str(v)for v in selection_pressure])
Fiel.save('AUC.data', str(best.auc))