class_docstr: An GA class, inherited from Optimizer.
  
  This is the designed class to define GA-related
  variables and methods.
  
  References:
      M. Mitchell. An introduction to genetic algorithms. MIT Press (1998).
class_docstr_tok: ["An","GA","class",",","inherited","from","Optimizer",".","This","is","the","designed","class","to","define","GA-related","variables","and","methods",".","References",":","M.","Mitchell",".","An","introduction","to","genetic","algorithms",".","MIT","Press","(","1998",")","."]
docstr: Wraps Genetic Algorithm over all agents and variables.
  
  Args:
      space: Space containing agents and update-related information.
      function: A Function object that will be used as the objective function.
docstr_tok: ["Wraps","Genetic","Algorithm","over","all","agents","and","variables",".","Args",":","space",":","Space","containing","agents","and","update-related","information",".","function",":","A","Function","object","that","will","be","used","as","the","objective","function","."]
code: def update(self, space: Space, function: Function) -> None:
      """Wraps Genetic Algorithm over all agents and variables.
  
      Args:
          space: Space containing agents and update-related information.
          function: A Function object that will be used as the objective function.
  
      """
  
      new_agents = []
      n_agents = len(space.agents)
  
      fitness = [agent.fit + c.EPSILON for agent in space.agents]
  
      selected = self._roulette_selection(n_agents, fitness)
      for s in g.n_wise(selected):
          alpha, beta = self._crossover(
              space.agents[s[0]], space.agents[s[1]]
          )
          alpha, beta = self._mutation(alpha, beta)
  
          alpha.clip_by_bound()
          beta.clip_by_bound()
  
          alpha.fit = function(alpha.position)
          beta.fit = function(beta.position)
  
          new_agents.extend([alpha, beta])
  
      space.agents += new_agents
      space.agents.sort(key=lambda x: x.fit)
      space.agents = space.agents[:n_agents]
  
imports: import copy
  from typing import Any, Dict, List, Optional, Tuple
  import numpy
  import opytimizer.math.distribution
  import opytimizer.math.general
  import opytimizer.math.random
  import opytimizer.utils.constant
  import opytimizer.utils.exception
  from opytimizer.core import Optimizer
  from opytimizer.core.agent import Agent
  from opytimizer.core.function import Function
  from opytimizer.core.space import Space
  from opytimizer.utils import logging
label_desc: Use image node_id 11 for calling the GA obj's underlying member method code with example usage: obj.update(space, function) without return types