luca-scr / GA

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

How to generate population from pre-defined individuals? #39

Closed NamLQ closed 4 years ago

NamLQ commented 4 years ago

Hi!

Suppose I have 100 solutions and have selected the five best ones. How can I generate 50 new individuals from the five best ones with pcrossover = 0.8 and pmutation = 0.1?

Thank you very much!

luca-scr commented 4 years ago

Maybe you want to use arg 'suggestions' in ga() function call.

NamLQ commented 4 years ago

If I use arg suggestions in ga(), the algorithm will calculate the fitness function base on the solutions I gave or the algorithm will generate new individuals and calculate the fitness from the new ones?

luca-scr commented 4 years ago

As described in the help page, the suggested solutions you provide will be included in the initial population, then the fitness function will be evaluated on that solutions and genetic operators applied as usual.

NamLQ commented 4 years ago

I use GA for feature selection in machine learning and the fitness function is time-consuming. So it is better if:

luca-scr commented 4 years ago

I will go with 2nd option and uses memoization to avoid evaluating again the fitness function of already known solutions. See the vignette for an example.