Skip to content

Strength Pareto Evolutionary Algorithm 2 (SPEA2)

An evolutionary method for problems with several objectives.

SPEA2

SPEA2(*, archive_size=None, crossover=None, mutation=None, space='encoded', operators=None, max_archive=None, **kwargs)

Strength Pareto Evolutionary Algorithm 2 (SPEA2).

SPEA2 keeps a population of pop_size solutions and an archive of archive_size. Each iteration:

  1. Fitness: every solution of the population and the archive gets R(i) + D(i), smaller is better. The strength S(i) counts the solutions that i dominates, the raw fitness R(i) adds up the strengths of the solutions that dominate i (0 for a non-dominated one), and the density D(i) = 1 / (sigma_k + 2) uses the distance sigma_k in objective space to the k-th nearest other solution, with k = floor(sqrt(population plus archive size)). D is below 1/2, so a non-dominated solution has a fitness below 1.
  2. Environmental selection: the non-dominated solutions (fitness below 1) form the next archive. When they are too few, the best dominated ones by fitness fill it. When they are too many, the truncation operator removes, one at a time, the solution closest to another one (ties broken by the second closest distance, and so on), which keeps the boundary solutions.
  3. Mating: binary tournaments with replacement on the archive, by fitness, fill the mating pool.
  4. Variation: crossover and mutation of the pool give the next population.

Parameters

  • pop_size: the population size N (default 100)
  • archive_size: the archive size N bar. None (the default) uses pop_size.
  • crossover: ypea.operators.Crossover or None. The default (None) is simulated binary crossover with index 20, SBX(). Its rate 0.9 is the NSGA-II setting, because the report gives none.
  • mutation: ypea.operators.Mutation or None. The default (None) is polynomial mutation, PolynomialMutation() (index 20 and rate 1/n, the NSGA-II settings, because the report gives none).
  • space, operators: native operators, as in NSGAII
  • max_archive: as in NSGAII. It is separate from the algorithm's own archive of archive_size.

Constraints use the problem's rule, constrained domination by default.

Reference: E. Zitzler, M. Laumanns and L. Thiele (2001), SPEA2: Improving the strength Pareto evolutionary algorithm, TIK-Report 103, ETH Zurich.

Example

import ypea
from ypea.benchmarks import pareto_front, zdt1
from ypea.indicators import igd

problem = ypea.Problem(
    ypea.Real("x", shape=30, lb=0, ub=1),
    lambda sol: zdt1(sol.x),
    vectorized=True,
    n_obj=2,
    name="zdt1",
)

alg = ypea.SPEA2(max_nfe=10_000)
result = alg.solve(problem, seed=1)

true_front = pareto_front("zdt1", 500)
score = igd(result.front.obj_values, true_front)
print(len(result.front), score)
163 0.017031707379413015

Differs from Python: MATLAB draws its own random numbers, so the front size and IGD differ from Python's.

problem = ypea.Problem( ...
    vars=ypea.Real("x", shape=30, lb=0, ub=1), ...
    objective=@(sol) ypea.benchmarks.zdt1(sol.x), ...
    vectorized=true, ...
    n_obj=2, ...
    name="zdt1");

alg = ypea.SPEA2(max_nfe=10000);
result = alg.solve(problem, seed=1);

true_front = ypea.benchmarks.pareto_front("zdt1", 500);
score = ypea.indicators.igd(result.front.obj_values, true_front);
fprintf("%d %.17g\n", length(result.front), score)
175 0.020371078120059689

Front on ZDT1

Front found by SPEA2 on ZDT1
SPEA2 with default settings on ZDT1 with 10 variables, 10 000 evaluations (seed 1), a separate run from the example above. Each dot is one solution of result.front, and the dashed line is the true front.