Skip to content

[BUG] Incorrect strength calculation axis in SPEA2Survival._do method #748

@eiro10

Description

@eiro10

Checklist

  • I searched existing issues
  • I'm using the latest pymoo version

Bug Description

In the SPEA2Survival._do method, the calculation of the strength S uses S = (M == 1).sum(axis=0), which counts how many times each individual is dominated by others, instead of how many individuals each dominates. According to the SPEA2 algorithm, S should be computed as S = (M == 1).sum(axis=1) (i.e., summing across rows), so S[i] is the number of solutions dominated by individual i. This could lead to incorrect fitness calculations and selection in the algorithm.

Minimal Code to Reproduce

# Example code snippet for reproduction:
import numpy as np
from pymoo.util.dominator import Dominator
F = np.array([[1,2],[2,3],[3,4]])
M = Dominator().calc_domination_matrix(F)
S_col = (M == 1).sum(axis=0) # current implementation
S_row = (M == 1).sum(axis=1) # correct per SPEA2
print('Current S:', S_col)
print('Correct S:', S_row)

Error Message

Current S: [0 1 2]
Correct S: [2 1 0]
The current S assigns the strength as the number of times an individual is dominated, rather than how many it dominates. This contradicts the original SPEA2 definition and may affect algorithm behavior.

PyMoo & Python Version

Pymoo 0.6.1.5, Python 3.13

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions