saealib.RNSGA2Comparator#

class saealib.RNSGA2Comparator(reference_points, epsilon=0.001, direction=None, *, eps_cv=1e-06, eps_obj=1e-06, sorter=<function non_dominated_sort>, dominator=None)[source]#

Bases: ParetoComparator

Comparator for multi-objective optimization via R-NSGA-II style ranking.

Extends ParetoComparator with reference-point-based secondary ordering:

  • sort_population: non-dominated sorting + reference-point proximity ordering

  • compare_population: overrides ParetoComparator with rank + reference-point distance: lower rank wins, ties broken by smaller distance to the nearest reference point – see compare_population()

The R-NSGA-II selection mechanism (Deb & Sundar 2006):

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

  2. Normalize objectives by range (min-max per objective).

  3. Step 1: for each reference point, compute the normalized Euclidean distance of every individual in the front to that point and rank them ascending (closest = rank 1).

  4. Step 2: each individual’s crowding-distance-equivalent is the minimum of its per-reference-point ranks from Step 1 (smaller = preferred).

  5. Step 3 (ε-clearing): solutions within epsilon of a higher-ranked solution sharing the same nearest reference point are moved to the back of their reference-point group.

Parameters:
  • reference_points (np.ndarray) – Shape (n_ref, n_obj). User-supplied reference points (aspiration points) in the objective space. Unlike NSGA-III, these need not lie on the unit simplex.

  • epsilon (float) – ε-clearing radius in normalized objective space. Solutions within epsilon of a better-ranked solution sharing the same reference point are deprioritized.

  • 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.

References

[8]: Deb, K., & Sundar, J. (2006). Reference Point Based Multi-Objective Optimization Using Evolutionary Algorithms. Proceedings of GECCO 2006, 635-642.

Methods

__init__

compare

Compare two solutions directly without a Population object.

compare_population

Compare via R-NSGA-II operator: rank first, then reference-point distance.

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 reference-point proximity (R-NSGA-II).

Method Details

RNSGA2Comparator.__init__(reference_points, epsilon=0.001, direction=None, *, eps_cv=1e-06, eps_obj=1e-06, sorter=<function non_dominated_sort>, dominator=None)[source]#
Parameters:
  • reference_points (ndarray)

  • epsilon (float)

  • direction (ndarray | None)

  • eps_cv (float)

  • eps_obj (float)

  • sorter (NonDominatedSorter)

  • dominator (Dominator | None)

Return type:

None

RNSGA2Comparator.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

RNSGA2Comparator.compare_population(population, idx_a, idx_b)[source]#

Compare via R-NSGA-II operator: rank first, then reference-point distance.

Lower rank wins; within the same rank, closer to the nearest reference point wins (smaller distance is better, opposite of NSGA-II crowding distance). Infeasibility is handled with the standard constraint- domination rule (Deb 2000).

Parameters:
Return type:

int

RNSGA2Comparator.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]

RNSGA2Comparator.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

RNSGA2Comparator.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

RNSGA2Comparator.sort_population(population)[source]#

Sort by Pareto front rank then reference-point proximity (R-NSGA-II).

Parameters:

population (Population)

Return type:

np.ndarray