class_docstr: An RRA class, inherited from Optimizer.
  
  This is the designed class to define RRA-related
  variables and methods.
  
  References:
      F. Merrikh-Bayat.
      The runner-root algorithm: A metaheuristic for solving unimodal and
      multimodal optimization problems inspired by runners and roots of plants in nature.
      Applied Soft Computing (2015).
class_docstr_tok: ["An","RRA","class",",","inherited","from","Optimizer",".","This","is","the","designed","class","to","define","RRA-related","variables","and","methods",".","References",":","F.","Merrikh-Bayat",".","The","runner-root","algorithm",":","A","metaheuristic","for","solving","unimodal","and","multimodal","optimization","problems","inspired","by","runners","and","roots","of","plants","in","nature",".","Applied","Soft","Computing","(","2015",")","."]
docstr: Wraps Runner-Root 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.
docstr_tok: ["Wraps","Runner-Root","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","."]
code: def update(self, space: Space, function: Function) -> None:
      """Wraps Runner-Root 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.
  
      """
  
      space.agents.sort(key=lambda x: x.fit)
  
      self.last_best_fit = space.agents[0].fit
  
      daughters = copy.deepcopy(space.agents)
      for daughter in daughters[1:]:
          r1 = r.generate_uniform_random_number(-0.5, 0.5)
  
          # Updates the daughter's position and clips its bounds (eq. 2)
          daughter.position += self.d_runner * r1
          daughter.clip_by_bound()
  
          daughter.fit = function(daughter.position)
  
      daughters.sort(key=lambda x: x.fit)
  
      # Checks the new positions' effectiviness (eq. 3)
      effectiveness = np.fabs(
          (self.last_best_fit - daughters[0].fit)
          / (self.last_best_fit + c.EPSILON)
      )
      if effectiveness < self.tol:
          # Performs the stalling large search (eq. 4)
          self._stalling_search(daughters, function, is_large=True)
  
          # Performs the stalling small search (eq. 5)
          self._stalling_search(daughters, function, is_large=False)
  
      # Performs the elite selection (eq. 6)
      space.agents[0] = copy.deepcopy(daughters[0])
  
      daughters_fit = [daughter.fit for daughter in daughters]
      for agent in space.agents[1:]:
          idx = self._roulette_selection(daughters_fit)
          agent = copy.deepcopy(daughters[idx])
  
      # Checks again the positions' effectiviness (eq. 3)
      effectiveness = np.fabs(
          (self.last_best_fit - daughters[0].fit)
          / (self.last_best_fit + c.EPSILON)
      )
      if effectiveness < self.tol:
          self.n_stall += 1
      else:
          self.n_stall = 0
  
      if self.n_stall == self.max_stall:
          for agent in space.agents:
              agent.fill_with_uniform()
  
          self.n_stall = 0
  
imports: import copy
  from typing import Any, Dict, List, Optional
  import numpy
  import opytimizer.math.distribution
  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 16 for calling the RRA obj's underlying member method code with example usage: obj.update(space, function) without return types