genetic-algorithmdeap

Separate mutation probabilities for each part of the solution (Genetic Algorithms)


I am working with the Deap library (Python) for evolutionary computation. I am interested in the following mutation function:

deap.tools.mutGaussian(individual, mu, sigma, indpb)

where indpb, according to documentation, refers to the probability of mutating each solution element.

My question is, how does one specify higher (or lower) mutation probabilities for certain parts of the solution (indices).

With other words, so that the indpb is not a scalar but a vector of solutions.


Solution

  • You most likely need to implement your own mutation function. Perhaps something like the following:

    def mutGaussian(individual, mu, sigma, indpb):
        size = len(individual)
        for i, m, s, p in zip(xrange(size), mu, sigma, indpb):
            if random.random() < p:
                individual[i] += random.gauss(m, s)
    
        return individual,