class SimpleMutation(SimpleGenomeManipulation): mutationVariate = None """ A simple mutation filter, which uses a gaussian variate per default for mutation. """ def __init__(self): """ :key kwargs: See setArgs() method documentation """ SimpleGenomeManipulation.__init__(self) self.mutationVariate = GaussianVariate() self.mutationVariate.alpha = 0.1 self.verbosity = 0 def apply(self, population): """ Apply the mutation to the population :key population: must implement the getIndividuals() method """ for individual in population.getIndividuals(): self._mutateIndividual(individual) def _mutateIndividual(self, individual): """ Mutate a single individual :key individual: must implement the getGenome() method """ genome = individual.getGenome() self._manipulateGenome(genome) def _manipulateValue(self, value): """ Implementation of the abstract method of class SimpleGenomeManipulation Set's the x0 value of the variate to value and takes a new sample value and returns it. """ self.mutationVariate.x0 = value newval = self.mutationVariate.getSample() # print("MUTATED: ", value, "--->", newval) return newval