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