本文整理汇总了Python中Population.Population.regenerate_population方法的典型用法代码示例。如果您正苦于以下问题:Python Population.regenerate_population方法的具体用法?Python Population.regenerate_population怎么用?Python Population.regenerate_population使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Population.Population
的用法示例。
在下文中一共展示了Population.regenerate_population方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_input_data
# 需要导入模块: from Population import Population [as 别名]
# 或者: from Population.Population import regenerate_population [as 别名]
INFILE = arguments['<fichier>']
N, solutions = parse_input_data(INFILE)
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
elif arguments['--generate'] is True:
N = int(arguments['<N>'])
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