class_docstr: Class defining mutations, and holding a random state used for random generation.
class_docstr_tok: ["Class","defining","mutations",",","and","holding","a","random","state","used","for","random","generation","."]
docstr: Apply a roulette tournament selection.
docstr_tok: ["Apply","a","roulette","tournament","selection","."]
code: def get_roulette(
      self,
      archive: utils.Archive[utils.MultiValue],
      num: tp.Optional[int] = None,
  ) -> tp.Any:
      """Apply a roulette tournament selection."""
      if num is None:
          num = int(0.999 + np.sqrt(len(archive)))
      # the following sort makes the line deterministic, and function seedable, at the cost of complexity!
      my_keys = sorted(archive.bytesdict.keys())
      my_keys_indices = self.random_state.choice(
          len(my_keys), size=min(num, len(my_keys)), replace=False
      )
      my_keys = [my_keys[i] for i in my_keys_indices]
      # best pessimistic value in a random set of keys
      return np.frombuffer(
          min(
              my_keys,
              key=lambda x: archive.bytesdict[
                  x
              ].pessimistic_confidence_bound,
          )
      )
  
file_path: nevergrad/nevergrad/optimization/mutations.py
imports: import numpy
  import nevergrad.common.typing
  from nevergrad.parametrization import discretization
  from .None import utils
label_desc: Use image node_id 10 for calling the Mutator obj's underlying member method code with example usage: obj.get_roulette(archive, num) and returns: np