I am using rbga in R, and the following error occurs during what seems to be the part of the function that applies elitism. Here is the session leading up to the error:
Testing the sanity of parameters...
The start conditions:
GA Settings
Type =
Population size = 10
Number of Generations = 10
Elitism = 2
Mutation Chance = 0.00237529691211401
Search Domain
Var 1 = [-0.1,0.1]
Var 2 = [-0.1,0.1]
Var 3 = [-0.1,0.1]
Starting with random values in the given domains...
Starting iteration 1
Calucating evaluation values... .......... done.
Creating next generation...
sorting results...
applying elitism...
Error: subscript out of bounds
Unfortunately, I can't provide a reproducible example as my code consists of around 300 lines, and I can't seem to create simplified version. Has anyone experienced a similar issue when using rbga, and can anyone give me any pointers on why this could be happening ?
Update
I have found the line of code in the rbga function that is causing the error:
newPopulation[1:elitism, ] = sortedPopulation[1:elitism, ]
The length of sortedPopulation at this point is 0, while elitism is 2 ... anyone have any ideas ?
This issue occurred because the evaluation function returned NA, which messed things up in the rbga function. Ensure the evaluation function returns a real value to avoid this error.