当前位置: 首页>>代码示例>>Python>>正文


Python Population.most_fit方法代码示例

本文整理汇总了Python中Population.Population.most_fit方法的典型用法代码示例。如果您正苦于以下问题:Python Population.most_fit方法的具体用法?Python Population.most_fit怎么用?Python Population.most_fit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Population.Population的用法示例。


在下文中一共展示了Population.most_fit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: LilyWriter

# 需要导入模块: from Population import Population [as 别名]
# 或者: from Population.Population import most_fit [as 别名]
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:
        if p_melody.most_fit() > 0.01 or p_melody2.most_fit() > 0.01 or p_melody3.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_melody3.generation()
开发者ID:Delejnr,项目名称:yesterday-tomorrow,代码行数:33,代码来源:super_simple_example.py

示例2: Population

# 需要导入模块: from Population import Population [as 别名]
# 或者: from Population.Population import most_fit [as 别名]
#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:
            #p_melody.generation([p_melody2.best(1)[0].genome])
            p_melody.generation()
            p_melody2.generation()
            #p_melody2.generation([p_melody.best(1)[0].genome])
开发者ID:Delejnr,项目名称:yesterday-tomorrow,代码行数:32,代码来源:simple_example.py

示例3: Population

# 需要导入模块: from Population import Population [as 别名]
# 或者: from Population.Population import most_fit [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")
开发者ID:Delejnr,项目名称:yesterday-tomorrow,代码行数:33,代码来源:thematic_bridge_example.py


注:本文中的Population.Population.most_fit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。