class_docstr: A BWO class, inherited from Optimizer.
  
  This is the designed class to define BWO-related
  variables and methods.
  
  References:
      V. Hayyolalam and A. Kazem.
      Black Widow Optimization Algorithm: A novel meta-heuristic approach
      for solving engineering optimization problems.
      Engineering Applications of Artificial Intelligence (2020).
class_docstr_tok: ["A","BWO","class",",","inherited","from","Optimizer",".","This","is","the","designed","class","to","define","BWO-related","variables","and","methods",".","References",":","V.","Hayyolalam","and","A.","Kazem",".","Black","Widow","Optimization","Algorithm",":","A","novel","meta-heuristic","approach","for","solving","engineering","optimization","problems",".","Engineering","Applications","of","Artificial","Intelligence","(","2020",")","."]
docstr: Wraps Black Widow Optimization 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","Black","Widow","Optimization","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 Black Widow Optimization 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.
  
      """
  
      n_agents = len(space.agents)
      n_variables = space.n_variables
  
      n_reproduct = int(n_agents * self.pp)
      n_cannibals = int(n_agents * self.cr)
      n_mutate = int(n_agents * self.pm)
  
      space.agents.sort(key=lambda x: x.fit)
  
      agents1 = copy.deepcopy(space.agents[:n_reproduct])
      agents2 = []
  
      for _ in range(0, n_reproduct):
          idx = r.generate_uniform_random_number(0, n_agents, size=2)
  
          father, mother = copy.deepcopy(
              space.agents[int(idx[0])]
          ), copy.deepcopy(space.agents[int(idx[1])])
  
          new_agents = []
  
          for _ in range(0, int(n_variables / 2)):
              y1, y2 = self._procreating(father, mother)
  
              y1.clip_by_bound()
              y2.clip_by_bound()
  
              y1.fit = function(y1.position)
              y2.fit = function(y2.position)
  
              new_agents.extend([mother, y1, y2])
  
          new_agents.sort(key=lambda x: x.fit)
  
          # Extending auxiliary population with the number of cannibals (s. 3.3)
          agents2.extend(new_agents[:n_cannibals])
  
      for _ in range(0, n_mutate):
          idx = int(r.generate_uniform_random_number(0, n_reproduct))
  
          alpha = self._mutation(agents1[idx])
          alpha.clip_by_bound()
  
          alpha.fit = function(alpha.position)
  
          agents2.extend([alpha])
  
      space.agents += agents2
      space.agents.sort(key=lambda x: x.fit)
      space.agents = space.agents[:n_agents]
  
imports: import copy
  from typing import Any, Dict, Optional, Tuple
  import opytimizer.math.random
  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 10 for calling the BWO obj's underlying member method code with example usage: obj.update(space, function) without return types