class_docstr: A WAOA class, inherited from Optimizer.
  
  This is the designed class to define WAOA-related
  variables and methods.
  
  References:
      P. Trojovský and M. Dehghani. A new bio-inspired metaheuristic algorithm for
      solving optimization problems based on walruses behavior. Scientific Reports (2023).
docstr: Wraps Walrus Optimization 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.
      iteration: Current iteration.
docstr_tok: ["Wraps","Walrus","Optimization","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",".","iteration",":","Current","iteration","."]
code: def update(
      self, space: Space, function: Function, iteration: int
  ) -> None:
      """Wraps Walrus Optimization 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.
          iteration: Current iteration.
  
      """
  
      for i, agent in enumerate(space.agents):
          a = copy.deepcopy(agent)
  
          r1 = r.generate_integer_random_number(
              1, 3, size=(space.n_variables, space.n_dimensions)
          )
          r2 = r.generate_uniform_random_number(
              size=(space.n_variables, space.n_dimensions)
          )
  
          a.position = agent.position + r2 * (
              space.best_agent.position - r1 * agent.position
          )
  
          a.clip_by_bound()
  
          a.fit = function(a.position)
          if a.fit < agent.fit:
              agent.position = copy.deepcopy(a.position)
              agent.fit = copy.deepcopy(a.fit)
  
          k = r.generate_integer_random_number(0, space.n_agents, i)
  
          if space.agents[k].fit < agent.fit:
              r3 = r.generate_integer_random_number(
                  1, 3, size=(space.n_variables, space.n_dimensions)
              )
              r4 = r.generate_uniform_random_number(
                  size=(space.n_variables, space.n_dimensions)
              )
  
              a.position = agent.position + r4 * (
                  space.agents[k].position - r3 * agent.position
              )
  
          else:
              r5 = r.generate_uniform_random_number(
                  size=(space.n_variables, space.n_dimensions)
              )
  
              a.position = agent.position + r5 * (
                  agent.position - space.agents[k].position
              )
  
          a.clip_by_bound()
  
          a.fit = function(a.position)
          if a.fit < agent.fit:
              agent.position = copy.deepcopy(a.position)
              agent.fit = copy.deepcopy(a.fit)
  
          r6 = r.generate_uniform_random_number(
              size=(space.n_variables, space.n_dimensions)
          )
  
          lb = (agent.lb / (iteration + 1)).reshape(-1, 1)
          ub = (agent.ub / (iteration + 1)).reshape(-1, 1)
  
          a.position = agent.position + (lb + (ub - r6 * lb))
  
          a.clip_by_bound()
  
          a.fit = function(a.position)
          if a.fit < agent.fit:
              agent.position = copy.deepcopy(a.position)
              agent.fit = copy.deepcopy(a.fit)
  
file_path: opytimizer/opytimizer/optimizers/swarm/waoa.py
imports: import copy
  import time
  from typing import Any, Dict, Optional
  import numpy
  import opytimizer.math.random
  import opytimizer.utils.logging
  from opytimizer.core.function import Function
  from opytimizer.core.optimizer import Optimizer
  from opytimizer.core.space import Space
label_desc: Use image node_id 3 for calling the WAOA obj's underlying member method code with example usage: obj.update(space, function, iteration) without return types