jMetal / jMetalPy

A framework for single/multi-objective optimization with metaheuristics
https://jmetal.github.io/jMetalPy/index.html
MIT License
497 stars 150 forks source link

SPXCrossover doesn't work with number of variables > 1 #149

Closed sergiosilvarubio closed 1 year ago

sergiosilvarubio commented 1 year ago

Hi. I did several tests with different numbers of variables and the following always happens:

For example, number of variables = 3 (and number of bits = 8)

Parent 0 [True, True, True, False, False, True, False, False] [False, True, False, True, False, False, False, True] [False, False, True, False, True, True, True, False]

Parent 1 [True, False, True, True, True, False, False, False] [False, True, True, True, True, True, True, False] [False, True, False, True, False, True, True, False]

Offspring 0 [True, True, True, True, True, False, False, False] [False, True, True, True, True, True, True, False] [False, True, False, True, False, True, True, False]

Offspring 1 [True, False, True, False, False, True, False, False] [False, True, False, True, False, False, False, True] [False, False, True, False, True, True, True, False]

Values in bold: Parent 0 and Parent 1 contribute in the first variable of Offspring 0 (Same idea for Offspring 1)

Values in italics: Then the other variables of Parent 0 go to Offspring 1 without any changes.

I would expect that the same logic for creating the first variable applies to others. Is this correct or am I wrong?

ajnebro commented 1 year ago

Hi. The SPXCrossover assumes that all the variables lead to a single bit string (i.e., the bit strings of all the variables are concatenated). Taking this into account, the example you include seems to work as expected.

sergiosilvarubio commented 1 year ago

Hi. The SPXCrossover assumes that all the variables lead to a single bit string (i.e., the bit strings of all the variables are concatenated). Taking this into account, the example you include seems to work as expected.

Thank you for the quick answer, now it's very clear to me. Thank you very much again and great project!