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


Python Population.generation方法代码示例

本文整理汇总了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
开发者ID:Delejnr,项目名称:yesterday-tomorrow,代码行数:33,代码来源:simple_example.py


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