Optimize a population of individuals.
    :param population:
    :param toolbox:
    :param mut_prob:
    :param ngen:
    :param archive:
    :param stats:
    :param verbose:
    :param history:
    :return:

def optimize(population, toolbox, ngen, archive=None, stats=None, verbose=False, history=None):
    """
    Optimize a population of individuals.
    :param population:
    :param toolbox:
    :param mut_prob:
    :param ngen:
    :param archive:
    :param stats:
    :param verbose:
    :param history:
    :return:
    """
    start = time.time()
    if history is not None:
        history.update(population)
    logbook = tools.Logbook()
    logbook.header = ['gen', 'nevals', 'cpu_time'] + (stats.fields if stats else [])
    render_fitness(population, toolbox, history)
    record_information(population, stats, start, archive, logbook, verbose)
    for gen in range(1, ngen + 1):
        offspring = generate_next_population(population, toolbox)
        render_fitness(offspring, toolbox, history)
        population = offspring
        record_information(population, stats, start, archive, logbook, verbose)
    return population, logbook, history