GeneticAlgorithmPython icon indicating copy to clipboard operation
GeneticAlgorithmPython copied to clipboard

Please specify that your library only supports deterministic subject

Open tearfur opened this issue 3 years ago • 2 comments

PyGAD version: 2.16.3

Please specify somewhere in the docs that PyGAD is only geared for deterministic problems, and are not suitable for subjects that will produce different outputs even when given the same inputs, such as games. Or we would very welcome PyGAD to account for stochastic problems in the future.

We had to find out about this ourselves by digging into GA.cal_pop_fitness() to find out that parents kept from the previous generation will directly use the fitness value calculated during the previous generation.

Thank you.

tearfur avatar Apr 20 '22 14:04 tearfur

I am not sure, but it seems like setting keep_parents=0 might be a fix?

martinandrovich avatar Apr 24 '22 22:04 martinandrovich

@tearfur, Thank you.

Thanks @martinandrovich for your suggestion.

By setting:

  1. keep_parents=0
  2. keep_elitism=0
  3. save_solutions=False (Default)

Then you guarantee that no fitness is re-used. This means the fitness function will be called for each single solution in each generation.

ahmedfgad avatar Feb 26 '23 19:02 ahmedfgad