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

   This Tournament Selector don't uses the Roulette Wheel

   It accepts the *tournamentPool* population parameter.

   .. versionadded: 0.6
      Added the GTournamentAlternative function.
The alternative Tournament Selector
The alternative Tournament Selector
def GTournamentSelectorAlternative(population, **args):
   """ The alternative Tournament Selector

   This Tournament Selector don't uses the Roulette Wheel

   It accepts the *tournamentPool* population parameter.

   .. versionadded: 0.6
      Added the GTournamentAlternative function.

   """
   pool_size = population.getParam("tournamentPool", Consts.CDefTournamentPoolSize)
   len_pop = len(population)
   should_minimize = population.minimax == Consts.minimaxType["minimize"]
   minimax_operator = min if should_minimize else max
   tournament_pool = [population[random.randint(0, len_pop - 1)] for i in xrange(pool_size)]

   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 GTournamentSelectorAlternative ( population , * * args ) : pool_size = population . getParam ( "tournamentPool" , Consts . CDefTournamentPoolSize ) len_pop = len ( population ) should_minimize = population . minimax == Consts . minimaxType [ "minimize" ] minimax_operator = min if should_minimize else max tournament_pool = [ population [ random . randint ( 0 , len_pop - 1 ) ] for i in xrange ( pool_size ) ] 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