Evolutionary-Optimization-Laboratory / rmoo

An R package for multi/many-objective optimization with non-dominated genetic algorithms' family
GNU General Public License v2.0
29 stars 7 forks source link

crossover fails randomly #1

Closed kaurao closed 3 years ago

kaurao commented 3 years ago

I am trying to optimize a function with 3 objectives and rmoo fails randomly (at some iteration) while creating children.

Error in fitnessChildren[1:2, ] <- fitness[2:1, ] : 
  number of items to replace is not a multiple of replacement length
Called from: crossover(object, parents)
Browse[1]> fitness
         [,1]     [,2] [,3]
[1,] 3.214156 0.000000  1.0
[2,] 3.251013 0.299798  0.5
Browse[1]> fitnessChildren
     [,1] [,2]
[1,]   NA   NA
[2,]   NA   NA
kaurao commented 3 years ago

I think the culprit is line 335 in the file R/geneticoperator.R where the ncol = 2 should be actually the number of objective functions.

fitnessChildren <- matrix(as.double(NA), nrow = 2, ncol = 2)