Skip to content

Releases: ahmedfgad/GeneticAlgorithmPython

PyGAD-2.14.1

19 May 07:37
b3bd7e9
Compare
Choose a tag to compare
  1. Issue #40 is solved. Now, the None value works with the crossover_type and mutation_type parameters: #40
  2. The gene_type parameter supports accepting a list/tuple/numpy.ndarray of numeric data types for the genes. This helps to control the data type of each individual gene. Previously, the gene_type can be assigned only to a single data type that is applied for all genes.
  3. A new bool attribute named gene_type_single is added to the pygad.GA class. It is True when there is a single data type assigned to the gene_type parameter. When the gene_type parameter is assigned a list/tuple/numpy.ndarray, then gene_type_single is set to False.
  4. The mutation_by_replacement flag now has no effect if gene_space exists except for the genes with None values. For example, for gene_space=[None, [5, 6]] the mutation_by_replacement flag affects only the first gene which has None for its value space.
  5. When an element has a value of None in the gene_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 with None value in gene_space is the same across all solutions
  6. Some changes in the documentation according to issue #32: #32

PyGAD-2.13.0

13 Mar 00:47
67bc972
Compare
Choose a tag to compare

PyGAD 2.13.0

Release Date: 12 March 2021

  1. A new bool parameter called allow_duplicate_genes is supported. If True, which is the default, then a solution/chromosome may have duplicate gene values. If False, then each gene will have a unique value in its solution. Check the Prevent Duplicates in Gene Values section for more details.
  2. 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 the last_generation_fitness parameter.

PyGAD-2.12.0

20 Feb 06:57
0c0ac1c
Compare
Choose a tag to compare

Release Date: 20 February 2021

  1. 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, and last_generation_offspring_mutation holds the offspring generated after applying the mutation in the last generation. You can access these attributes inside the on_generation() method for example.
  2. 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 to initial_population and the gene type in the gene_type attribute. Assuming that the array assigned to the initial_population parameter is ((1, 1), (3, 3), (5, 5), (7, 7)) which has type int. When gene_type is set to float, then the genes will not be float but casted to int because the defined array has int type. The bug is fixed by forcing the array assigned to initial_population to have the data type in the gene_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

16 Feb 07:02
6500af4
Compare
Choose a tag to compare

PyGAD 2.11.0

Release Date: 16 February 2021

  1. 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 keys low and high 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 using gene_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.
  2. The plot_result() method returns the figure so that the user can save it.
  3. Bug fixes in copying elements from the gene space.
  4. 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

15 Jan 16:18
05a069a
Compare
Choose a tag to compare

A bug fix when save_best_solutions=True. Refer to this issue for more information: #25

PyGAD-2.10.1

11 Jan 02:55
de62f66
Compare
Choose a tag to compare

Changes in PyGAD 2.10.1

  1. In the gene_space parameter, any None value (regardless of its index or axis), is replaced by a randomly generated number based on the 3 parameters init_range_low, init_range_high, and gene_type. So, the None value in [..., None, ...] or [..., [..., None, ...], ...] are replaced with random values. This gives more freedom in building the space of values for the genes.
  2. All the numbers passed to the gene_space parameter are casted to the type specified in the gene_type parameter.
  3. The numpy.uint data type is supported for the parameters that accept integer values.
  4. In the pygad.kerasga module, the model_weights_as_vector() function uses the trainable attribute of the model's layers to only return the trainable weights in the network. So, only the trainable layers with their trainable attribute set to True (trainable=True), which is the default value, have their weights evolved. All non-trainable layers with the trainable attribute set to False (trainable=False) will not be evolved. Thanks to Prof. Tamer A. Farrag for pointing about that at GitHub.

PyGAD-2.10.0

04 Jan 02:17
f5a17be
Compare
Choose a tag to compare
  1. Support of a new module pygad.torchga to train PyTorch models using PyGAD. Check its documentation.
  2. 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.
  3. Before the run() method completes or exits, the fitness value of the best solution in the current population is appended to the best_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.
  4. When the parameter parent_selection_type is set to sss (steady-state selection), then a warning message is printed if the value of the keep_parents parameter is set to 0.
  5. More validations to the user input parameters.
  6. 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 the mutation_percent_genes parameter or it is left to its default one. The "default" value is later translated into the integer 10.
  7. The mutation_percent_genes parameter is no longer accepting the value 0. It must be >0 and <=100.
  8. The built-in warnings module is used to show warning messages rather than just using the print() function.
  9. A new bool parameter called suppress_warnings is added to the constructor of the pygad.GA class. It allows the user to control whether the warning messages are printed or not. It defaults to False which means the messages are printed.
  10. A helper method called adaptive_mutation_population_fitness() is created to calculate the average fitness value used in adaptive mutation to filter the solutions.
  11. The best_solution() method accepts a new optional parameter called pop_fitness. It accepts a list of the fitness values of the solutions in the population. If None, then the cal_pop_fitness() method is called to calculate the fitness values of the population.

PyGAD-2.9.0

05 Dec 23:30
040b8e1
Compare
Choose a tag to compare

Changes in PyGAD 2.9.0 (06 December 2020):

  1. The fitness values of the initial population are considered in the best_solutions_fitness attribute.
  2. An optional parameter named save_best_solutions is added. It defaults to False. When it is True, then the best solution after each generation is saved into an attribute named best_solutions. If False, then no solutions are saved and the best_solutions attribute will be empty.
  3. Scattered crossover is supported. To use it, assign the crossover_type parameter the value "scattered".
  4. NumPy arrays are now supported by the gene_space parameter.
  5. 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, or numpy.float64.

PyGAD-2.8.1

04 Oct 04:06
ee8fe42
Compare
Choose a tag to compare
  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

20 Sep 21:53
4f695c6
Compare
Choose a tag to compare

Support of a new module named pygad.kerasga to train Keras models using the genetic algorithm.