Skip to content

Commit c9d5df7

Browse files
authored
Add files via upload
1 parent fcc0a02 commit c9d5df7

File tree

3 files changed

+222
-87
lines changed

3 files changed

+222
-87
lines changed

docs/source/Footer.rst

+130-34
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ Release date: 1 June 2020
166166
6. The name of the ``pygad.nn.train_network()`` function is changed to
167167
``pygad.nn.train()``.
168168

169-
.. _header-n214:
169+
.. _header-n77:
170170

171171
PyGAD 2.4.0
172172
-----------
@@ -183,28 +183,124 @@ Release date: 5 July 2020
183183
algorithm if it returns the string ``stop``. This causes the
184184
``run()`` method to stop.
185185

186-
One important use case for that feature is to stop the genetic
187-
algorithm when a condition is met before passing though all the
188-
generations. The user may assigned a value of 100 to the
189-
``num_generations`` parameter of the pygad.GA class constructor.
190-
Assuming that at generation 50, for example, a condition is met and
191-
the user wants to stop the execution before waiting the remaining 50
192-
generations. To do that, just make the function passed to the
193-
``callback_generation`` parameter to return the string ``stop``.
186+
One important use case for that feature is to stop the genetic algorithm
187+
when a condition is met before passing though all the generations. The
188+
user may assigned a value of 100 to the ``num_generations`` parameter of
189+
the pygad.GA class constructor. Assuming that at generation 50, for
190+
example, a condition is met and the user wants to stop the execution
191+
before waiting the remaining 50 generations. To do that, just make the
192+
function passed to the ``callback_generation`` parameter to return the
193+
string ``stop``.
194+
195+
Here is an example of a function to be passed to the
196+
``callback_generation`` parameter which stops the execution if the
197+
fitness value 70 is reached. The value 70 might be the best possible
198+
fitness value. After being reached, then there is no need to pass
199+
through more generations because no further improvement is possible.
194200

