Skip to content

Releases: ahmedfgad/GeneticAlgorithmPython

PyGAD-2.19.1

22 Feb 15:21

Choose a tag to compare

  1. A new summary() method is supported to return a Keras-like summary of the PyGAD lifecycle.
  2. A new optional parameter called fitness_batch_size is supported to calculate the fitness function in batches. If it is assigned the value 1 or None (default), then the normal flow is used where the fitness function is called for each individual solution. If the fitness_batch_size parameter is assigned a value satisfying this condition 1 < fitness_batch_size <= sol_per_pop, then the solutions are grouped into batches of size fitness_batch_size and the fitness function is called once for each batch. In this case, the fitness function must return a list/tuple/numpy.ndarray with a length equal to the number of solutions passed. #136.
  3. The cloudpickle library (https://github.com/cloudpipe/cloudpickle) is used instead of the pickle library to pickle the pygad.GA objects. This solves the issue of having to redefine the functions (e.g. fitness function). The cloudpickle library is added as a dependancy in the requirements.txt file. #159
  4. Support of assigning methods to these parameters: fitness_func, crossover_type, mutation_type, parent_selection_type, on_start, on_fitness, on_parents, on_crossover, on_mutation, on_generation, and on_stop. #92 #138
  5. Validating the output of the parent selection, crossover, and mutation functions.
  6. The built-in parent selection operators return the parent's indices as a NumPy array.
  7. The outputs of the parent selection, crossover, and mutation operators must be NumPy arrays.
  8. Fix an issue when allow_duplicate_genes=True. #39
  9. Fix an issue creating scatter plots of the solutions' fitness.
  10. Sampling from a set() is no longer supported in Python 3.11. Instead, sampling happens from a list(). Thanks Marco Brenna for pointing to this issue.
  11. The lifecycle is updated to reflect that the new population's fitness is calculated at the end of the lifecycle not at the beginning. #154 (comment)
  12. There was an issue when save_solutions=True that causes the fitness function to be called for solutions already explored and have their fitness pre-calculated. #160
  13. A new instance attribute named last_generation_elitism_indices added to hold the indices of the selected elitism. This attribute helps to re-use the fitness of the elitism instead of calling the fitness function.
  14. Fewer calls to the best_solution() method which in turns saves some calls to the fitness function.
  15. Some updates in the documentation to give more details about the cal_pop_fitness() method. #79 (comment)

PyGAD-2.18.3

14 Feb 20:39
b15c15c

Choose a tag to compare

Update conf.py

PyGAD-2.18.2

14 Feb 19:25

Choose a tag to compare

PyGAD 2.18.2 release notes

  1. Remove numpy.int and numpy.float from the list of supported data types. #151 #152
  2. Call the on_crossover() callback function even if crossover_type is None. #138
  3. Call the on_mutation() callback function even if mutation_type is None. #138

PyGAD-2.18.1

19 Sep 19:08
4d7cd22

Choose a tag to compare

PyGAD 2.18.1

  1. A big fix when keep_elitism is used. #132

PyGAD-2.18.0

09 Sep 05:39
16c5ad9

Choose a tag to compare

  1. Raise an exception if the sum of fitness values is zero while either roulette wheel or stochastic universal parent selection is used. #129
  2. Initialize the value of the run_completed property to False. #122
  3. The values of these properties are no longer reset with each call to the run() method self.best_solutions, self.best_solutions_fitness, self.solutions, self.solutions_fitness: #123. Now, the user can have the flexibility of calling the run() method more than once while extending the data collected after each generation. Another advantage happens when the instance is loaded and the run() method is called, as the old fitness value are shown on the graph alongside with the new fitness values. Read more in this section: [Continue without Loosing Progress](https://pygad.readthedocs.io/en/latest/README_pygad_ReadTheDocs.html#continue-without-loosing-progress)
  4. Thanks [Prof. Fernando Jiménez Barrionuevo](http://webs.um.es/fernan) (Dept. of Information and Communications Engineering, University of Murcia, Murcia, Spain) for editing this [comment](https://github.com/ahmedfgad/GeneticAlgorithmPython/blob/5315bbec02777df96ce1ec665c94dece81c440f4/pygad.py#L73) in the code. 5315bbe
  5. A bug fixed when crossover_type=None.
  6. Support of elitism selection through a new parameter named keep_elitism. It defaults to 1 which means for each generation keep only the best solution in the next generation. If assigned 0, then it has no effect. Read more in this section: [Elitism Selection](https://pygad.readthedocs.io/en/latest/README_pygad_ReadTheDocs.html#elitism-selection). #74
  7. A new instance attribute named last_generation_elitism added to hold the elitism in the last generation.
  8. A new parameter called random_seed added to accept a seed for the random function generators. Credit to this issue #70 and [Prof. Fernando Jiménez Barrionuevo](http://webs.um.es/fernan). Read more in this section: [Random Seed](https://pygad.readthedocs.io/en/latest/README_pygad_ReadTheDocs.html#random-seed).
  9. Editing the pygad.TorchGA module to make sure the tensor data is moved from GPU to CPU. Thanks to Rasmus Johansson for opening this pull request: ahmedfgad/TorchGA#2

PyGAD-2.17.0

08 Jul 04:10
7f2b1f4

Choose a tag to compare

PyGAD 2.17.0

Release Date: 8 July 2022

  1. An issue is solved when the gene_space parameter is given a fixed value. e.g. gene_space=[range(5), 4]. The second gene's value is static (4) which causes an exception.
  2. Fixed the issue where the allow_duplicate_genes parameter did not work when mutation is disabled (i.e. mutation_type=None). This is by checking for duplicates after crossover directly. #39
  3. Solve an issue in the tournament_selection() method as the indices of the selected parents were incorrect. #89
  4. Reuse the fitness values of the previously explored solutions rather than recalculating them. This feature only works if save_solutions=True.
  5. Parallel processing is supported. This is by the introduction of a new parameter named parallel_processing in the constructor of the pygad.GA class. Thanks to [@windowshopr](https://github.com/windowshopr) for opening the issue [#78](#78) at GitHub. Check the [Parallel Processing in PyGAD](https://pygad.readthedocs.io/en/latest/README_pygad_ReadTheDocs.html#parallel-processing-in-pygad) section for more information and examples.

PyGAD-2.16.3

03 Feb 01:36
6ff4527

Choose a tag to compare

Changes in PyGAD 2.16.3

  1. A new instance attribute called previous_generation_fitness added in the pygad.GA class. It holds the fitness values of one generation before the fitness values saved in the last_generation_fitness.
  2. Issue in the cal_pop_fitness() method in getting the correct indices of the previous parents. This is solved by using the previous generation's fitness saved in the new attribute previous_generation_fitness to return the parents' fitness values. Thanks to Tobias Tischhauser (M.Sc. - [Mitarbeiter Institut EMS, Departement Technik, OST – Ostschweizer Fachhochschule, Switzerland](https://www.ost.ch/de/forschung-und-dienstleistungen/technik/systemtechnik/ems/team)) for detecting this bug.
  3. Validate the fitness value returned from the fitness function. An exception is raised if something is wrong. #67

PyGAD-2.16.1

29 Sep 01:46
158e53c

Choose a tag to compare

  1. Reuse the fitness of previously explored solutions rather than recalculating them. This feature only works if save_solutions=True.
  2. The user can use the tqdm library to show a progress bar. #50
import pygad
import numpy
import tqdm

equation_inputs = [4,-2,3.5]
desired_output = 44

def fitness_func(solution, solution_idx):
    output = numpy.sum(solution * equation_inputs)
    fitness = 1.0 / (numpy.abs(output - desired_output) + 0.000001)
    return fitness

num_generations = 10000
with tqdm.tqdm(total=num_generations) as pbar:
    ga_instance = pygad.GA(num_generations=num_generations,
                           sol_per_pop=5,
                           num_parents_mating=2,
                           num_genes=len(equation_inputs),
                           fitness_func=fitness_func,
                           on_generation=lambda _: pbar.update(1))
    
    ga_instance.run()

ga_instance.plot_result()
  1. Solved the issue of unequal length between the solutions and solutions_fitness when the save_solutions parameter is set to True. Now, the fitness of the last population is appended to the solutions_fitness array. #64
  2. There was an issue of getting the length of these 4 variables (solutions, solutions_fitness, best_solutions, and best_solutions_fitness) doubled after each call of the run() method. This is solved by resetting these variables at the beginning of the run() method. #62
  3. Bug fixes when adaptive mutation is used (mutation_type="adaptive"). #65

PyGAD-2.16.0

20 Jun 02:23
196a034

Choose a tag to compare

A user-defined function can be passed to the mutation_type, crossover_type, and parent_selection_type parameters in the pygad.GA class to create a custom mutation, crossover, and parent selection operators. Check the User-Defined Crossover, Mutation, and Parent Selection Operators section in the documentation: https://pygad.readthedocs.io/en/latest/README_pygad_ReadTheDocs.html#user-defined-crossover-mutation-and-parent-selection-operators
The example_custom_operators.py script gives an example of building and using custom functions for the 3 operators.
#50

PyGAD-2.15.1

18 Jun 06:17
3349dea

Choose a tag to compare

Fix a bug when keep_parents is set to a positive integer. #49