class_docstr: A KH class, inherited from Optimizer.
  
  This is the designed class to define KH-related
  variables and methods.
  
  References:
      A. Gandomi and A. Alavi. Krill herd: A new bio-inspired optimization algorithm.
      Communications in Nonlinear Science and Numerical Simulation (2012).
docstr: Wraps motion and genetic updates 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.
      iteration: Current iteration.
      n_iterations: Maximum number of iterations.
docstr_tok: ["Wraps","motion","and","genetic","updates","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",".","iteration",":","Current","iteration",".","n_iterations",":","Maximum","number","of","iterations","."]
code: def update(
      self,
      space: Space,
      function: Function,
      iteration: int,
      n_iterations: int,
  ) -> None:
      """Wraps motion and genetic updates 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.
          iteration: Current iteration.
          n_iterations: Maximum number of iterations.
  
      """
  
      space.agents.sort(key=lambda x: x.fit)
  
      # Calculates the food location (eq. 12)
      food = self._food_location(space.agents, function)
  
      for i, _ in enumerate(space.agents):
          space.agents[i].position = self._update_position(
              space.agents,
              i,
              iteration,
              n_iterations,
              food,
              self.motion[i],
              self.foraging[i],
          )
  
          space.agents[i] = self._crossover(space.agents, i)
          space.agents[i] = self._mutation(space.agents, i)
  
imports: import copy
  from typing import Any, Dict, List, Optional, Tuple
  import numpy
  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 38 for calling the KH obj's underlying member method code with example usage: obj.update(space, function, iteration, n_iterations) without return types