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.84k stars 462 forks source link

Fix a typo in example_custom_operators #285

Closed madprog closed 5 months ago

madprog commented 5 months ago

In the crossover function, the split point is chosen in the range of the offspring size, instead of the solution size.

An out-of-range split point is silently ignored by the range selection: it selects all genes from parent1, and none from parent2. However, the error can be demonstrated by throwing an exception if the split point is out of range.