本文整理汇总了Python中Population.Population.print_stats方法的典型用法代码示例。如果您正苦于以下问题:Python Population.print_stats方法的具体用法?Python Population.print_stats怎么用?Python Population.print_stats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Population.Population
的用法示例。
在下文中一共展示了Population.print_stats方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: int
# 需要导入模块: from Population import Population [as 别名]
# 或者: from Population.Population import print_stats [as 别名]
pop_size = int(arguments['<pop_size>'])
solutions = generate_population(N, pop_size)
Pop = Population(N, solutions, XOVER_PROB, MUTATION_PROB)
optimal_solutions = []
iterations = 0
# Genetic algorithm loop starts here
while iterations < MAX_ITER:
print_iterations = 'Iteration=%i' % iterations
Printer(print_iterations)
# create the next generation
next_generation = Pop.build_new_population()
# modify the current population to the new one
Pop.regenerate_population(next_generation)
# increment generations
iterations += 1
outfile_stats = 'output/N%iP%i_%s.txt' % (N, len(solutions), timestamp)
outfile_sols = 'output/solutions_N%iP%i_%s.txt' % (N, len(solutions), timestamp)
Pop.print_stats()
if Pop.optimal_solutions:
print 'Found %i solutions' % len(Pop.optimal_solutions)
for s in Pop.optimal_solutions:
print s
Pop.export_stats(outfile_stats)
Pop.export_optimal_solutions(outfile_sols)