class_docstr: An AF class, inherited from Optimizer.
  
  This is the designed class to define AF-related
  variables and methods.
  
  References:
      L. Cheng, W. Xue-han and Y. Wang. Artificial flora (AF) optimization algorithm.
      Applied Sciences (2018).
docstr: Wraps Artificial Flora 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","Artificial","Flora","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 Artificial Flora 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.
  
      """
  
      space.agents.sort(key=lambda x: x.fit)
      new_agents = []
  
      for i, agent in enumerate(space.agents):
          for _ in range(self.m):
              a = copy.deepcopy(agent)
  
              r1 = r.generate_uniform_random_number()
              r2 = r.generate_uniform_random_number()
              r3 = r.generate_uniform_random_number()
  
              # Calculates the new distance (eq. 1)
              distance = (
                  self.g_distance[i] * r1 * self.c1
                  + self.p_distance[i] * r2 * self.c2
              )
  
              D = r.generate_gaussian_random_number(
                  0, distance, (space.n_variables, space.n_dimensions)
              )
  
              # Updates offspring's position (eq. 5)
              a.position += D
              a.clip_by_bound()
  
              a.fit = function(a.position)
  
              # Calculates the probability of selection (eq. 6)
              p = (
                  np.fabs(np.sqrt(a.fit / space.agents[-1].fit))
                  * self.Q
              )
              if r3 < p:
                  new_agents.append(a)
  
          # Updates both grandparent and parent distances (eq. 2 and 3)
          self.g_distance[i] = self.p_distance[i]
          self.p_distance[i] = np.std(agent.position - a.position)
  
      idx = d.generate_choice_distribution(
          len(new_agents), None, space.n_agents
      )
      space.agents = [new_agents[i] for i in idx]
  
imports: import copy
  from typing import Any, Dict, Optional
  import numpy
  import opytimizer.math.distribution
  import opytimizer.math.random
  import opytimizer.utils.exception
  from opytimizer.core import Optimizer
  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 AF obj's underlying member method code with example usage: obj.update(space, function) without return types