The genetic flow is implemented in the main() function, as described in the following steps:
- We start the flow by creating the initial population using the populationCreator operator we defined earlier, and the POPULATION_SIZE constant as the argument for this operator. The generationCounter variable, which will be used later on, is initialized here as well:
population = toolbox.populationCreator(n=POPULATION_SIZE)generationCounter = 0
- To calculate the fitness for each individual in the initial population, we use the Python map() function to apply the evaluate operator to each item in the population. As the evaluate operator is an alias for the oneMaxFitness() function, the resulting iterable consists of the calculated ...