def nsga2select(population, fitnesses, survivors, allowequality = True):
    fronts = const_non_dominated_sort(population,
                                key=lambda x: fitnesses[x],
                                allowequality = allowequality)
    
    individuals = set()
    for front in fronts:
        remaining = survivors - len(individuals)
        if not remaining > 0:
            break
        if len(front) > remaining:
            # If the current front does not fit in the spots left, use those
            # that have the biggest crowding distance.
            crowd_dist = const_crowding_distance(front, fitnesses)
            front = sorted(front, key=lambda x: crowd_dist[x], reverse=True)
            front = set(front[:remaining])
        individuals |= front

    return list(individuals)
The NSGA-II selection strategy (Deb et al., 2002).
dataset/ETHPy150Open pybrain/pybrain/pybrain/optimization/populationbased/multiobjective/constnsga2.py/nsga2select