本文整理汇总了Python中individual.Individual.mutate方法的典型用法代码示例。如果您正苦于以下问题:Python Individual.mutate方法的具体用法?Python Individual.mutate怎么用?Python Individual.mutate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类individual.Individual
的用法示例。
在下文中一共展示了Individual.mutate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_once
# 需要导入模块: from individual import Individual [as 别名]
# 或者: from individual.Individual import mutate [as 别名]
def run_once(self):
newpop = []
# Elitism, keep the best chromosome to the next generation
newpop = self.population[:3]
for i in range(3, self.popsize):
tmpchrom = Individual(mother=self.__my_choice(), father=self.__my_choice())
tmpchrom.mutate()
newpop.append(tmpchrom)
self.population = newpop
self.evaluate_all()
self.randomize_duplicates()
self.apply_max()
self.evaluate_all()
self.population.sort(key=attrgetter("fitness"), reverse=True)
self.inc_mutation_rate(MUTATION_RATE_INC)
示例2: print
# 需要导入模块: from individual import Individual [as 别名]
# 或者: from individual.Individual import mutate [as 别名]
from individual import Individual
print("an individual")
myInd = Individual()
print(myInd)
print("mutated")
myInd.mutate()
print(myInd)
print("another individual")
myInd2 = Individual()
print(myInd2)
print("Offspring")
offspring = myInd.crossover(myInd2)
print(offspring)
offspring = myInd.crossover(myInd2)
print(offspring)