luca-scr / GA

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

GA execution fails after some generations #56

Closed Saurajyoti closed 3 years ago

Saurajyoti commented 3 years ago

Hi, thank you for developing the R package. I am implementing the GA with an expensive objective function. The code runs for first handful of generations, but then it gives an environment error: Error in { : task 15 failed - "env must be an environment". It always ends up with this error in windows RStudio. When run on Mac with the Apple silicone, I was successful to get a completed GA run, but error other times. Attached is a screenshot of the error with traceback. Do you have some suggestions for this? Please let me know. Thank you again. error_msg

Saurajyoti commented 3 years ago

Following is the session info. image

luca-scr commented 3 years ago

It looks like an issue with the fitness function. I would start to find the vector of values that produced the error, then I would go step-by-step in the fitness function to see if there is any issue.

Saurajyoti commented 3 years ago

Thanks for the suggestion. I checked the lower and upper bounds of the objective function and it works ok. To make the problem repetitive, I set the seed in the ga() call, and run the function twice. At first run, the error appeared at 16th GA iteration as: Error in { : task 43 failed - "env must be an environment". However, the second time I run the code, the ga() completed its run successfully. Both runs I performed through RStudio, and consecutively after rm(list=ls()). This makes me believe the objective function is working okay, and some error is happening with the environment management during ga()'s parallel calls. However, the problem is not repetitive. Please let me know if you have further suggestions. Thanks.

luca-scr commented 3 years ago

Debug in non parallel mode.

Saurajyoti commented 3 years ago

Thanks very much for your suggestions. I could identify the error that was caused for some invalid values. Now I am able to run the ga(0 without errors.