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: ParetoComparator

Comparator 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):

  1. Non-dominated sorting (same fronts as NSGA-II).

  2. Normalize objectives over S_t (the fronts accumulated so far, not the full combined population R_t): translate by the ideal point of S_t then scale by hyperplane intercepts computed from extreme points (ASF minimizers) of S_t.

  3. Associate each individual with the nearest reference line (perpendicular distance from the individual to the ray from origin through each reference point).

  4. 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_l selected in the paper), each front is in turn treated as if it were that boundary front: normalization (step 2) is recomputed over S_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 by uniform_weight_vectors().

  • direction (np.ndarray or None) – Per-objective optimization directions (+1 maximize, -1 minimize). None means 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

__init__

compare

Compare two solutions directly without a Population object.

compare_population

Compare via Pareto dominance; -1=a dominates, 1=b dominates, 0=equal.

default_hints

Provide default hints based on reference points.

get_required_attrs

Return population attributes this comparator needs to persist.

prepare_population

Freshly recompute and materialize population-relative ranking state.

rank_population

Prepare population-relative ranking state, then sort.

sort_population

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:
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/cv do not need this. Comparators that declare attributes via get_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 by sort_population(). Callers performing environmental selection on a freshly assembled pool (e.g. survivor selection merging population and offspring) should call this instead of sort_population() directly, so any population-relative state declared via get_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