import random


def binary_tournament_selection(model, population, size):
  """
  Select individual from the population of size
  tourn_size based on tournament evaluation
  :param model: Model used for evaluation
  :param population: Population to sample from
  :param size: Size of tournament
  :return: Most dominant individual from the tournament
  """
  tournament = random.sample(population, size)
  best = tournament[0]
  for i in range(1, len(tournament)):
    if model.better(tournament[i], best) == 1:
      best = tournament[i]
  return best