Closed RomeroBarata closed 7 years ago
Hi, thanks for your patches.
However, the improvements in speed is really marginal (see attached file) and considering the creation of population is only performed once the overall speed is likely to be not significant. Furthermore, the code is less clear when read.
A real advantage in speed would be achieved if all the functions involved with population creation and genetic operators (selection, crossover, and mutation) are recoded in Rcpp (and renaming the old functions for backward check and compatibility).
Finally, the bug you mention in gaperm_Population() is not clear to me. I have checked but I got the same results...
All the best,
Luca GA_bench.txt
Hi Luca,
I understand your point and indeed the speed improvements in that case will be marginal. Currently I don't have much knowledge of Rcpp, but since I've been really keen to learn it I may be able to help with that at some point.
As for the gaperm_Population() function, this line of code should trigger the bug:
library(GA)
ga(type = "permutation", fitness = function(x) 1, min = 2, max = 5)
and the problem comes from this line:
sample(min:max, size = max, replace = FALSE)
Got it. I have fixed the bug in gaperm_Population() following your suggestion, and some other small glitches. I'm going to push the modifications to version 3.0.999 (the last three digits stands for developing version). About Rcpp isn't very difficult once you have general programming abilities. And working in RStudio make it really easy.
Cool! I'll definitely start studying Rcpp and contribute with the optimised operators as soon as I can.
In the meantime I'll work on some simple bugs I found in the error checking process of ga, and open an issue to discuss with you a problem that I'm having with the number of considered variables for a permutation optimisation problem (just need to prepare a simple example to illustrate it).
Hi,
I rewrote the functions that generate the populations, making them quicker and more concise, and also fixed a bug with the gaperm_Population function (it wasn't working for any value of min > 1).
Kind regards, Romero Morais