(population, **args)
return choosen
The Tournament Selector

   It accepts the *tournamentPool* population parameter.

   .. note::
      the Tournament Selector uses the Roulette Wheel to
      pick individuals for the pool

   .. versionchanged:: 0.6
      Changed the parameter `poolSize` to the `tournamentPool`, now the selector
      gets the pool size from the population.
The Tournament Selector
The Tournament Selector
def GTournamentSelector(population, **args):
   """ The Tournament Selector

   It accepts the *tournamentPool* population parameter.

   .. note::
      the Tournament Selector uses the Roulette Wheel to
      pick individuals for the pool

   .. versionchanged:: 0.6
      Changed the parameter `poolSize` to the `tournamentPool`, now the selector
      gets the pool size from the population.

   """
   choosen = None
   should_minimize = population.minimax == Consts.minimaxType["minimize"]
   minimax_operator = min if should_minimize else max

   poolSize = population.getParam("tournamentPool", Consts.CDefTournamentPoolSize)
   tournament_pool = [GRouletteWheel(population, **args) for i in xrange(poolSize)]

   if population.sortType == Consts.sortType["scaled"]:
      choosen = minimax_operator(tournament_pool, key=lambda ind: ind.fitness)
   else:
      choosen = minimax_operator(tournament_pool, key=lambda ind: ind.score)

   return choosen
def GTournamentSelector ( population , * * args ) : choosen = None should_minimize = population . minimax == Consts . minimaxType [ "minimize" ] minimax_operator = min if should_minimize else max poolSize = population . getParam ( "tournamentPool" , Consts . CDefTournamentPoolSize ) tournament_pool = [ GRouletteWheel ( population , * * args ) for i in xrange ( poolSize ) ] if population . sortType == Consts . sortType [ "scaled" ] : choosen = minimax_operator ( tournament_pool , key = lambda ind : ind . fitness ) else : choosen = minimax_operator ( tournament_pool , key = lambda ind : ind . score ) return choosen