Releases: ahmedfgad/GeneticAlgorithmPython
Releases · ahmedfgad/GeneticAlgorithmPython
PyGAD-2.14.1
- Issue #40 is solved. Now, the
None
value works with thecrossover_type
andmutation_type
parameters: #40 - The
gene_type
parameter supports accepting alist/tuple/numpy.ndarray
of numeric data types for the genes. This helps to control the data type of each individual gene. Previously, thegene_type
can be assigned only to a single data type that is applied for all genes. - A new
bool
attribute namedgene_type_single
is added to thepygad.GA
class. It isTrue
when there is a single data type assigned to thegene_type
parameter. When thegene_type
parameter is assigned alist/tuple/numpy.ndarray
, thengene_type_single
is set toFalse
. - The
mutation_by_replacement
flag now has no effect ifgene_space
exists except for the genes withNone
values. For example, forgene_space=[None, [5, 6]]
themutation_by_replacement
flag affects only the first gene which hasNone
for its value space. - When an element has a value of
None
in thegene_space
parameter (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 withNone
value ingene_space
is 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
bool
parameter calledallow_duplicate_genes
is 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_fitness
is 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_fitness
parameter.
PyGAD-2.12.0
Release Date: 20 February 2021
- 4 new instance attributes are added to hold temporary results after each generation:
last_generation_fitness
holds the fitness values of the solutions in the last generation,last_generation_parents
holds the parents selected from the last generation,last_generation_offspring_crossover
holds the offspring generated after applying the crossover in the last generation, andlast_generation_offspring_mutation
holds 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_population
parameter is used. The bug occurred due to a mismatch between the data type of the array assigned toinitial_population
and the gene type in thegene_type
attribute. Assuming that the array assigned to theinitial_population
parameter is((1, 1), (3, 3), (5, 5), (7, 7))
which has typeint
. Whengene_type
is set tofloat
, then the genes will not be float but casted toint
because the defined array hasint
type. The bug is fixed by forcing the array assigned toinitial_population
to have the data type in thegene_type
attribute. 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_space
argument, the user can use a dictionary to specify the lower and upper limits of the gene. This dictionary must have only 2 items with keyslow
andhigh
to 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_space
parameter 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_space
parameter, anyNone
value (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, theNone
value 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_space
parameter are casted to the type specified in thegene_type
parameter. - The
numpy.uint
data type is supported for the parameters that accept integer values. - In the
pygad.kerasga
module, themodel_weights_as_vector()
function uses thetrainable
attribute of the model's layers to only return the trainable weights in the network. So, only the trainable layers with theirtrainable
attribute set toTrue
(trainable=True
), which is the default value, have their weights evolved. All non-trainable layers with thetrainable
attribute 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.torchga
to 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_fitness
list 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_type
is set tosss
(steady-state selection), then a warning message is printed if the value of thekeep_parents
parameter is set to 0. - More validations to the user input parameters.
- The default value of the
mutation_percent_genes
is 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_genes
parameter or it is left to its default one. The"default"
value is later translated into the integer 10. - The
mutation_percent_genes
parameter is no longer accepting the value 0. It must be>0
and<=100
. - The built-in
warnings
module is used to show warning messages rather than just using theprint()
function. - A new
bool
parameter calledsuppress_warnings
is added to the constructor of thepygad.GA
class. It allows the user to control whether the warning messages are printed or not. It defaults toFalse
which 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_fitness
attribute. - An optional parameter named
save_best_solutions
is 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_solutions
attribute will be empty. - Scattered crossover is supported. To use it, assign the
crossover_type
parameter the value"scattered"
. - NumPy arrays are now supported by the
gene_space
parameter. - 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
.
PyGAD-2.8.1
- Bug fix in applying the crossover operation when the
crossover_probability
parameter is used. Thanks to Eng. Hamada Kassem, Research and Teaching Assistant, Construction Engineering and Management, Faculty of Engineering, Alexandria University, Egypt.
PyGAD-2.8.0
Support of a new module named pygad.kerasga
to train Keras models using the genetic algorithm.