import random


def _fitness_proportionate_selection(*args):
    """
    Fitness proportionate selection for the genetic algorithm (also called roulette wheel selection).

    This function first normalizes the fitness values (makespan) of the solutions in the population,
    then randomly removes a solution from the population and returns it.

    See https://en.wikipedia.org/wiki/Fitness_proportionate_selection for more info.

    :param args: list where args[0] is the population

    :rtype: Solution
    :returns: a Solution from the population
    """
    fitness_sum = sum(sol.makespan for sol in args[0])
    s = random.uniform(0, fitness_sum)
    partial_sum = 0
    for sol in args[0]:
        partial_sum += sol.makespan
        if partial_sum >= s:
            args[0].remove(sol)
            return sol