Skip to content

Commit 6ff1e47

Browse files
authored
Merge pull request #361 from ahmedfgad/master
Sync
2 parents 0480044 + 568cfd2 commit 6ff1e47

2,200 files changed

Lines changed: 415 additions & 252 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.gitignore‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,21 @@ docs/build/
2626
# These are personal to each developer and should not be committed.
2727
# =============================================================================
2828
.idea/
29+
30+
# =============================================================================
31+
# Example datasets from third parties. These are not part of PyGAD and are
32+
# not shipped in the repository. Download them separately to run the
33+
# examples that use them.
34+
# =============================================================================
35+
examples/data/Fruit360/
36+
examples/data/Skin_Cancer_Dataset/
37+
examples/data/Fish.csv
38+
examples/data/*.npy
39+
40+
# =============================================================================
41+
# Local-only working directories that are not part of PyGAD. These hold
42+
# personal tooling, caches, and their own virtual environments.
43+
# =============================================================================
44+
release_video/
45+
.pytest_cache/
46+
.claude/

‎LICENSES/BSD-3-Clause.txt‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Copyright GeneticAlgorithmPython Contributors
2+
3+
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.

‎README.md‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# PyGAD: Genetic Algorithm in Python
22

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.
44

55
> 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.
66
77
Read the [PyGAD documentation](https://pygad.readthedocs.io/en/latest).
88

99
[![PyPI Downloads](https://pepy.tech/badge/pygad)](https://pepy.tech/project/pygad) [![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/pygad.svg?label=Conda%20Downloads)](
10-
https://anaconda.org/conda-forge/PyGAD) [![PyPI version](https://badge.fury.io/py/pygad.svg)](https://badge.fury.io/py/pygad)![Docs](https://readthedocs.org/projects/pygad/badge)[![PyGAD PyTest / Python 3.13](https://github.com/ahmedfgad/GeneticAlgorithmPython/actions/workflows/main.yml/badge.svg)](https://github.com/ahmedfgad/GeneticAlgorithmPython/actions/workflows/main.yml) [![PyGAD PyTest / Python 3.12](https://github.com/ahmedfgad/GeneticAlgorithmPython/actions/workflows/release.yml/badge.svg)](https://github.com/ahmedfgad/GeneticAlgorithmPython/actions/workflows/release.yml) [![PyGAD PyTest / Python 3.11](https://github.com/ahmedfgad/GeneticAlgorithmPython/actions/workflows/scorecard.yml/badge.svg)](https://github.com/ahmedfgad/GeneticAlgorithmPython/actions/workflows/scorecard.yml) [![License](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause) [![Translation](https://hosted.weblate.org/widgets/weblate/-/svg-badge.svg)](https://hosted.weblate.org/engage/weblate/) [![REUSE](https://api.reuse.software/badge/github.com/WeblateOrg/weblate)](https://api.reuse.software/info/github.com/WeblateOrg/weblate) [![Stack Overflow](https://img.shields.io/badge/stackoverflow-Ask%20questions-blue.svg)](
10+
https://anaconda.org/conda-forge/PyGAD) [![PyPI version](https://badge.fury.io/py/pygad.svg)](https://badge.fury.io/py/pygad)![Docs](https://readthedocs.org/projects/pygad/badge)[![PyGAD PyTest Matrix](https://github.com/ahmedfgad/GeneticAlgorithmPython/actions/workflows/main.yml/badge.svg)](https://github.com/ahmedfgad/GeneticAlgorithmPython/actions/workflows/main.yml) [![Release](https://github.com/ahmedfgad/GeneticAlgorithmPython/actions/workflows/release.yml/badge.svg)](https://github.com/ahmedfgad/GeneticAlgorithmPython/actions/workflows/release.yml) [![Scorecard supply-chain security](https://github.com/ahmedfgad/GeneticAlgorithmPython/actions/workflows/scorecard.yml/badge.svg)](https://github.com/ahmedfgad/GeneticAlgorithmPython/actions/workflows/scorecard.yml) [![License](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause) [![REUSE](https://api.reuse.software/badge/github.com/ahmedfgad/GeneticAlgorithmPython)](https://api.reuse.software/info/github.com/ahmedfgad/GeneticAlgorithmPython) [![Stack Overflow](https://img.shields.io/badge/stackoverflow-Ask%20questions-blue.svg)](
1111
https://stackoverflow.com/questions/tagged/pygad) [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/ahmedfgad/GeneticAlgorithmPython/badge)](https://securityscorecards.dev/viewer/?uri=github.com/ahmedfgad/GeneticAlgorithmPython) [![DOI](https://zenodo.org/badge/DOI/10.1007/s11042-023-17167-y.svg)](https://doi.org/10.1007/s11042-023-17167-y)
1212

1313
![PYGAD-LOGO](https://user-images.githubusercontent.com/16560492/101267295-c74c0180-375f-11eb-9ad0-f8e37bd796ce.png)
@@ -60,11 +60,11 @@ Please check the **Contact Us** section for more contact details.
6060

6161
# Life Cycle of PyGAD
6262

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`.
6464

6565
![PyGAD Lifecycle](https://user-images.githubusercontent.com/16560492/220486073-c5b6089d-81e4-44d9-a53c-385f479a7273.jpg)
6666

67-
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.
6868

6969
```python
7070
import pygad
@@ -175,7 +175,7 @@ num_parents_mating = 7 # Number of solutions to be selected as parents in the ma
175175

176176
# To prepare the initial population, there are 2 ways:
177177
# 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.
179179
sol_per_pop = 50 # Number of solutions in the population.
180180
num_genes = len(function_inputs)
181181

@@ -260,7 +260,7 @@ Read about training neural networks using the genetic algorithm through the tuto
260260

261261
## Book: Practical Computer Vision Applications Using Deep Learning with CNNs
262262

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.
264264

265265
Find the book at these links:
266266

‎REUSE.toml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version = 1
2+
3+
# Every file tracked in this repository is part of PyGAD and is licensed
4+
# under BSD-3-Clause. Third-party example datasets are not tracked here
5+
# (see .gitignore) and keep their own licenses where you download them.
6+
[[annotations]]
7+
path = "**"
8+
SPDX-FileCopyrightText = "GeneticAlgorithmPython Contributors"
9+
SPDX-License-Identifier = "BSD-3-Clause"

‎docs/source/conf.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
author = 'Ahmed Fawzy Gad'
1111

1212
# The full version, including alpha/beta/rc tags.
13-
release = '3.6.0'
13+
release = '3.7.0'
1414

1515
master_doc = 'index'
1616

‎docs/source/pygad.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,8 @@ Parameters:
785785

786786
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).
787787

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+
788790
## Functions in `pygad`
789791

790792
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()`.

‎docs/source/releases.md‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ Release Date April 8, 2026
659659

660660
## PyGAD 3.7.0
661661

662-
Release Date ..., 2026
662+
Release Date June 5, 2026
663663

664664
1. Validation logic is applied to validate the `num_generations` parameter.
665665
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
668668
5. The `wheel_cumulative_probs()` method in the `pygad.parent_selection.ParentSelection` class is refactored to reduce its computational time.
669669
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.
670670
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`
676676
8. Fix a bug in the `visualize/plot.py` script where the `labels` parameter of `boxplot()` has been renamed `tick_labels` in Matplotlib.
677677
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.
678678
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
700700
32. A new example `examples/example_generate_report.py` shows how to build a PDF report after running a multi-objective GA.
701701
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.
702702
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()`.

‎docs/source/utils.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ Two module-level constants in `pygad.utils.nsga3` control the numerical safeguar
352352

353353
## `pygad.utils.report` Submodule
354354

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`:
356356

357357
```
358358
pip install pygad[report]

0 commit comments

Comments
 (0)