I used deap library on Python to work with genetic algorithm. For example: I have individual [0,1,1,1,1,0], I have 3 methods of mutation such as mutation1, mutation2, mutation3. With deap library, I do the mutation as below:
for mutate in [mutate1, mutate2, mutate3]:
mutate(individual)
How can I save the population data after each mutation method? Besides, I'm trying to use deap.logbook
for this but it doesn't work. Anyone have any suggestion about this?
You could open 3 files and in each iteration after each method append the population to correct file.
files = ['path/to/method_1', 'path/to/method_2', 'path/to/method_3']
files_list = [open(i, 'a+') for i in files]
for mutate in range(len([mutate1, mutate2, mutate3])):
mutated = mutate[i](individual)
files[i].write(mutated)