You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6ff1e47
Browse filesBrowse the repository at this point in the historyBrowse files
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
+
5
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
7
+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
8
+
9
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Copy file name to clipboardExpand all lines: README.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,13 @@
1
1
# PyGAD: Genetic Algorithm in Python
2
2
3
-
[PyGAD](https://pypi.org/project/pygad) is an open-source easy-to-use Python 3 library for building the genetic algorithm and optimizing machine learning algorithms. It supports Keras and PyTorch. PyGAD supports optimizing both single-objective and multi-objective problems.
3
+
[PyGAD](https://pypi.org/project/pygad) is an open-source, easy-to-use Python 3 library for building the genetic algorithm and optimizing machine learning algorithms. It supports Keras and PyTorch, and it can optimize both single-objective and multi-objective problems.
4
4
5
5
> Try [Vilvik](https://vilvik.com), a free cloud-based tool powered by PyGAD. It makes optimization easier by reducing or removing the need for coding, and it shows helpful visualizations.
6
6
7
7
Read the [PyGAD documentation](https://pygad.readthedocs.io/en/latest).
@@ -60,11 +60,11 @@ Please check the **Contact Us** section for more contact details.
60
60
61
61
# Life Cycle of PyGAD
62
62
63
-
The next figure shows the main stages in the life cycle of a `pygad.GA` instance. PyGAD stops when all generations are completed or when the function passed to the `on_generation` parameter returns the string `stop`.
63
+
The following figure shows the main stages in the life cycle of a `pygad.GA` instance. PyGAD stops when all generations are completed or when the function passed to the `on_generation` parameter returns the string `stop`.
The next code implements all the callback functions to trace the execution of the genetic algorithm. Each callback function prints its name.
67
+
The following code implements all the callback functions to trace the execution of the genetic algorithm. Each callback function prints its name.
68
68
69
69
```python
70
70
import pygad
@@ -175,7 +175,7 @@ num_parents_mating = 7 # Number of solutions to be selected as parents in the ma
175
175
176
176
# To prepare the initial population, there are 2 ways:
177
177
# 1) Prepare it yourself and pass it to the initial_population parameter. This way is useful when the user wants to start the genetic algorithm with a custom initial population.
178
-
# 2) Assign valid integer values to the sol_per_pop and num_genes parameters. If the initial_population parameter exists, then the sol_per_pop and num_genes parameters are useless.
178
+
# 2) Assign valid integer values to the sol_per_pop and num_genes parameters. If the initial_population parameter is used, then the sol_per_pop and num_genes parameters are ignored.
179
179
sol_per_pop =50# Number of solutions in the population.
180
180
num_genes =len(function_inputs)
181
181
@@ -260,7 +260,7 @@ Read about training neural networks using the genetic algorithm through the tuto
260
260
261
261
## Book: Practical Computer Vision Applications Using Deep Learning with CNNs
262
262
263
-
You can also check my book cited as [**Ahmed Fawzy Gad 'Practical Computer Vision Applications Using Deep Learning with CNNs'. Dec. 2018, Apress, 978-1-4842-4167-7**](https://www.amazon.com/Practical-Computer-Vision-Applications-Learning/dp/1484241665) which discusses neural networks, convolutional neural networks, deep learning, genetic algorithm, and more.
263
+
You can also check my book cited as [**Ahmed Fawzy Gad 'Practical Computer Vision Applications Using Deep Learning with CNNs'. Dec. 2018, Apress, 978-1-4842-4167-7**](https://www.amazon.com/Practical-Computer-Vision-Applications-Learning/dp/1484241665) which discusses neural networks, convolutional neural networks, deep learning, genetic algorithms, and more.
Copy file name to clipboardExpand all lines: docs/source/pygad.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -785,6 +785,8 @@ Parameters:
785
785
786
786
The report skips any plot whose preconditions are not met. For example, `plot_pareto_front_curve` is included only for multi-objective runs with 2 or 3 objectives; `plot_non_dominated_hypervolume` is included only when `save_solutions=True` is set on the GA. A full example lives at [`examples/example_generate_report.py`](https://github.com/ahmedfgad/GeneticAlgorithmPython/tree/master/examples/example_generate_report.py).
787
787
788
+
The title page shows the PyGAD logo. The image ships with the package, so it works without network access. If the image file is missing, the report is built without it.
789
+
788
790
## Functions in `pygad`
789
791
790
792
Besides the methods available in the `pygad.GA` class, this section discusses the functions available in `pygad`. Up to this time, there is only a single function named `load()`.
Copy file name to clipboardExpand all lines: docs/source/releases.md
+20-6Lines changed: 20 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -659,7 +659,7 @@ Release Date April 8, 2026
659
659
660
660
## PyGAD 3.7.0
661
661
662
-
Release Date ..., 2026
662
+
Release Date June 5, 2026
663
663
664
664
1. Validation logic is applied to validate the `num_generations` parameter.
665
665
2. The `num_generations` parameter must be assigned a positive integer. Previously, any number (positive/negative, int/float) was accepted.
@@ -668,11 +668,11 @@ Release Date ..., 2026
668
668
5. The `wheel_cumulative_probs()` method in the `pygad.parent_selection.ParentSelection` class is refactored to reduce its computational time.
669
669
6. Use `numpy.where()` to decide which the source parent of each gene within the `uniform_crossover()` method in the `utils/crossover.py` script. The same was already applied to the `scattered_crossover()` method.
670
670
7. Add tests for the following modules:
671
-
`nn`
672
-
`cnn`
673
-
`gacnn`
674
-
`kerasga`
675
-
`torchga`
671
+
1.`nn`
672
+
2.`cnn`
673
+
3.`gacnn`
674
+
4.`kerasga`
675
+
5.`torchga`
676
676
8. Fix a bug in the `visualize/plot.py` script where the `labels` parameter of `boxplot()` has been renamed `tick_labels` in Matplotlib.
677
677
9. Fix a bug where the `best_solutions_fitness` list (instance attribute to `pygad.GA`) has the fitness of the last generation duplicated when an early stop happens inside the `on_generation()` callback. This made its size incompatible with the `best_solutions` list.
678
678
10. The documentation is refactored to solve many language issues and the Furo theme is applied. For easy navigation, the index is reformatted to only show the main sections. At each page, its index is shown at the right side. A new theme toggle button to change theme between light and dark.
@@ -700,3 +700,17 @@ Release Date ..., 2026
700
700
32. A new example `examples/example_generate_report.py` shows how to build a PDF report after running a multi-objective GA.
701
701
33. The `pygad.md`, `releases.md`, `visualize.md`, and `utils.md` documentation pages were updated to reflect the new module layout, the renamed methods, the new `generate_report()` entry point, and the new NSGA-III instance attributes (`nsga3_num_divisions`, `nsga3_reference_points`). The "Other Instance Attributes & Methods" section in `pygad.md` is now grouped by area (Lifecycle, Population, Fitness, Parent Selection, NSGA-II, NSGA-III, Crossover, Mutation, Elitism, Gene Constraints, Saving) so each method or attribute appears under its topic.
702
702
34. Fix issue https://github.com/ahmedfgad/GeneticAlgorithmPython/issues/351 by updating the documentation to clarify what the `solution` has.
703
+
35. Version changed in the following modules:
704
+
1. A new submodule `pygad.benchmarks` is added with the version `1.0.0`.
705
+
2. The version of the `pygad.utils` submodule is upgraded from `1.4.0` to `1.5.0`.
706
+
3. The version of the `pygad.helper` submodule is upgraded from `1.3.0` to `1.4.0`.
707
+
4. The version of the `pygad.visualize` submodule is upgraded from `1.1.1` to `1.2.0`.
708
+
5. The version of the `pygad.nn` submodule is upgraded from `1.2.2` to `1.2.3`.
709
+
6. The version of the `pygad.cnn` submodule is upgraded from `1.1.1` to `1.1.2`.
710
+
7. The version of the `pygad.kerasga` submodule is upgraded from `1.3.1` to `1.3.2`.
711
+
8. The version of the `pygad.torchga` submodule is upgraded from `1.4.1` to `1.4.2`.
712
+
9. The version of the `pygad.gann` submodule is upgraded from `1.0.0` to `1.0.1`.
713
+
10. The version of the `pygad.gacnn` submodule is upgraded from `1.0.0` to `1.0.1`.
714
+
36. The PDF report built by `generate_report()` now shows the PyGAD logo on its title page. The logo image ships with the package, so no network access is needed. If the image file is missing, the report is built without it.
715
+
37. Two private helper functions are added to the `pygad/utils/report.py` script for the logo. `_pdf_report_read_logo_bytes()` reads the bundled logo file and returns its bytes, or `None` if the file is missing. `_pdf_report_build_logo_image()` builds the image that is placed on the title page, or returns `None` so the report still builds without the logo.
716
+
38. The private helper functions in the `pygad/utils/report.py` script are renamed to start with the `_pdf_report_` prefix so their purpose is clear from the name. For example, `_build_title_section()` becomes `_pdf_report_build_title_section()` and `_render_plot_to_png()` becomes `_pdf_report_render_plot_to_png()`.
Copy file name to clipboardExpand all lines: docs/source/utils.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -352,7 +352,7 @@ Two module-level constants in `pygad.utils.nsga3` control the numerical safeguar
352
352
353
353
## `pygad.utils.report` Submodule
354
354
355
-
The `pygad.utils.report` module has a class named `Report` that adds the `generate_report()` method to the `pygad.GA` class. It builds a PDF report of the GA run, bundling the configuration table, a run summary, the best solution, and every applicable plot. Requires the optional dependencies `reportlab` and `matplotlib`:
355
+
The `pygad.utils.report` module has a class named `Report` that adds the `generate_report()` method to the `pygad.GA` class. It builds a PDF report of the GA run, bundling the configuration table, a run summary, the best solution, and every applicable plot. The title page shows the PyGAD logo, which ships with the package. Requires the optional dependencies `reportlab` and `matplotlib`:
0 commit comments