Exemple #1
0
    def evolution(self):

        population = self.initPopulation(self.populationSize)
        generations = self.numberOfGenerations
        searchDepth = self.searchDepth

        for generation in range(generations):
            print("Generation " + str(generation) + "\n")
            (parents, population) = self.selection(population)
            children = self.crossover(parents)
            population.append(children[0])
            population.append(children[1])
            population = self.mutation(population)
            Organism.pickleOrganisms(population,
                                     'generation' + str(generation) + '.pkl')

        return population