class_docstr: An ABO class, inherited from Optimizer.
  
  This is the designed class to define ABO-related
  variables and methods.
  
  References:
      X. Qi, Y. Zhu and H. Zhang. A new meta-heuristic butterfly-inspired algorithm.
      Journal of Computational Science (2017).
class_docstr_tok: ["An","ABO","class",",","inherited","from","Optimizer",".","This","is","the","designed","class","to","define","ABO-related","variables","and","methods",".","References",":","X.","Qi",",","Y.","Zhu","and","H.","Zhang",".","A","new","meta-heuristic","butterfly-inspired","algorithm",".","Journal","of","Computational","Science","(","2017",")","."]
docstr: Wraps Artificial Butterfly 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.
      iteration: Current iteration.
      n_iterations: Maximum number of iterations.
docstr_tok: ["Wraps","Artificial","Butterfly","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",".","iteration",":","Current","iteration",".","n_iterations",":","Maximum","number","of","iterations","."]
code: def update(
      self,
      space: Space,
      function: Function,
      iteration: int,
      n_iterations: int,
  ) -> None:
      """Wraps Artificial Butterfly 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.
          iteration: Current iteration.
          n_iterations: Maximum number of iterations.
  
      """
  
      space.agents.sort(key=lambda x: x.fit)
  
      n_sunspots = int(self.sunspot_ratio * len(space.agents))
      for agent in space.agents[:n_sunspots]:
          k = r.generate_integer_random_number(0, len(space.agents))
  
          # Performs a flight mode using sunspot butterflies (eq. 1)
          agent.position, agent.fit, _ = self._flight_mode(
              agent, space.agents[k], function
          )
  
      for agent in space.agents[n_sunspots:]:
          k = r.generate_integer_random_number(
              0, len(space.agents) - n_sunspots
          )
  
          # Performs a flight mode using canopy butterflies (eq. 1)
          agent.position, agent.fit, is_better = self._flight_mode(
              agent, space.agents[k], function
          )
  
          if not is_better:
              k = r.generate_integer_random_number(0, len(space.agents))
              r1 = r.generate_uniform_random_number()
  
              # Calculates `D` (eq. 4)
              D = np.fabs(
                  2 * r1 * space.agents[k].position - agent.position
              )
  
              r2 = r.generate_uniform_random_number()
  
              # Updates the agent's position (eq. 3)
              a = self.a - self.a * (iteration / n_iterations)
              agent.position = (
                  space.agents[k].position - 2 * a * r2 - a * D
              )
              agent.clip_by_bound()
  
              agent.fit = function(agent.position)
  
file_path: opytimizer/opytimizer/optimizers/swarm/abo.py
imports: import copy
  from typing import Any, Dict, Optional, Tuple
  import numpy
  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 7 for calling the ABO obj's underlying member method code with example usage: obj.update(space, function, iteration, n_iterations) without return types