saealib.DecompositionComparator#

class saealib.DecompositionComparator(decomposition, weights, ideal_point=None, direction=None, *, eps_cv=1e-06, eps_obj=1e-06)[ソース]#

ベースクラス: Comparator

Comparator that ranks solutions by a scalarization (decomposition) score.

Implements MOEA/D-style decomposition: each sub-problem is defined by a weight vector weights and an ideal point ideal_point. The ordering follows the library convention (feasibility first, then score).

Ordering rules:

  1. Infeasible individuals (cv > eps_cv) are always placed after feasible ones, sorted by ascending constraint violation (Deb 2000).

  2. Among feasible individuals, the individual with the lower aggregate score (as returned by decomposition.aggregate) is ranked first.

  3. Two individuals with scores within eps_obj are considered equal.

Direction handling: weights contains non-negative magnitudes only. Sign conventions (minimize vs. maximize) are expressed via direction. Before calling decomposition.aggregate, objectives are transformed as f_min = f * (-direction) so that all objectives are in the minimization frame.

Ideal-point tracking: when ideal_point=None, sort_population computes the per-objective minimum of the feasible set at each call (dynamic tracking). For compare, the pair-wise minimum is used as a local approximation — consistent but not globally optimal.

パラメータ:
  • decomposition (Decomposition) -- Scalarization function (e.g. TchebycheffDecomposition).

  • weights (np.ndarray) -- Non-negative weight vector, shape (n_obj,).

  • ideal_point (np.ndarray or None) -- Reference minimum per objective, shape (n_obj,). None (the default) activates dynamic computation from the population.

  • direction (np.ndarray or None) -- Per-objective optimization direction: +1 = maximize, -1 = minimize. None means minimize all objectives.

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

  • eps_obj (float) -- Score tolerance: differences smaller than this are treated as equal.

参照

[9]: Zhang, Q., & Li, H. (2007). MOEA/D: A multiobjective evolutionary algorithm based on decomposition. IEEE Transactions on Evolutionary Computation, 11(6), 712-731.

[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

Compare two solutions directly without a Population object.

compare_population

Compare two individuals using feasibility rule then aggregate score.

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 aggregate score; infeasible individuals come last.

Method Details

DecompositionComparator.__init__(decomposition, weights, ideal_point=None, direction=None, *, eps_cv=1e-06, eps_obj=1e-06)[ソース]#
パラメータ:
  • decomposition (Decomposition)

  • weights (ndarray)

  • ideal_point (ndarray | None)

  • direction (ndarray | None)

  • eps_cv (float)

  • eps_obj (float)

戻り値の型:

None

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

Compare two solutions directly without a Population object.

When ideal_point was not provided at construction time, the pair-wise minimum min(fa_min, fb_min) is used as a local approximation of the ideal point. This is consistent for pairwise comparison but may differ from sort_population results (which use the population-wide minimum).

パラメータ:
  • fa (np.ndarray) -- Objective vectors, shape (n_obj,).

  • fb (np.ndarray) -- Objective vectors, shape (n_obj,).

  • cv_a (float) -- Constraint violations.

  • cv_b (float) -- Constraint violations.

戻り値:

-1 if a is better, 1 if b is better, 0 if equal.

戻り値の型:

int

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

Compare two individuals using feasibility rule then aggregate score.

Returns -1 if a is better, 1 if b is better, 0 if equal (within eps_obj).

パラメータ:
戻り値の型:

int

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

パラメータ:

problem (Problem) -- The optimization problem.

戻り値:

Empty by default.

戻り値の型:

list[PopulationAttribute]

DecompositionComparator.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).

パラメータ:

population (Population) -- The population to prepare ranking state for.

戻り値の型:

None

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

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

Sort by aggregate score; infeasible individuals come last.

パラメータ:

population (Population) -- The population to sort.

戻り値:

Sorted population indices (int).

戻り値の型:

np.ndarray