本文整理汇总了Python中Population.Population.generation方法的典型用法代码示例。如果您正苦于以下问题:Python Population.generation方法的具体用法?Python Population.generation怎么用?Python Population.generation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Population.Population
的用法示例。
在下文中一共展示了Population.generation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: min
# 需要导入模块: from Population import Population [as 别名]
# 或者: from Population.Population import generation [as 别名]
path2 += p_melody2.best(1)[0].genome
last_melody_fitness = p_melody.most_fit()
interval = 1
repeats = 0
total_paths = 0
try:
while True:
if p_melody.most_fit() > 0.01 or p_melody2.most_fit() > 0.01:
#if p_melody.most_fit() > 0.05:
#p_melody.generation([p_melody2.best(1)[0].genome])
p_melody.generation()
p_melody2.generation()
#p_melody2.generation([p_melody.best(1)[0].genome])
new_melody_fitness = min(p_melody.most_fit(),p_melody2.most_fit())
#new_melody_fitness = p_melody.most_fit()
if new_melody_fitness != last_melody_fitness:
repeats = 0
else:
repeats += 1
if repeats < 1 and (p_melody.number_of_generations % interval == 0 or last_melody_fitness - p_melody.most_fit() > 0.1 or last_melody_fitness - p_melody2.most_fit() > 0.1):
#if repeats < 1 and (p_melody.number_of_generations % interval == 0 or last_melody_fitness - p_melody.most_fit() > 0.1):
total_paths += 1
#print "GEN: ",p_melody.number_of_generations, "FITNESS:",min(p_melody.most_fit(),p_melody2.most_fit()), "||"
print "MIDI GEN: ", total_paths, "\tGEN: ",p_melody.number_of_generations, "\tFITNESS1: %.5f" %p_melody.most_fit(), "\tFITNESS2: %.5f" % p_melody2.most_fit(), "\t","".join(["|" for counter in range(int((p_melody.most_fit() + p_melody2.most_fit())*100))])
if p_melody.number_of_generations > 20:
interval = 5