code: def main():
      # Differential evolution parameters
      MU = NDIM * 10
      NGEN = 200
  
      pop = toolbox.population(n=MU)
      hof = tools.HallOfFame(1)
      stats = tools.Statistics(lambda ind: ind.fitness.values)
      stats.register("avg", numpy.mean)
      stats.register("std", numpy.std)
      stats.register("min", numpy.min)
      stats.register("max", numpy.max)
  
      logbook = tools.Logbook()
      logbook.header = "gen", "evals", "std", "min", "avg", "max"
  
      # Evaluate the individuals
      fitnesses = toolbox.map(toolbox.evaluate, pop)
      for ind, fit in zip(pop, fitnesses):
          ind.fitness.values = fit
  
      record = stats.compile(pop)
      logbook.record(gen=0, evals=len(pop), **record)
      print(logbook.stream)
  
      for g in range(1, NGEN):
          children = []
          for agent in pop:
              # We must clone everything to ensure independence
              a, b, c = [
                  toolbox.clone(ind) for ind in toolbox.select(pop)
              ]
              x = toolbox.clone(agent)
              y = toolbox.clone(agent)
              y = toolbox.mutate(y, a, b, c)
              z = toolbox.mate(x, y)
              del z.fitness.values
              children.append(z)
  
          fitnesses = toolbox.map(toolbox.evaluate, children)
          for (i, ind), fit in zip(enumerate(children), fitnesses):
              ind.fitness.values = fit
              if ind.fitness > pop[i].fitness:
                  pop[i] = ind
  
          hof.update(pop)
          record = stats.compile(pop)
          logbook.record(gen=g, evals=len(pop), **record)
          print(logbook.stream)
  
      print("Best individual is ", hof[0])
      print("with fitness", hof[0].fitness.values[0])
      return logbook
  
file_path: deap/examples/de/sphere.py
imports: import random
  import array
  import numpy
  from itertools import chain
  from deap import base
  from deap import benchmarks
  from deap import creator
  from deap import tools
label_desc: Use image node_id 4 for calling a global function with example usage: main() and returns: logbook