def tournament(self,individuals,tourn_size, num_selections=None):
        """conducts tournament selection of size tourn_size"""
        winners = []
        locs = []
        if num_selections is None:
            num_selections = len(individuals)

        for i in np.arange(num_selections):
            # sample pool with replacement
            pool_i = self.random_state.choice(len(individuals),size=tourn_size)
            pool = []
            for i in pool_i:
                pool.append(np.mean(individuals[i].fitness))
            # winner
            locs.append(pool_i[np.argmin(pool)])
            winners.append(copy.deepcopy(individuals[locs[-1]]))

        return winners,locs
def tournament ( self , individuals , tourn_size , num_selections = None ) : winners = [ ] locs = [ ] if num_selections is None : num_selections = len ( individuals ) for i in np . arange ( num_selections ) : pool_i = self . random_state . choice ( len ( individuals ) , size = tourn_size ) pool = [ ] for i in pool_i : pool . append ( np . mean ( individuals [ i ] . fitness ) ) locs . append ( pool_i [ np . argmin ( pool ) ] ) winners . append ( copy . deepcopy ( individuals [ locs [ - 1 ] ] ) ) return winners , locs
conducts tournament selection of size tourn_size