ahmedfgad / GeneticAlgorithmPython

Source code of PyGAD, a Python 3 library for building the genetic algorithm and training machine learning algorithms (Keras & PyTorch).
https://pygad.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.87k stars 462 forks source link

Please specify that your library only supports deterministic subject #100

Open tearfur opened 2 years ago

tearfur commented 2 years ago

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.

martinandrovich commented 2 years ago

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

ahmedfgad commented 1 year ago

@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.