luca-scr / GA

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

GA giving out an error after few iterations #17

Closed kchaitanyabandi closed 5 years ago

kchaitanyabandi commented 6 years ago

Hi,

I'm trying to run GA with a custom fitness function. I'm working with a company and hence cannot give you a reproducible example but I wanted to know when and why does the following error occur ?

Error in ga_nlrSelection_Rcpp(object, q) : Probabilities must be finite and non-negative!

Thanks and Regards Krishna Chaitanya Bandi

luca-scr commented 6 years ago

It seems that when applying the (non linear) selection operator the computed probability of selection is either non-finite or negative. This could be due to my code or to your fitness function. But without a minimal reproducible example is impossible to exactly figure out the problem. You may want to try a different selection operator.

biobiomanu commented 5 years ago

Hi Luca, I am to new to GA but I could run it well. however when i try to optimize parameters it gives also an error after few itérations. For example,I would like to limits the nBits to a fix number, let's say 10 (instead ot total nb of vars, >100). can I do this or there are conflicts ?

grazie mille & best regards Manuela

luca-scr commented 5 years ago

Can you provide a a minimal reproducible example of the error you got? For the second question, I understood that you want to optimise a fitness function where your decision variables are binary and only a subset of them should be set a 1 and 0 the remaining. If this is your problem, I would encode the set of solutions using random-key GAs.

biobiomanu commented 5 years ago

hi, yes, thanks, my decision var is indeed binary. here the msg: Error in { : task 45 failed - "NA in a call to an external function (argument 6)"

I am not sure I will be able to do it with random-key GAs, but I will try. Many thanks anyway

luca-scr commented 5 years ago

This is not a minimal reproducible example (data+code https://en.wikipedia.org/wiki/Minimal_Working_Example), it is simply the error message, which likely is issued by the fitness function you defined.