195-
Here is an example of a function to be passed to the
196-
``callback_generation`` parameter which stops the execution if the
197-
fitness value 70 is reached. The value 70 might be the best possible
198-
fitness value. After being reached, then there is no need to pass
199-
through more generations because no further improvement is possible.
200-
201-
.. code:: python
201+
.. code:: python
202202
203203
def func_generation(ga_instance):
204204
if ga_instance.best_solution()[1] >= 70:
205205
return "stop"
206206
207-
.. _header-n219:
207+
.. _header-n225:
208+
209+
PyGAD 2.5.0
210+
-----------
211+
212+
Release date: 19 July 2020
213+
214+
1. | 2 new optional parameters added to the constructor of the
215+
``pygad.GA`` class which are ``crossover_probability`` and
216+
``mutation_probability``.
217+
| While applying the crossover operation, each parent has a random
218+
value generated between 0.0 and 1.0. If this random value is less
219+
than or equal to the value assigned to the
220+
``crossover_probability`` parameter, then the parent is selected
221+
for the crossover operation.
222+
| For the mutation operation, a random value between 0.0 and 1.0 is
223+
generated for each gene in the solution. If this value is less than
224+
or equal to the value assigned to the ``mutation_probability``,
225+
then this gene is selected for mutation.
226+
227+
2. A new optional parameter named ``linewidth`` is added to the
228+
``plot_result()`` method to specify the width of the curve in the
229+
plot. It defaults to 3.0.
230+
231+
3. Previously, the indices of the genes selected for mutation was
232+
randomly generated once for all solutions within the generation.
233+
Currently, the genes' indices are randomly generated for each
234+
solution in the population. If the population has 4 solutions, the
235+
indices are randomly generated 4 times inside the single generation,
236+
1 time for each solution.
237+
238+
4. Previously, the position of the point(s) for the single-point and
239+
two-points crossover was(were) randomly selected once for all
240+
solutions within the generation. Currently, the position(s) is(are)
241+
randomly selected for each solution in the population. If the
242+
population has 4 solutions, the position(s) is(are) randomly
243+
generated 4 times inside the single generation, 1 time for each
244+
solution.
245+
246+
5. A new optional parameter named ``gene_space`` as added to the
247+
``pygad.GA`` class constructor. It is used to specify the possible
248+
values for each gene in case the user wants to restrict the gene
249+
values. It is useful if the gene space is restricted to a certain
250+
range or to discrete values.
251+
252+
Assuming that all genes have the same global space which include the
253+
values 0.3, 5.2, -4, and 8, then those values can be assigned to the
254+
``gene_space`` parameter as a list, tuple, or range. Here is a list
255+
assigned to this parameter. By doing that, then the gene values are
256+
restricted to those assigned to the ``gene_space`` parameter.
257+
258+
.. code:: python
259+
260+
gene_space = [0.3, 5.2, -4, 8]
261+
262+
If some genes have different spaces, then ``gene_space`` should accept a
263+
nested list or tuple. In this case, its elements could be:
264+
265+
1. List, tuple, or range: It holds the individual gene space.
266+
267+
2. Number (int/float): A single value to be assigned to the gene. This
268+
means this gene will have the same value across all generations.
269+
270+
3. ``None``: A gene with its space set to ``None`` is initialized
271+
randomly from the range specified by the 2 parameters
272+
``init_range_low`` and ``init_range_high``. For mutation, its value
273+
is mutated based on a random value from the range specified by the 2
274+
parameters ``random_mutation_min_val`` and
275+
``random_mutation_max_val``. If all elements in the ``gene_space``
276+
parameter are ``None``, the parameter will not have any effect.
277+
278+
Assuming that a chromosome has 2 genes and each gene has a different
279+
value space. Then the ``gene_space`` could be assigned a nested
280+
list/tuple where each element determines the space of a gene. According
281+
to the next code, the space of the first gene is [0.4, -5] which has 2
282+
values and the space for the second gene is [0.5, -3.2, 8.8, -9] which
283+
has 4 values.
284+
285+
.. code:: python
286+
287+
gene_space = [[0.4, -5], [0.5, -3.2, 8.2, -9]]
288+
289+
For a 2 gene chromosome, if the first gene space is restricted to the
290+
discrete values from 0 to 4 and the second gene is restricted to the
291+
values from 10 to 19, then it could be specified according to the next
292+
code.
293+
294+
.. code:: python
295+
296+
gene_space = [range(5), range(10, 20)]
297+
298+
If the user did not assign the initial population to the
299+
``initial_population`` parameter, the the initial population is created
300+
randomly based on the ``gene_space`` parameter. Moreover, the mutation
301+
is applied based on this parameter.
302+
303+
.. _header-n224:
208304

209305
PyGAD Projects at GitHub
210306
========================
@@ -214,7 +310,7 @@ https://pypi.org/project/pygad. PyGAD is built out of a number of
214310
open-source GitHub projects. A brief note about these projects is given
215311
in the next subsections.
216312

217-
.. _header-n79:
313+
.. _header-n89:
218314

219315
`GeneticAlgorithmPython <https://github.com/ahmedfgad/GeneticAlgorithmPython>`__
220316
--------------------------------------------------------------------------------
@@ -225,7 +321,7 @@ GitHub Link: https://github.com/ahmedfgad/GeneticAlgorithmPython
225321
is the first project which is an open-source Python 3 project for
226322
implementing the genetic algorithm based on NumPy.
227323

228-
.. _header-n82:
324+
.. _header-n92:
229325

230326
`NumPyANN <https://github.com/ahmedfgad/NumPyANN>`__
231327
----------------------------------------------------
@@ -239,7 +335,7 @@ neural network without using a training algorithm. Currently, it only
239335
supports classification and later regression will be also supported.
240336
Moreover, only one class is supported per sample.
241337

242-
.. _header-n85:
338+
.. _header-n95:
243339

244340
`NeuralGenetic <https://github.com/ahmedfgad/NeuralGenetic>`__
245341
--------------------------------------------------------------
@@ -252,7 +348,7 @@ projects
252348
`GeneticAlgorithmPython <https://github.com/ahmedfgad/GeneticAlgorithmPython>`__
253349
and `NumPyANN <https://github.com/ahmedfgad/NumPyANN>`__.
254350

