Hello,
I'm new in EC and Python and I have to work with several algorithms for my thesis project. I'm using DEAP and your nsga2.py example as a guide but I have some doubts about the code. For instance, in line 77 the population (pop) is created and then in lines 80 to 83 different operations are executed to check and/or create the fitness values for each individual.
1) Is verification in line 80 necessary considering that the population was just created and it is known that individuals do not have fitnesses yet and therefore the evaluation must be applied to the entire population)?
2) Can lines 81 to 83 be replaced only for one line with "toolbox.map(toolbox.evaluate, pop)" and to modify the evaluation function to return the individual with the fitness values already inside it?
I thought in something like this:
def evaluation(chromosome):
fitness_1 = # Calculations for objective function 1
fitness_2 = # Calculation for objective function 2
fitness_n = # Calculations for objective function n
chromosome.fitness.values = (fitness_1, fitness_2, fitness_n)
return chromosome
I think the output should be the same as your example code (nsga2.py), but I'm not sure because of my ignorance about Python/NSGA-II) and maybe the example code must be in that way.
Thanks in advance.