在DEAP 示例(Python 框架)中有一段代码:
# Evaluate the entire population
fitnesses = list(map(toolbox.evaluate, pop))
for ind, fit in zip(pop, fitnesses):
ind.fitness.values = fit
他们为什么使用map
呢for
?为什么不只是:
for ind in pop:
ind.fitness.values = toolbox.evaluate(ind)