eckity.population
1class Population: 2 """ 3 Population of individuals to be evolved in the evolutionary run. 4 5 Parameters 6 ---------- 7 sub_populations: list of Subpopulations 8 subpopulations contained in the population. 9 For more information, see eckity.subpopulation. 10 """ 11 12 def __init__(self, sub_populations): 13 self.sub_populations = sub_populations 14 15 def create_population_individuals(self): 16 for sub_pop in self.sub_populations: 17 sub_pop.create_subpopulation_individuals() 18 19 def find_individual_subpopulation(self, individual): 20 for sub_pop in self.sub_populations: 21 if sub_pop.contains_individual(individual): 22 return sub_pop 23 raise ValueError( 24 "The given individual was not found in any sub-population." 25 "It probably belongs to a previous generation population." 26 ) 27 28 def get_best_individuals(self): 29 return [ 30 sub_pop.get_best_individual() for sub_pop in self.sub_populations 31 ] 32 33 def get_worst_individuals(self): 34 return [ 35 sub_pop.get_worst_individual() for sub_pop in self.sub_populations 36 ] 37 38 def get_average_fitness(self): 39 return [ 40 sub_pop.get_average_fitness() for sub_pop in self.sub_populations 41 ]
class
Population:
2class Population: 3 """ 4 Population of individuals to be evolved in the evolutionary run. 5 6 Parameters 7 ---------- 8 sub_populations: list of Subpopulations 9 subpopulations contained in the population. 10 For more information, see eckity.subpopulation. 11 """ 12 13 def __init__(self, sub_populations): 14 self.sub_populations = sub_populations 15 16 def create_population_individuals(self): 17 for sub_pop in self.sub_populations: 18 sub_pop.create_subpopulation_individuals() 19 20 def find_individual_subpopulation(self, individual): 21 for sub_pop in self.sub_populations: 22 if sub_pop.contains_individual(individual): 23 return sub_pop 24 raise ValueError( 25 "The given individual was not found in any sub-population." 26 "It probably belongs to a previous generation population." 27 ) 28 29 def get_best_individuals(self): 30 return [ 31 sub_pop.get_best_individual() for sub_pop in self.sub_populations 32 ] 33 34 def get_worst_individuals(self): 35 return [ 36 sub_pop.get_worst_individual() for sub_pop in self.sub_populations 37 ] 38 39 def get_average_fitness(self): 40 return [ 41 sub_pop.get_average_fitness() for sub_pop in self.sub_populations 42 ]
Population of individuals to be evolved in the evolutionary run.
Parameters
- sub_populations (list of Subpopulations): subpopulations contained in the population. For more information, see eckity.subpopulation.
def
find_individual_subpopulation(self, individual):
20 def find_individual_subpopulation(self, individual): 21 for sub_pop in self.sub_populations: 22 if sub_pop.contains_individual(individual): 23 return sub_pop 24 raise ValueError( 25 "The given individual was not found in any sub-population." 26 "It probably belongs to a previous generation population." 27 )