code: def main(func, dim, maxfuncevals, ftarget=None):
      toolbox = base.Toolbox()
      toolbox.register("update", update)
      toolbox.register("evaluate", func)
      toolbox.decorate("evaluate", tupleize)
  
      # Create the desired optimal function value as a Fitness object
      # for later comparison
      opt = creator.FitnessMin((ftarget,))
  
      # Interval in which to initialize the optimizer
      interval = -5, 5
      sigma = (interval[1] - interval[0]) / 2.0
      alpha = 2.0 ** (1.0 / dim)
  
      # Initialize best randomly and worst as a place holder
      best = creator.Individual(
          random.uniform(interval[0], interval[1]) for _ in range(dim)
      )
      worst = creator.Individual([0.0] * dim)
  
      # Evaluate the first individual
      best.fitness.values = toolbox.evaluate(best)
  
      # Evolve until ftarget is reached or the number of evaluation
      # is exhausted (maxfuncevals)
      for g in range(1, maxfuncevals):
          toolbox.update(worst, best, sigma)
          worst.fitness.values = toolbox.evaluate(worst)
          if best.fitness <= worst.fitness:
              # Increase mutation strength and swap the individual
              sigma = sigma * alpha
              best, worst = worst, best
          else:
              # Decrease mutation strength
              sigma = sigma * alpha ** (-0.25)
  
          # Test if we reached the optimum of the function
          # Remember that ">" for fitness means better (not greater)
          if best.fitness > opt:
              return best
  
      return best
  
file_path: deap/examples/bbob.py
imports: import array
  import math
  import random
  import time
  from itertools import chain
  from deap import base
  from deap import creator
  import fgeneric
  import bbobbenchmarks
label_desc: Use image node_id 3 for calling a global function with example usage: main(func, dim, maxfuncevals, ftarget) and returns: best, best