PyGAD-3.0.0
This release has a major change where the fitness function accepts a mandatory parameter referring to the instance of the pygad.GA class.
This is the release notes:
- The structure of the library is changed and some methods defined in the
pygad.pymodule are moved to thepygad.utils,pygad.helper, andpygad.visualizesubmodules. - The
pygad.utils.parent_selectionmodule has a class namedParentSelectionwhere all the parent selection operators exist. Thepygad.GAclass extends this class. - The
pygad.utils.crossovermodule has a class namedCrossoverwhere all the crossover operators exist. Thepygad.GAclass extends this class. - The
pygad.utils.mutationmodule has a class namedMutationwhere all the mutation operators exist. Thepygad.GAclass extends this class. - The
pygad.helper.uniquemodule has a class namedUniquesome helper methods exist to solve duplicate genes and make sure every gene is unique. Thepygad.GAclass extends this class. - The
pygad.visualize.plotmodule has a class namedPlotwhere all the methods that create plots exist. Thepygad.GAclass extends this class.
...
class GA(utils.parent_selection.ParentSelection,
utils.crossover.Crossover,
utils.mutation.Mutation,
helper.unique.Unique,
visualize.plot.Plot):
...- Support of using the
loggingmodule to log the outputs to both the console and text file instead of using theprint()function. This is by assigning thelogging.Loggerto the newloggerparameter. Check the [Logging Outputs](https://pygad.readthedocs.io/en/latest/README_pygad_ReadTheDocs.html#logging-outputs) for more information. - A new instance attribute called
loggerto save the logger. - The function/method passed to the
fitness_funcparameter accepts a new parameter that refers to the instance of thepygad.GAclass. Check this for an example: [Use Functions and Methods to Build Fitness Function and Callbacks](https://pygad.readthedocs.io/en/latest/README_pygad_ReadTheDocs.html#use-functions-and-methods-to-build-fitness-and-callbacks). #163 - Update the documentation to include an example of using functions and methods to calculate the fitness and build callbacks. Check this for more details: [Use Functions and Methods to Build Fitness Function and Callbacks](https://pygad.readthedocs.io/en/latest/README_pygad_ReadTheDocs.html#use-functions-and-methods-to-build-fitness-and-callbacks). #92 (comment)
- Validate the value passed to the
initial_populationparameter. - Validate the type and length of the
pop_fitnessparameter of thebest_solution()method. - Some edits in the documentation. #106
- Fix an issue when building the initial population as (some) genes have their value taken from the mutation range (defined by the parameters
random_mutation_min_valandrandom_mutation_max_val) instead of using the parametersinit_range_lowandinit_range_high. - The
summary()method returns the summary as a single-line string. Just log/print the returned string it to see it properly. - The
callback_generationparameter is removed. Use theon_generationparameter instead. - There was an issue when using the
parallel_processingparameter with Keras and PyTorch. As Keras/PyTorch are not thread-safe, thepredict()method gives incorrect and weird results when more than 1 thread is used. #145 ahmedfgad/TorchGA#5 ahmedfgad/KerasGA#6. Thanks to this [StackOverflow answer](https://stackoverflow.com/a/75606666/5426539). - Replace
numpy.floatbyfloatin the 2 parent selection operators roulette wheel and stochastic universal. #168