Releases: ahmedfgad/GeneticAlgorithmPython
PyGAD-2.14.3
Some bug fixes when setting the save_best_solutions parameter to True. Previously, the best solution for generation i was added into the best_solutions attribute at generation i+1. Now, the best_solutions attribute is updated by each solution at its exact generation.
PyGAD-2.14.2
Some bug fixes when the gene_type parameter is nested. Thanks to Rainer Engel for opening a discussion to report this bug: #43 (reply in thread)
Rainer Engel helped a lot in suggesting new features and suggesting enhancements in 2.14.0 to 2.14.2 releases.
PyGAD-2.14.1
- Issue #40 is solved. Now, the
Nonevalue works with thecrossover_typeandmutation_typeparameters: #40 - The
gene_typeparameter supports accepting alist/tuple/numpy.ndarrayof numeric data types for the genes. This helps to control the data type of each individual gene. Previously, thegene_typecan be assigned only to a single data type that is applied for all genes. - A new
boolattribute namedgene_type_singleis added to thepygad.GAclass. It isTruewhen there is a single data type assigned to thegene_typeparameter. When thegene_typeparameter is assigned alist/tuple/numpy.ndarray, thengene_type_singleis set toFalse. - The
mutation_by_replacementflag now has no effect ifgene_spaceexists except for the genes withNonevalues. For example, forgene_space=[None, [5, 6]]themutation_by_replacementflag affects only the first gene which hasNonefor its value space. - When an element has a value of
Nonein thegene_spaceparameter (e.g.gene_space=[None, [5, 6]]), then its value will be randomly generated for each solution rather than being generate once for all solutions. Previously, the gene withNonevalue ingene_spaceis the same across all solutions - Some changes in the documentation according to issue #32: #32
PyGAD-2.13.0
PyGAD 2.13.0
Release Date: 12 March 2021
- A new
boolparameter calledallow_duplicate_genesis supported. IfTrue, which is the default, then a solution/chromosome may have duplicate gene values. IfFalse, then each gene will have a unique value in its solution. Check the Prevent Duplicates in Gene Values section for more details. - The
last_generation_fitnessis updated at the end of each generation not at the beginning. This keeps the fitness values of the most up-to-date population assigned to thelast_generation_fitnessparameter.
PyGAD-2.12.0
Release Date: 20 February 2021
- 4 new instance attributes are added to hold temporary results after each generation:
last_generation_fitnessholds the fitness values of the solutions in the last generation,last_generation_parentsholds the parents selected from the last generation,last_generation_offspring_crossoverholds the offspring generated after applying the crossover in the last generation, andlast_generation_offspring_mutationholds the offspring generated after applying the mutation in the last generation. You can access these attributes inside theon_generation()method for example. - A bug fixed when the
initial_populationparameter is used. The bug occurred due to a mismatch between the data type of the array assigned toinitial_populationand the gene type in thegene_typeattribute. Assuming that the array assigned to theinitial_populationparameter is((1, 1), (3, 3), (5, 5), (7, 7))which has typeint. Whengene_typeis set tofloat, then the genes will not be float but casted tointbecause the defined array hasinttype. The bug is fixed by forcing the array assigned toinitial_populationto have the data type in thegene_typeattribute. Check the issue at GitHub: #27
Thanks to Marios Giouvanakis, a PhD candidate in Electrical & Computer Engineer, Aristotle University of Thessaloniki (Αριστοτέλειο Πανεπιστήμιο Θεσσαλονίκης), Greece, for emailing me about these issues.
PyGAD-2.11.0
PyGAD 2.11.0
Release Date: 16 February 2021
- In the
gene_spaceargument, the user can use a dictionary to specify the lower and upper limits of the gene. This dictionary must have only 2 items with keyslowandhighto specify the low and high limits of the gene, respectively. This way, PyGAD takes care of not exceeding the value limits of the gene. For a problem with only 2 genes, then usinggene_space=[{'low': 1, 'high': 5}, {'low': 0.2, 'high': 0.81}]means the accepted values in the first gene start from 1 (inclusive) to 5 (exclusive) while the second one has values between 0.2 (inclusive) and 0.85 (exclusive). For more information, please check the Limit the Gene Value Range section of the documentation. - The
plot_result()method returns the figure so that the user can save it. - Bug fixes in copying elements from the gene space.
- For a gene with a set of discrete values (more than 1 value) in the
gene_spaceparameter like[0, 1], it was possible that the gene value may not change after mutation. That is if the current value is 0, then the randomly selected value could also be 0. Now, it is verified that the new value is changed. So, if the current value is 0, then the new value after mutation will not be 0 but 1.
PyGAD-2.10.2
A bug fix when save_best_solutions=True. Refer to this issue for more information: #25
PyGAD-2.10.1
Changes in PyGAD 2.10.1
- In the
gene_spaceparameter, anyNonevalue (regardless of its index or axis), is replaced by a randomly generated number based on the 3 parametersinit_range_low,init_range_high, andgene_type. So, theNonevalue in[..., None, ...]or[..., [..., None, ...], ...]are replaced with random values. This gives more freedom in building the space of values for the genes. - All the numbers passed to the
gene_spaceparameter are casted to the type specified in thegene_typeparameter. - The
numpy.uintdata type is supported for the parameters that accept integer values. - In the
pygad.kerasgamodule, themodel_weights_as_vector()function uses thetrainableattribute of the model's layers to only return the trainable weights in the network. So, only the trainable layers with theirtrainableattribute set toTrue(trainable=True), which is the default value, have their weights evolved. All non-trainable layers with thetrainableattribute set toFalse(trainable=False) will not be evolved. Thanks to Prof. Tamer A. Farrag for pointing about that at GitHub.
PyGAD-2.10.0
- Support of a new module
pygad.torchgato train PyTorch models using PyGAD. Check its documentation. - Support of adaptive mutation where the mutation rate is determined by the fitness value of each solution. Read the Adaptive Mutation section for more details. Also, read this paper: Libelli, S. Marsili, and P. Alba. "Adaptive mutation in genetic algorithms." Soft computing 4.2 (2000): 76-80.
- Before the
run()method completes or exits, the fitness value of the best solution in the current population is appended to thebest_solution_fitnesslist attribute. Note that the fitness value of the best solution in the initial population is already saved at the beginning of the list. So, the fitness value of the best solution is saved before the genetic algorithm starts and after it ends. - When the parameter
parent_selection_typeis set tosss(steady-state selection), then a warning message is printed if the value of thekeep_parentsparameter is set to 0. - More validations to the user input parameters.
- The default value of the
mutation_percent_genesis set to the string"default"rather than the integer 10. This change helps to know whether the user explicitly passed a value to themutation_percent_genesparameter or it is left to its default one. The"default"value is later translated into the integer 10. - The
mutation_percent_genesparameter is no longer accepting the value 0. It must be>0and<=100. - The built-in
warningsmodule is used to show warning messages rather than just using theprint()function. - A new
boolparameter calledsuppress_warningsis added to the constructor of thepygad.GAclass. It allows the user to control whether the warning messages are printed or not. It defaults toFalsewhich means the messages are printed. - A helper method called
adaptive_mutation_population_fitness()is created to calculate the average fitness value used in adaptive mutation to filter the solutions. - The
best_solution()method accepts a new optional parameter calledpop_fitness. It accepts a list of the fitness values of the solutions in the population. IfNone, then thecal_pop_fitness()method is called to calculate the fitness values of the population.
PyGAD-2.9.0
Changes in PyGAD 2.9.0 (06 December 2020):
- The fitness values of the initial population are considered in the
best_solutions_fitnessattribute. - An optional parameter named
save_best_solutionsis added. It defaults toFalse. When it isTrue, then the best solution after each generation is saved into an attribute namedbest_solutions. IfFalse, then no solutions are saved and thebest_solutionsattribute will be empty. - Scattered crossover is supported. To use it, assign the
crossover_typeparameter the value"scattered". - NumPy arrays are now supported by the
gene_spaceparameter. - The following parameters (
gene_type,crossover_probability,mutation_probability,delay_after_gen) can be assigned to a numeric value of any of these data types:int,float,numpy.int,numpy.int8,numpy.int16,numpy.int32,numpy.int64,numpy.float,numpy.float16,numpy.float32, ornumpy.float64.