class_docstr: A GSGP class, inherited from GP.
  
  This is the designed class to define GSGP-related
  variables and methods.
  
  References:
      A. Moraglio, K. Krawiec, and C. G. Johnson.
      Geometric semantic genetic programming.
      Lecture Notes in Computer Science (2012).
  
      G. H. de Rosa, J. P. Papa, and L. P. Papa.
      Feature selection using geometric semantic genetic programming.
      Proceedings of the Genetic and Evolutionary Computation Conference Companion (2017).
class_docstr_tok: ["A","GSGP","class",",","inherited","from","GP",".","This","is","the","designed","class","to","define","GSGP-related","variables","and","methods",".","References",":","A.","Moraglio",",","K.","Krawiec",",","and","C.","G.","Johnson",".","Geometric","semantic","genetic","programming",".","Lecture","Notes","in","Computer","Science","(","2012",")",".","G.","H.","de","Rosa",",","J.","P.","Papa",",","and","L.","P.","Papa",".","Feature","selection","using","geometric","semantic","genetic","programming",".","Proceedings","of","the","Genetic","and","Evolutionary","Computation","Conference","Companion","(","2017",")","."]
docstr: Mutates a number of individuals pre-selected through a tournament procedure.
  
  Args:
      space: A TreeSpace object.
docstr_tok: ["Mutates","a","number","of","individuals","pre-selected","through","a","tournament","procedure",".","Args",":","space",":","A","TreeSpace","object","."]
code: def _mutation(self, space: TreeSpace) -> None:
      """Mutates a number of individuals pre-selected through a tournament procedure.
  
      Args:
          space: A TreeSpace object.
  
      """
  
      fitness = [agent.fit for agent in space.agents]
  
      n_individuals = int(space.n_agents * self.p_mutation)
      if n_individuals % 2 != 0:
          n_individuals += 1
  
      selected = g.tournament_selection(fitness, n_individuals)
      for s in selected:
          n_nodes = space.trees[s].n_nodes
          if n_nodes > 1:
              max_nodes = self._prune_nodes(n_nodes)
              space.trees[s] = self._mutate(
                  space.trees[s], space.n_variables, max_nodes
              )
  
file_path: opytimizer/opytimizer/optimizers/evolutionary/gsgp.py
imports: import copy
  from hashlib import sha1
  from typing import Any, Dict, Optional
  import numpy
  import opytimizer.math.general
  import opytimizer.math.random
  from opytimizer.core.node import Node
  from opytimizer.optimizers.evolutionary.gp import GP
  from opytimizer.spaces.tree import TreeSpace
  from opytimizer.utils import logging
label_desc: Use image node_id 2 for calling the GSGP obj's underlying member method code with example usage: obj._mutation(space) without return types