def _mutation(self): self.mating_individuals = [ self.Individual( mutate(x, self.dims, self.mutation_rate, self.mutation_eta)) for x in self.mating_individuals ] for ind in self.mating_individuals: ind.known_objectives = False
def generate(self, pop): selected_parents = [x.value for x in random.sample(pop, 2)] child = crossover(selected_parents[0], selected_parents[1], self.dims, self.crossover_rate, self.crossover_eta) return Individual( self.trim_function( mutate(child, self.dims, self.mutation_rate, self.mutation_eta)))
def generate(self, pop): selected_parents = [x.value for x in random.sample(pop, 2)] child = crossover(selected_parents[0], selected_parents[1], self.dims, self.crossover_rate, self.crossover_eta) return Individual(self.trim_function(mutate(child, self.dims, self.mutation_rate, self.mutation_eta)))
def population_generator(self): cost = 0 while True: cost = self.calculate_fitnesses(self.__population, self.__archive) self.__archive = self.environmental_selection( self.__population, self.__archive) self.population = [ self.trim_function( mutate( crossover(self.select(self.__archive), self.select(self.__archive), self.dims, self.crossover_rate, self.crossover_eta), self.dims, self.mutation_rate, self.mutation_eta)) for _ in self.__population ] yield SPEA2ImgaProxy(self, self.__archive, self.__population, cost)
def step(self): self.cost += self.calculate_fitnesses(self.individuals, self.archive) self.archive = self.environmental_selection(self.individuals, self.archive) self.population = [ self.trim_function( mutate( crossover( self.select(self.archive), self.select(self.archive), self.dims, self.crossover_rate, self.crossover_eta, ), self.dims, self.mutation_rate, self.mutation_eta, )) for _ in self.individuals ]
def population_from_delegate(delegate, size, dims, rate, eta): population = [[x for x in delegate]] for _ in range(size - 1): population.append(drivertools.mutate(delegate, dims, rate, eta)) return population
def _mutation(self): self.mating_individuals = [ self.Individual(mutate(x, self.dims, self.mutation_rate, self.mutation_eta)) for x in self.mating_individuals] for ind in self.mating_individuals: ind.known_objectives = False
def _mutation(self): self.mating_individuals = [ Individual( mutate(x, self.dims, self.mutation_rate, self.mutation_eta)) for x in self.mating_individuals ]
def _mutation(self): self.mating_individuals = [ self.Individual(mutate(x, self.dims, self.mutation_rate, self.mutation_eta)) for x in self.mating_individuals]
def mutate(self, xs): return mutate(xs, self.dims, self.mutation_probability, self.mutation_variance)
def population_from_delegate_mutate(delegate, size, dims, rate, eta): population = [[x for x in delegate]] for _ in range(size - 1): population.append(drivertools.mutate(delegate, dims, rate, eta)) return population