0

I want to use more than one mutation method in GP, for example both mutUniform and mutEmphemeral. But all the algorithm can only receive one parameter. Is there method can solve this?

xxyao
  • 529
  • 1
  • 7
  • 16
  • How would you like to use them? Both in succession? Either one or the other? One type of mutation on some genes, another type of mutation on other genes? – usernumber Nov 06 '19 at 10:30

1 Answers1

0

Assuming you have already defined mutUniform and mutEmphemeral, you can define a new mutation function that runs both mutations, and register that new function to your toolbox.

This would look something along the lines of

def mutMyWay(individual, mutpb, uniform_parameters, emphemeral_parameters):
    if random.random()<mutpb:
        individual = mutUniform(individual, *uniform_parameters)
        individual = mutEmphemeral(individual, *emphemeral_parameters)

toolbox.register('mutate', mutMyWay)
usernumber
  • 1,958
  • 1
  • 21
  • 58