Example #1
0
 def __init__(self):
     """ @param kwargs: See setArgs() method documentation
     """
     SimpleGenomeManipulation.__init__(self)
     self.mutationVariate = GaussianVariate()
     self.mutationVariate.alpha = 0.1
     self.verbosity = 0
Example #2
0
 def __init__(self):
     """ @param kwargs: See setArgs() method documentation
     """
     SimpleGenomeManipulation.__init__(self)
     self.mutationVariate = GaussianVariate()
     self.mutationVariate.alpha = 0.1
     self.verbosity=0
Example #3
0
class SimpleMutation(SimpleGenomeManipulation):
    mutationVariate = None
    """ A simple mutation filter, which uses a gaussian variate per default
        for mutation.
    """
    def __init__(self):
        """ @param 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
            @param population: must implement the getIndividuals() method
        """
        for individual in population.getIndividuals():
            self._mutateIndividual(individual)

    def _mutateIndividual(self, individual):
        """ Mutate a single individual
            @param 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
Example #4
0
class SimpleMutation(SimpleGenomeManipulation):
    mutationVariate = None
    """ A simple mutation filter, which uses a gaussian variate per default
        for mutation.
    """
    def __init__(self):
        """ @param 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
            @param population: must implement the getIndividuals() method
        """
        for individual in population.getIndividuals():
            self._mutateIndividual(individual)

    def _mutateIndividual(self, individual):
        """ Mutate a single individual
            @param 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