saealib.NSGA3Comparator#
- class saealib.NSGA3Comparator(reference_points, direction=None, *, eps_cv=1e-06, eps_obj=1e-06, sorter=<function non_dominated_sort>, dominator=None, seed=None)[source]#
Bases:
ParetoComparatorComparator for many-objective optimization via NSGA-III style ranking.
Extends ParetoComparator with reference-point-based niche preservation:
sort_population: non-dominated sorting + normalization + niche preservation
compare_population: inherited from ParetoComparator (Pareto dominance)
The NSGA-III selection mechanism (Deb & Jain 2014):
Non-dominated sorting (same fronts as NSGA-II).
Normalize objectives over
S_t(the fronts accumulated so far, not the full combined populationR_t): translate by the ideal point ofS_tthen scale by hyperplane intercepts computed from extreme points (ASF minimizers) ofS_t.Associate each individual with the nearest reference line (perpendicular distance from the individual to the ray from origin through each reference point).
Order each front using niche-count-based preference: reference points with fewer associated individuals from earlier fronts are preferred; ties broken randomly.
The total ordering returned by sort_population processes all fronts in order, accumulating niche counts across fronts so that earlier fronts’ niche counts propagate to later ones—matching the selection pressure NSGA-III would apply when truncating to a target population size. Because sort_population ranks every front (not only the one boundary front
F_lselected in the paper), each front is in turn treated as if it were that boundary front: normalization (step 2) is recomputed overS_t= the union of fronts processed up to and including the current one.- Parameters:
reference_points (np.ndarray) – Shape
(n_ref, n_obj). Reference points on the unit simplex. Typically generated byuniform_weight_vectors().direction (np.ndarray or None) – Per-objective optimization directions (
+1maximize,-1minimize).Nonemeans all objectives are minimized.eps_cv (float) – Constraint-violation tolerance.
eps_obj (float) – Objective tolerance (passed to base class).
sorter (NonDominatedSorter) – Non-dominated sorting callable.
dominator (Dominator or None) – Dominance predicate.
seed (int or None) – Seed for the random number generator used in niche tie-breaking.
References
[7]: Deb, K., & Jain, H. (2014). An Evolutionary Many-Objective Optimization Algorithm Using Reference-Point-Based Nondominated Sorting Approach, Part I. IEEE Transactions on Evolutionary Computation, 18(4), 577-601.
Methods
Compare two solutions directly without a Population object. |
|
Compare via Pareto dominance; -1=a dominates, 1=b dominates, 0=equal. |
|
Provide default hints based on reference points. |
|
Return population attributes this comparator needs to persist. |
|
Freshly recompute and materialize population-relative ranking state. |
|
Prepare population-relative ranking state, then sort. |
|
Sort by Pareto front rank then NSGA-III niche preservation. |
Method Details
- NSGA3Comparator.__init__(reference_points, direction=None, *, eps_cv=1e-06, eps_obj=1e-06, sorter=<function non_dominated_sort>, dominator=None, seed=None)[source]#
- Parameters:
reference_points (ndarray)
direction (ndarray | None)
eps_cv (float)
eps_obj (float)
sorter (NonDominatedSorter)
dominator (Dominator | None)
seed (int | None)
- Return type:
None
- NSGA3Comparator.compare(fa, cv_a, fb, cv_b)#
Compare two solutions directly without a Population object.
- Parameters:
fa (ndarray)
cv_a (float)
fb (ndarray)
cv_b (float)
- Return type:
int
- NSGA3Comparator.compare_population(population, idx_a, idx_b)#
Compare via Pareto dominance; -1=a dominates, 1=b dominates, 0=equal.
- Parameters:
population (Population)
idx_a (int)
idx_b (int)
- Return type:
int
- NSGA3Comparator.default_hints(ctx)[source]#
Provide default hints based on reference points.
Calculates canonical population size from reference points:
n_population = 4 * ceil(n_ref / 4)This provides the canonical population size for NSGA-III’s reference point layout: a multiple of 4 and at least as large as the number of reference points.
- Parameters:
ctx (DefaultContext) – The default resolution context (unused, but required by protocol).
- Returns:
Hints for population size based on reference points.
- Return type:
tuple[DefaultHint, …]
- NSGA3Comparator.get_required_attrs(problem)#
Return population attributes this comparator needs to persist.
Population-relative ranking state (e.g. SPEA2 fitness) that must survive across selections belongs here as a named, typed attribute rather than in the population’s transient cache. Default: no additional attributes.
- Parameters:
problem (Problem) – The optimization problem.
- Returns:
Empty by default.
- Return type:
list[PopulationAttribute]
- NSGA3Comparator.prepare_population(population)#
Freshly recompute and materialize population-relative ranking state.
Default is a no-op — comparators whose ranking depends only on per-individual values already stored in
f/cvdo not need this. Comparators that declare attributes viaget_required_attrs()should override this to recompute and write those attributes for the given population, unconditionally (not reusing any prior cached value).- Parameters:
population (Population) – The population to prepare ranking state for.
- Return type:
None
- NSGA3Comparator.rank_population(population)#
Prepare population-relative ranking state, then sort.
Equivalent to calling
prepare_population()followed bysort_population(). Callers performing environmental selection on a freshly assembled pool (e.g. survivor selection merging population and offspring) should call this instead ofsort_population()directly, so any population-relative state declared viaget_required_attrs()is recomputed for the new set before ranking.- Parameters:
population (Population) – The population to rank.
- Returns:
Sorted population indices, as returned by
sort_population().- Return type:
np.ndarray
- NSGA3Comparator.sort_population(population)[source]#
Sort by Pareto front rank then NSGA-III niche preservation.
- Parameters:
population (Population)
- Return type:
np.ndarray