Question 1: True or false
mediumAI-checkedGenetic AlgorithmsThis is the main loop of the aima-python genetic algorithm. select samples two parents with
fitness-proportionate probability, recombine is one-point crossover, and mutate changes one
gene with probability pmut.
def genetic_algorithm(population, fitness_fn, gene_pool=[0, 1], f_thres=None, ngen=1000, pmut=0.1):
for i in range(ngen):
population = [mutate(recombine(*select(2, population, fitness_fn)), gene_pool, pmut)
for i in range(len(population))]
fittest_individual = fitness_threshold(fitness_fn, f_thres, population)
if fittest_individual:
return fittest_individual
return max(population, key=fitness_fn)
True or false: with this loop, the best fitness in the population can never decrease from one generation to the next.