本文整理汇总了Python中Population.Population.best方法的典型用法代码示例。如果您正苦于以下问题:Python Population.best方法的具体用法?Python Population.best怎么用?Python Population.best使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Population.Population
的用法示例。
在下文中一共展示了Population.best方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LilyWriter
# 需要导入模块: from Population import Population [as 别名]
# 或者: from Population.Population import best [as 别名]
(45,4,['to']), (52,4,['mor']), (50,2,['row']), # tomorrow
(47,4,["You're"]), (50,4,['on']), (49,2,['ly']), # you're only
(45,4,['a']), (40,2,['day']), (47,2,['a']), (45,1,['way']) # a day away
]
yesterday_combined = [(tup[0]-4 if tup[0] != 0 else 0,tup[1],tup[2]) for tup in yesterday_combined]
tomorrow = [(tup[0]-4 if tup[0] != 0 else 0,tup[1],tup[2]) for tup in tomorrow]
w = LilyWriter()
p_melody = Population(200,yesterday_combined,tomorrow,(19,88),2,organism_class=SimpleOrganism)
p_melody2 = Population(200,yesterday_combined,tomorrow,(19,88),2,organism_class=SimpleOrganism)
p_melody3 = Population(200,yesterday_combined,tomorrow,(19,88),2,organism_class=SimpleOrganism)
path = []
path += p_melody.best(1)[0].genome
path2 = []
path2 += p_melody2.best(1)[0].genome
path3 = []
path3 += p_melody3.best(1)[0].genome
last_melody_fitness = p_melody.most_fit()
interval = 1
repeats = 0
total_paths = 0
try:
while True:
示例2: LilyWriter
# 需要导入模块: from Population import Population [as 别名]
# 或者: from Population.Population import best [as 别名]
yesterday_combined = [(tup[0]-4 if tup[0] != 0 else 0,tup[1],tup[2]) for tup in yesterday_combined]
tomorrow = [(tup[0]-4 if tup[0] != 0 else 0,tup[1],tup[2]) for tup in tomorrow]
w = LilyWriter()
#sun = helpers.midi_to_combined(helpers.tomorrow)
#yesterday_combined = helpers.midi_to_combined(helpers.yesterday)
#yesterday_combined = helpers.assign_syllables(yesterday_combined,helpers.yesterday_lyrics)
#tomorrow = helpers.assign_syllables(tomorrow,helpers.tomorrow_lyrics)
p_melody = Population(100,yesterday_combined,tomorrow,(19,88),10)
p_melody2 = Population(100,yesterday_combined,tomorrow,(19,88),10)
path = []
path += p_melody.best(1)[0].genome
path2 = []
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:
示例3: Population
# 需要导入模块: from Population import Population [as 别名]
# 或者: from Population.Population import best [as 别名]
#w.write([tomorrow],"output/tomorrow")
#w.write([yesterday_combined],"output/yesterday")
#exit(0)
yesterday_combined = [(tup[0]-4 if tup[0] != 0 else 0,tup[1],tup[2]) for tup in yesterday_combined]
tomorrow = [(tup[0]-4 if tup[0] != 0 else 0,tup[1],tup[2]) for tup in tomorrow]
p_melody = Population(200,None,(yesterday_combined,tomorrow),(1,6),1,organism_class=OperationOrganism)
p_melody2 = Population(200,None,(yesterday_combined,tomorrow),(1,6),1,organism_class=OperationOrganism)
w = LilyWriter()
#w.write(p_melody.best(1)[0].resolve(yesterday,tomorrow),"output/"+str(p_melody.number_of_generations)+".wav")
#w.write(tomorrow,"output/final.wav")
#w.write([yesterday_combined],"output/start")
print yesterday_combined
print p_melody.best(1)[0].resolve(yesterday_combined,tomorrow),"gens:", p_melody.number_of_generations, "melody:",p_melody.most_fit()
print tomorrow
last_fit = 0.0
last_gen = 0
try:
while (p_melody.most_fit() + p_melody2.most_fit()) > 0.02:
print "GEN: ", p_melody.number_of_generations, "\t", "(%.5f,%.5f)" % (p_melody.most_fit(),p_melody2.most_fit()), "\t\t","".join(["|" for i in range(int((p_melody.most_fit() + p_melody2.most_fit())*100))])
p_melody.generation()
p_melody2.generation()
if not last_fit or last_fit - p_melody.most_fit() > 0.02 or p_melody.number_of_generations-last_gen > 100:
last_fit = p_melody.most_fit()
last_gen = p_melody.number_of_generations
#print p_melody.best(1)[0].resolve(yesterday_combined,tomorrow),"gens:", p_melody.number_of_generations, "melody:",p_melody.most_fit(),"level:",p_melody.best(1)[0].fitness_level
#print tomorrow
#print p_melody.summary(5)
#w.write(p_melody.best(1)[0].resolve(yesterday,tomorrow),"output/"+str(p_melody.number_of_generations)+".wav")