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.py
module are moved to thepygad.utils
,pygad.helper
, andpygad.visualize
submodules. - The
pygad.utils.parent_selection
module has a class namedParentSelection
where all the parent selection operators exist. Thepygad.GA
class extends this class. - The
pygad.utils.crossover
module has a class namedCrossover
where all the crossover operators exist. Thepygad.GA
class extends this class. - The
pygad.utils.mutation
module has a class namedMutation
where all the mutation operators exist. Thepygad.GA
class extends this class. - The
pygad.helper.unique
module has a class namedUnique
some helper methods exist to solve duplicate genes and make sure every gene is unique. Thepygad.GA
class extends this class. - The
pygad.visualize.plot
module has a class namedPlot
where all the methods that create plots exist. Thepygad.GA
class 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
logging
module to log the outputs to both the console and text file instead of using theprint()
function. This is by assigning thelogging.Logger
to the newlogger
parameter. Check the [Logging Outputs](https://pygad.readthedocs.io/en/latest/README_pygad_ReadTheDocs.html#logging-outputs) for more information. - A new instance attribute called
logger
to save the logger. - The function/method passed to the
fitness_func
parameter accepts a new parameter that refers to the instance of thepygad.GA
class. 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_population
parameter. - Validate the type and length of the
pop_fitness
parameter 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_val
andrandom_mutation_max_val
) instead of using the parametersinit_range_low
andinit_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_generation
parameter is removed. Use theon_generation
parameter instead. - There was an issue when using the
parallel_processing
parameter 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.float
byfloat
in the 2 parent selection operators roulette wheel and stochastic universal. #168