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: Performs a roulette selection on the population (eq. 8).
  
  Args:
      fitness: A fitness list of every agent.
      a: Selection regularizer.
  
  Returns:
      (int): The selected index of the population.
docstr_tok: ["Performs","a","roulette","selection","on","the","population","(","eq",".","8",")",".","Args",":","fitness",":","A","fitness","list","of","every","agent",".","a",":","Selection","regularizer",".","Returns",":","(","int",")",":","The","selected","index","of","the","population","."]
code: def _roulette_selection(
      self, fitness: List[float], a: float = 0.1
  ) -> int:
      """Performs a roulette selection on the population (eq. 8).
  
      Args:
          fitness: A fitness list of every agent.
          a: Selection regularizer.
  
      Returns:
          (int): The selected index of the population.
  
      """
  
      min_fitness = np.min(fitness)
  
      # Re-arrange the list of fitness by inverting it (eq. 7)
      inv_fitness = [1 / (a + fit - min_fitness) for fit in fitness]
      total_fitness = np.sum(inv_fitness)
  
      # Calculates the probability of each inverted fitness (eq. 8)
      probs = [fit / total_fitness for fit in inv_fitness]
      selected = d.generate_choice_distribution(len(probs), probs, 1)
  
      return selected[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 15 for calling the RRA obj's underlying member method code with example usage: obj._roulette_selection(fitness, a) and returns: selected