Perform truncated selection with elitism.
    :param individuals:
    :param toolbox:
    :return:

def generate_next_population(individuals, toolbox):
    """
    Perform truncated selection with elitism.
    :param individuals:
    :param toolbox:
    :return:
    """
    individuals = [toolbox.clone(ind) for ind in individuals]
    individuals.sort(key=lambda x: x.error)

    offspring = []
    pop_size = len(individuals)
    num_top = math.floor(pop_size / 2)
    parents = individuals[0:num_top + 1]
    for _ in range(pop_size - 1):
        off = toolbox.clone(random.choice(parents))
        off = toolbox.mutate(off)[0]
        offspring.append(off)
    offspring.append(individuals[0])
    return offspring