luca-scr / GA

An R package for optimization using genetic algorithms
http://luca-scr.github.io/GA/
91 stars 29 forks source link

NaN in vars in fitness function #46

Closed oujbih closed 4 years ago

oujbih commented 4 years ago

I don't know why i get NaN inside vars in fitness function Browse[1]> vars [1] 13.830 46.040 15.120 5.900 15.090 4.020 0.000 0.000 1289.053 234.117 NaN 999.000 NaN NaN 1050.661

GA <- ga(type = "real-valued", fitness = function(vars){
   browser()
  input_test[3:17]=vars
  -predict(object = model_rf_gros,newdata = input_test)
},
  crossover=gabin_uCrossover,
  lower =as.numeric( grid_input_test[1,]),
  upper =as.numeric( grid_input_test[nrow(grid_input_test),]),
  optim = F,
  pmutation = 0.5, # mutation rate prob
  popSize = nrow(grid_input_test) # the number of indivduals/solutions
 )

i used browser to debug the function any suggestions will be appreciated