saealib.SPEA2Comparator#

class saealib.SPEA2Comparator(direction=None, *, eps_cv=1e-06, eps_obj=1e-06, dominator=None)[ソース]#

ベースクラス: Comparator

Comparator implementing SPEA2 fitness-based ranking (Zitzler et al., 2001).

SPEA2 fitness F(i) = R(i) + D(i) is computed over the entire feasible set and used as the ranking criterion — lower is better. Because the fitness depends on the whole population, pairwise comparison of two isolated points is undefined.

Ordering rules:

  • Feasible block: the non-dominated subset (F(i) < 1) is ordered by the iterative nearest-neighbour truncation procedure -- see spea2_truncation_order() -- instead of a one-shot sort, so that boundary/extreme solutions are preferentially retained under truncation. The dominated subset (F(i) >= 1) follows, sorted by ascending SPEA2 fitness (lower = better), matching the paper's "fill with the best dominated individuals" branch. See spea2_fitness() for the k = √N density reduction note.

  • Infeasible block: always placed after feasible individuals, ordered by ascending constraint violation (Deb 2000 feasibility rule).

注釈

compare() raises NotImplementedError because SPEA2 fitness is population-relative. Components that require pairwise comparison (e.g. PSO pbest update, PairwiseComparisonSet) should use a ParetoComparator instead. Tournament selection should call compare_population(), which IS defined and safe to use.

パラメータ:
  • direction (np.ndarray or None) -- Per-objective optimization directions (+1 = maximize, -1 = minimize). None defaults to minimization for all objectives.

  • eps_cv (float) -- Feasibility threshold for constraint violation.

  • eps_obj (float) -- Epsilon for objective-value equality (stored for interface compatibility).

  • dominator (Dominator or None) -- Dominance predicate. None defaults to ParetoDominator.

参照

[4]: Zitzler, E., Laumanns, M., & Thiele, L. (2001). SPEA2: Improving the Strength Pareto Evolutionary Algorithm. TIK-Report 103, ETH Zurich.

[10]: Deb, K. (2000). An efficient constraint handling method for genetic algorithms. Computer Methods in Applied Mechanics and Engineering, 186(2-4), 311-338.

Methods

__init__

compare

Raise NotImplementedError — SPEA2 fitness is population-relative.

compare_population

Compare two individuals using constraint-domination then SPEA2 fitness.

get_required_attrs

Declare persistent SPEA2 fitness storage.

prepare_population

Recompute and store SPEA2 fitness for the current population.

rank_population

Prepare population-relative ranking state, then sort.

sort_population

Sort feasible individuals via SPEA2 environmental selection.

Method Details

SPEA2Comparator.__init__(direction=None, *, eps_cv=1e-06, eps_obj=1e-06, dominator=None)[ソース]#
パラメータ:
  • direction (ndarray | None)

  • eps_cv (float)

  • eps_obj (float)

  • dominator (Dominator | None)

SPEA2Comparator.compare(fa, cv_a, fb, cv_b)[ソース]#

Raise NotImplementedError — SPEA2 fitness is population-relative.

パラメータ:
  • fa (ndarray)

  • cv_a (float)

  • fb (ndarray)

  • cv_b (float)

戻り値の型:

int

SPEA2Comparator.compare_population(population, idx_a, idx_b)[ソース]#

Compare two individuals using constraint-domination then SPEA2 fitness.

Returns -1 if a is better, 1 if b is better, 0 if equal. The feasibility rule (Deb 2000) is applied first: feasible individuals always beat infeasible ones. Among both-infeasible pairs, lower constraint violation wins. Among both-feasible pairs, lower SPEA2 fitness wins.

パラメータ:
  • population (Population) -- The population containing both individuals.

  • idx_a (int) -- Index of the first individual.

  • idx_b (int) -- Index of the second individual.

戻り値:

-1, 0, or 1.

戻り値の型:

int

SPEA2Comparator.get_required_attrs(problem)[ソース]#

Declare persistent SPEA2 fitness storage.

パラメータ:

problem (Problem)

戻り値の型:

list[PopulationAttribute]

SPEA2Comparator.prepare_population(population)[ソース]#

Recompute and store SPEA2 fitness for the current population.

パラメータ:

population (Population)

戻り値の型:

None

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

パラメータ:

population (Population) -- The population to rank.

戻り値:

Sorted population indices, as returned by sort_population().

戻り値の型:

np.ndarray

SPEA2Comparator.sort_population(population)[ソース]#

Sort feasible individuals via SPEA2 environmental selection.

Within the feasible block, the non-dominated subset (F(i) < 1) is ordered by spea2_truncation_order() (Zitzler et al. 2001), and the dominated subset (F(i) >= 1) follows, ordered by ascending SPEA2 fitness. Infeasible individuals come last, ordered by ascending constraint violation.

パラメータ:

population (Population) -- The population to sort.

戻り値:

Sorted population indices (int).

戻り値の型:

np.ndarray