jmejia8 / Metaheuristics.jl

High-performance metaheuristics for optimization coded purely in Julia.
https://jmejia8.github.io/Metaheuristics.jl/stable/
Other
256 stars 27 forks source link

NSGA2 breaks for odd population size #27

Closed ManuelIndac0 closed 2 years ago

ManuelIndac0 commented 2 years ago

I'm using NSGA2 for solving a multi-objective optimization and I have noticed the code breaks when using an odd value for the population size. Tracking the error, it seems the issue is in the "reproduction" function, line 255 in NSGA2.jl, where the for loop in line 261 populates the Q variable with step 2. However, when doing this while using an odd population size, in the last iteration line 274 throws a bound error. Is it anywhere specified the population size must be even value? (I also must specify I'm fairly new to the evolutionary algorithm field, so I might be wrong in this). If not, I'd suggest add a check to the initial population size input and round it to the next value.

jmejia8 commented 2 years ago

Thank you for reporting this issue. NSGA2 has to work for odd population sizes. This will be fixed in the following release version.

jmejia8 commented 2 years ago

Solved.