code: def eaMuCommaLambda(
      population,
      toolbox,
      mu,
      lambda_,
      cxpb,
      mutpb,
      ngen,
      stats=None,
      halloffame=None,
      verbose=__debug__,
  ):
      r"""This is the :math:`(\mu~,~\lambda)` evolutionary algorithm.
  
      :param population: A list of individuals.
      :param toolbox: A :class:`~deap.base.Toolbox` that contains the evolution
                      operators.
      :param mu: The number of individuals to select for the next generation.
      :param lambda\_: The number of children to produce at each generation.
      :param cxpb: The probability that an offspring is produced by crossover.
      :param mutpb: The probability that an offspring is produced by mutation.
      :param ngen: The number of generation.
      :param stats: A :class:`~deap.tools.Statistics` object that is updated
                    inplace, optional.
      :param halloffame: A :class:`~deap.tools.HallOfFame` object that will
                         contain the best individuals, optional.
      :param verbose: Whether or not to log the statistics.
      :returns: The final population
      :returns: A class:`~deap.tools.Logbook` with the statistics of the
                evolution
  
      The algorithm takes in a population and evolves it in place using the
      :func:`varOr` function. It returns the optimized population and a
      :class:`~deap.tools.Logbook` with the statistics of the evolution. The
      logbook will contain the generation number, the number of evaluations for
      each generation and the statistics if a :class:`~deap.tools.Statistics` is
      given as argument. The *cxpb* and *mutpb* arguments are passed to the
      :func:`varOr` function. The pseudocode goes as follow ::
  
          evaluate(population)
          for g in range(ngen):
              offspring = varOr(population, toolbox, lambda_, cxpb, mutpb)
              evaluate(offspring)
              population = select(offspring, mu)
  
      First, the individuals having an invalid fitness are evaluated. Second,
      the evolutionary loop begins by producing *lambda_* offspring from the
      population, the offspring are generated by the :func:`varOr` function. The
      offspring are then evaluated and the next generation population is
      selected from **only** the offspring. Finally, when
      *ngen* generations are done, the algorithm returns a tuple with the final
      population and a :class:`~deap.tools.Logbook` of the evolution.
  
      .. note::
  
          Care must be taken when the lambda:mu ratio is 1 to 1 as a
          non-stochastic selection will result in no selection at all as the
          operator selects *lambda* individuals from a pool of *mu*.
  
  
      This function expects :meth:`toolbox.mate`, :meth:`toolbox.mutate`,
      :meth:`toolbox.select` and :meth:`toolbox.evaluate` aliases to be
      registered in the toolbox. This algorithm uses the :func:`varOr`
      variation.
      """
      assert lambda_ >= mu, "lambda must be greater or equal to mu."
  
      # Evaluate the individuals with an invalid fitness
      invalid_ind = [ind for ind in population if not ind.fitness.valid]
      fitnesses = toolbox.map(toolbox.evaluate, invalid_ind)
      for ind, fit in zip(invalid_ind, fitnesses):
          ind.fitness.values = fit
  
      if halloffame is not None:
          halloffame.update(population)
  
      logbook = tools.Logbook()
      logbook.header = ["gen", "nevals"] + (
          stats.fields if stats else []
      )
  
      record = stats.compile(population) if stats is not None else {}
      logbook.record(gen=0, nevals=len(invalid_ind), **record)
      if verbose:
          print(logbook.stream)
  
      # Begin the generational process
      for gen in range(1, ngen + 1):
          # Vary the population
          offspring = varOr(population, toolbox, lambda_, cxpb, mutpb)
  
          # 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
  
          # Update the hall of fame with the generated individuals
          if halloffame is not None:
              halloffame.update(offspring)
  
          # Select the next generation population
          population[:] = toolbox.select(offspring, mu)
  
          # Update the statistics with the new population
          record = (
              stats.compile(population) if stats is not None else {}
          )
          logbook.record(gen=gen, nevals=len(invalid_ind), **record)
          if verbose:
              print(logbook.stream)
      return population, logbook
  
file_path: deap/deap/algorithms.py
imports: import random
  from .None import tools
label_desc: Use image node_id 5 for calling a global function with example usage: eaMuCommaLambda(population, toolbox, mu, lambda_, cxpb, mutpb, ngen, stats, halloffame, verbose) and returns: population,  logbook