code: def main(seed=None):
      random.seed(seed)
  
      NGEN = 250
      MU = 100
      CXPB = 0.9
  
      stats = tools.Statistics(lambda ind: ind.fitness.values)
      # stats.register("avg", numpy.mean, axis=0)
      # stats.register("std", numpy.std, axis=0)
      stats.register("min", numpy.min, axis=0)
      stats.register("max", numpy.max, axis=0)
  
      logbook = tools.Logbook()
      logbook.header = "gen", "evals", "std", "min", "avg", "max"
  
      pop = toolbox.population(n=MU)
  
      # Evaluate the individuals with an invalid fitness
      invalid_ind = [ind for ind in pop if not ind.fitness.valid]
      fitnesses = toolbox.map(toolbox.evaluate, invalid_ind)
      for ind, fit in zip(invalid_ind, fitnesses):
          ind.fitness.values = fit
  
      record = stats.compile(pop)
      logbook.record(gen=0, evals=len(invalid_ind), **record)
      print(logbook.stream)
  
      # Begin the generational process
      for gen in range(1, NGEN):
          # Vary the population
          offspring = tools.selRandom(pop, len(pop))
          offspring = [toolbox.clone(ind) for ind in offspring]
  
          for ind1, ind2 in zip(offspring[::2], offspring[1::2]):
              if random.random() <= CXPB:
                  toolbox.mate(ind1, ind2)
  
              toolbox.mutate(ind1)
              toolbox.mutate(ind2)
              del ind1.fitness.values, ind2.fitness.values
  
          # Evaluate the individuals with an invalid fitness
          invalid_ind = [
              ind for ind in offspring if not ind.fitness.valid
          ]
          fitnesses = toolbox.map(toolbox.evaluate, invalid_ind)
          for ind, fit in zip(invalid_ind, fitnesses):
              ind.fitness.values = fit
  
          # Select the next generation population
          pop = pop + offspring
          fronts = toolbox.sort(pop, len(pop))
          chosen = []
          for i, front in enumerate(fronts):
              # Move is front to chosen population til it is almost full
              if len(chosen) + len(front) <= MU:
                  chosen.extend(front)
              else:
                  # Assign hypervolume contribution to individuals of front that
                  # cannot be completely move over to chosen individuals
                  fitness_hv = hypervolume_contrib(front)
                  for ind, fit_hv in zip(front, fitness_hv):
                      ind.fitness_hv.values = (fit_hv,)
                  # Fill chosen with best individuals from inspect front
                  # (based on hypervolume contribution)
                  chosen.extend(toolbox.select(front, MU - len(chosen)))
                  break
  
          pop = chosen
  
          record = stats.compile(pop)
          logbook.record(gen=gen, evals=len(invalid_ind), **record)
          print(logbook.stream)
  
      print(
          "Final population hypervolume is %f"
          % hypervolume(pop, [11.0, 11.0])
      )
  
      return pop, logbook
  
file_path: deap/examples/ga/mo_rhv.py
imports: import array
  import random
  import json
  import numpy
  from math import sqrt
  from deap import algorithms
  from deap import base
  from deap import benchmarks
  from deap.benchmarks.tools import diversity, convergence, hypervolume
  from deap.tools.indicator import hv
  from deap import creator
  from deap import tools
label_desc: Use image node_id 3 for calling a global function with example usage: main(seed) and returns: pop,  logbook