Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
PayPal: http://paypal.me/ahmedfgad # Replace with a single Patreon username
# paypal: http://paypal.me/ahmedfgad # Replace with a single Patreon username
open_collective: pygad
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: https://donate.stripe.com/eVa5kO866elKgM0144 # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
custom: ['https://donate.stripe.com/eVa5kO866elKgM0144', 'http://paypal.me/ahmedfgad'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ The library is under active development and more features are added regularly. I

# Donation

For donattion:
* By Card (recommended): https://donate.stripe.com/eVa5kO866elKgM0144
* [Open Collective](https://opencollective.com/pygad): [opencollective.com/pygad](https://opencollective.com/pygad).
* PayPal: Either this link: [paypal.me/ahmedfgad](https://paypal.me/ahmedfgad) or the e-mail address ahmed.f.gad@gmail.com.
* [Credit/Debit Card](https://donate.stripe.com/eVa5kO866elKgM0144): https://donate.stripe.com/eVa5kO866elKgM0144
* [Open Collective](https://opencollective.com/pygad): [opencollective.com/pygad](https://opencollective.com/pygad)
* PayPal: Use either this link: [paypal.me/ahmedfgad](https://paypal.me/ahmedfgad) or the e-mail address ahmed.f.gad@gmail.com
* Interac e-Transfer: Use e-mail address ahmed.f.gad@gmail.com

# Installation

Expand Down Expand Up @@ -76,7 +76,7 @@ import numpy
function_inputs = [4,-2,3.5,5,-11,-4.7]
desired_output = 44

def fitness_func(solution, solution_idx):
def fitness_func(ga_instance, solution, solution_idx):
output = numpy.sum(solution*function_inputs)
fitness = 1.0 / (numpy.abs(output - desired_output) + 0.000001)
return fitness
Expand Down Expand Up @@ -164,7 +164,7 @@ What are the best values for the 6 weights (w1 to w6)? We are going to use the g
function_inputs = [4,-2,3.5,5,-11,-4.7] # Function inputs.
desired_output = 44 # Function output.

def fitness_func(solution, solution_idx):
def fitness_func(ga_instance, solution, solution_idx):
# Calculating the fitness value of each solution in the current population.
# The fitness function calulates the sum of products between each input and its corresponding weight.
output = numpy.sum(solution*function_inputs)
Expand Down Expand Up @@ -280,7 +280,7 @@ To start with coding the genetic algorithm, you can check the tutorial titled [*
- [KDnuggets](https://www.kdnuggets.com/2018/04/building-convolutional-neural-network-numpy-scratch.html)
- [Chinese Translation](http://m.aliyun.com/yunqi/articles/585741)

[This tutorial](https://www.linkedin.com/pulse/building-convolutional-neural-network-using-numpy-from-ahmed-gad) is prepared based on a previous version of the project but it still a good resource to start with coding CNNs.
[This tutorial](https://www.linkedin.com/pulse/building-convolutional-neural-network-using-numpy-from-ahmed-gad)) is prepared based on a previous version of the project but it still a good resource to start with coding CNNs.

[![Building CNN in Python](https://user-images.githubusercontent.com/16560492/82431022-6c3a1200-9a8e-11ea-8f1b-b055196d76e3.png)](https://www.linkedin.com/pulse/building-convolutional-neural-network-using-numpy-from-ahmed-gad)

Expand Down Expand Up @@ -331,4 +331,3 @@ If you used PyGAD, please consider adding a citation to the following paper abou
* [KDnuggets](https://kdnuggets.com/author/ahmed-gad)
* [TowardsDataScience](https://towardsdatascience.com/@ahmedfgad)
* [GitHub](https://github.com/ahmedfgad)

2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .pygad import * # Relative import.

__version__ = "2.19.2"
__version__ = "3.0.0"
96 changes: 92 additions & 4 deletions docs/source/Footer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ Release Date: 28 September 2021
equation_inputs = [4,-2,3.5]
desired_output = 44

def fitness_func(solution, solution_idx):
def fitness_func(ga_instance, solution, solution_idx):
output = numpy.sum(solution * equation_inputs)
fitness = 1.0 / (numpy.abs(output - desired_output) + 0.000001)
return fitness
Expand Down Expand Up @@ -891,7 +891,7 @@ progress bar.
equation_inputs = [4,-2,3.5]
desired_output = 44

def fitness_func(solution, solution_idx):
def fitness_func(ga_instance, solution, solution_idx):
output = numpy.sum(solution * equation_inputs)
fitness = 1.0 / (numpy.abs(output - desired_output) + 0.000001)
return fitness
Expand Down Expand Up @@ -1119,7 +1119,7 @@ Release Date: 22 February 2023
(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
function). The ``cloudpickle`` library is added as a dependency in
the ``requirements.txt`` file.
https://github.com/ahmedfgad/GeneticAlgorithmPython/issues/159

Expand Down Expand Up @@ -1185,12 +1185,100 @@ Release Date: 22 February 2023
PyGAD 2.19.2
------------

Release Data 23 February 2023
Release Date 23 February 2023

1. Fix an issue when parallel processing was used where the elitism
solutions' fitness values are not re-used.
https://github.com/ahmedfgad/GeneticAlgorithmPython/issues/160#issuecomment-1441718184

.. _pygad-300:

PyGAD 3.0.0
-----------

Release Date 8 April 2023

1. The structure of the library is changed and some methods defined in
the ``pygad.py`` module are moved to the ``pygad.utils``,
``pygad.helper``, and ``pygad.visualize`` submodules.

2. The ``pygad.utils.parent_selection`` module has a class named
``ParentSelection`` where all the parent selection operators exist.
The ``pygad.GA`` class extends this class.

3. The ``pygad.utils.crossover`` module has a class named ``Crossover``
where all the crossover operators exist. The ``pygad.GA`` class
extends this class.

4. The ``pygad.utils.mutation`` module has a class named ``Mutation``
where all the mutation operators exist. The ``pygad.GA`` class
extends this class.

5. The ``pygad.helper.unique`` module has a class named ``Unique`` some
helper methods exist to solve duplicate genes and make sure every
gene is unique. The ``pygad.GA`` class extends this class.

6. The ``pygad.visualize.plot`` module has a class named ``Plot`` where
all the methods that create plots exist. The ``pygad.GA`` class
extends this class.

7. Support of using the ``logging`` module to log the outputs to both
the console and text file instead of using the ``print()`` function.
This is by assigning the ``logging.Logger`` to the new ``logger``
parameter. Check the `Logging
Outputs <https://pygad.readthedocs.io/en/latest/README_pygad_ReadTheDocs.html#logging-outputs>`__
for more information.

8. A new instance attribute called ``logger`` to save the logger.

9. The function/method passed to the ``fitness_func`` parameter accepts
a new parameter that refers to the instance of the ``pygad.GA``
class. Check this for an example: `Use Functions and Methods to
Build Fitness Function and
Callbacks <https://pygad.readthedocs.io/en/latest/README_pygad_ReadTheDocs.html#use-functions-and-methods-to-build-fitness-and-callbacks>`__.
https://github.com/ahmedfgad/GeneticAlgorithmPython/issues/163

10. Update the documentation to include an example of using functions
and methods to calculate the fitness and build callbacks. Check this
for more details: `Use Functions and Methods to Build Fitness
Function and
Callbacks <https://pygad.readthedocs.io/en/latest/README_pygad_ReadTheDocs.html#use-functions-and-methods-to-build-fitness-and-callbacks>`__.
https://github.com/ahmedfgad/GeneticAlgorithmPython/pull/92#issuecomment-1443635003

11. Validate the value passed to the ``initial_population`` parameter.

12. Validate the type and length of the ``pop_fitness`` parameter of the
``best_solution()`` method.

13. Some edits in the documentation.
https://github.com/ahmedfgad/GeneticAlgorithmPython/issues/106

14. Fix an issue when building the initial population as (some) genes
have their value taken from the mutation range (defined by the
parameters ``random_mutation_min_val`` and
``random_mutation_max_val``) instead of using the parameters
``init_range_low`` and ``init_range_high``.

15. The ``summary()`` method returns the summary as a single-line
string. Just log/print the returned string it to see it properly.

16. The ``callback_generation`` parameter is removed. Use the
``on_generation`` parameter instead.

17. There was an issue when using the ``parallel_processing`` parameter
with Keras and PyTorch. As Keras/PyTorch are not thread-safe, the
``predict()`` method gives incorrect and weird results when more
than 1 thread is used.
https://github.com/ahmedfgad/GeneticAlgorithmPython/issues/145
https://github.com/ahmedfgad/TorchGA/issues/5
https://github.com/ahmedfgad/KerasGA/issues/6. Thanks to this
`StackOverflow
answer <https://stackoverflow.com/a/75606666/5426539>`__.

18. Replace ``numpy.float`` by ``float`` in the 2 parent selection
operators roulette wheel and stochastic universal.
https://github.com/ahmedfgad/GeneticAlgorithmPython/pull/168

PyGAD Projects at GitHub
========================

Expand Down
Loading