255-
.. _header-n88:
351+
.. _header-n98:
256352

257353
`NumPyCNN <https://github.com/ahmedfgad/NumPyCNN>`__
258354
----------------------------------------------------
@@ -264,7 +360,7 @@ convolutional neural networks using NumPy. The purpose of this project
264360
is to only implement the **forward pass** of a convolutional neural
265361
network without using a training algorithm.
266362

267-
.. _header-n91:
363+
.. _header-n101:
268364

269365
`CNNGenetic <https://github.com/ahmedfgad/CNNGenetic>`__
270366
--------------------------------------------------------
@@ -276,7 +372,7 @@ convolutional neural networks using the genetic algorithm. It uses the
276372
`GeneticAlgorithmPython <https://github.com/ahmedfgad/GeneticAlgorithmPython>`__
277373
project for building the genetic algorithm.
278374

279-
.. _header-n94:
375+
.. _header-n104:
280376

281377
Submitting Issues
282378
=================
@@ -293,7 +389,7 @@ is not working properly or to ask for questions.
293389
If this is not a proper option for you, then check the **Contact Us**
294390
section for more contact details.
295391

296-
.. _header-n98:
392+
.. _header-n108:
297393

298394
Ask for Feature
299395
===============
@@ -310,7 +406,7 @@ to ahmed.f.gad@gmail.com.
310406

311407
Also check the **Contact Us** section for more contact details.
312408

313-
.. _header-n102:
409+
.. _header-n112:
314410

315411
Projects Built using PyGAD
316412
==========================
@@ -329,15 +425,15 @@ Within your message, please send the following details:
329425

330426
- Preferably, a link that directs the readers to your project
331427

332-
.. _header-n113:
428+
.. _header-n123:
333429

334430
For More Information
335431
====================
336432

337433
There are different resources that can be used to get started with the
338434
genetic algorithm and building it in Python.
339435

340-
.. _header-n115:
436+
.. _header-n125:
341437

342438
Tutorial: Implementing Genetic Algorithm in Python
343439
--------------------------------------------------
@@ -361,7 +457,7 @@ good resource to start with coding the genetic algorithm.
361457

362458
|image0|
363459

364-
.. _header-n126:
460+
.. _header-n136:
365461

366462
Tutorial: Introduction to Genetic Algorithm
367463
-------------------------------------------
@@ -380,7 +476,7 @@ which is available at these links:
380476

381477
|image1|
382478

383-
.. _header-n136:
479+
.. _header-n146:
384480

385481
Tutorial: Build Neural Networks in Python
386482
-----------------------------------------
@@ -400,7 +496,7 @@ available at these links:
400496

401497
|image2|
402498

403-
.. _header-n146:
499+
.. _header-n156:
404500

405501
Tutorial: Optimize Neural Networks with Genetic Algorithm
406502
---------------------------------------------------------
@@ -420,7 +516,7 @@ available at these links:
420516

421517
|image3|
422518

423-
.. _header-n156:
519+
.. _header-n166:
424520

425521
Tutorial: Building CNN in Python
426522
--------------------------------
@@ -446,7 +542,7 @@ good resource to start with coding CNNs.
446542

447543
|image4|
448544

449-
.. _header-n169:
545+
.. _header-n179:
450546

451547
Tutorial: Derivation of CNN from FCNN
452548
-------------------------------------
@@ -465,7 +561,7 @@ which is available at these links:
465561

466562
|image5|
467563

468-
.. _header-n179:
564+
.. _header-n189:
469565

470566
Book: Practical Computer Vision Applications Using Deep Learning with CNNs
471567
--------------------------------------------------------------------------
@@ -491,7 +587,7 @@ Find the book at these links:
491587
.. figure:: https://user-images.githubusercontent.com/16560492/78830077-ae7c2800-79e7-11ea-980b-53b6bd879eeb.jpg
492588
:alt:
493589

494-
.. _header-n194:
590+
.. _header-n204:
495591

496592
Contact Us
497593
==========

0 commit comments

Comments
 (0)