luca-scr / GA

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

Position based crossover for permutation type problems not working as expected. Possible bug found. #18

Closed mick001 closed 6 years ago

mick001 commented 6 years ago

Hi, while using the package and trying to understand the inner workings of each genetic operator used in my application, I found that the function gaperm_pbxCrossover_R doesn't seem to perform any crossover operation due to an indexing error in the for loop.

While I'm not allowed to share an example with the actual data I'm working on, I wrote a simple reproducible example of the issue I found. The only modification I propose is the change of the index -j to j in the indexing of the for loop of the function gaperm_pbxCrossover_R.

You can reproduce the following example in R to take look at the problem if you wish.

luca-scr commented 6 years ago

You are right. Thanks for pointing out and fix. This has been included in the current development release, both for R and C++ version of the genetic operator.