diff --git a/docs/source/Footer.rst b/docs/source/Footer.rst index 903ce29..fc4b6fe 100644 --- a/docs/source/Footer.rst +++ b/docs/source/Footer.rst @@ -1,12 +1,10 @@ -.. _header-n0: - Release History =============== .. figure:: https://user-images.githubusercontent.com/16560492/101267295-c74c0180-375f-11eb-9ad0-f8e37bd796ce.png :alt: -.. _header-n3: +.. _pygad-1017: PyGAD 1.0.17 ------------ @@ -18,7 +16,7 @@ Release Date: 15 April 2020 values for the solutions. This allows the project to be customized to any problem by building the right fitness function. -.. _header-n8: +.. _pygad-1020: PyGAD 1.0.20 ------------ @@ -38,7 +36,7 @@ Release Date: 4 May 2020 4. The code object ``__code__`` of the passed fitness function is checked to ensure it has the right number of parameters. -.. _header-n19: +.. _pygad-200: PyGAD 2.0.0 ----------- @@ -64,7 +62,7 @@ Release Date: 13 May 2020 is called after each generation. This helps the user to do post-processing or debugging operations after each generation. -.. _header-n30: +.. _pygad-210: PyGAD 2.1.0 ----------- @@ -100,7 +98,7 @@ Release Date: 14 May 2020 2. Mutation is applied independently for the genes. -.. _header-n45: +.. _pygad-221: PyGAD 2.2.1 ----------- @@ -110,7 +108,7 @@ Release Date: 17 May 2020 1. Adding 2 extra modules (pygad.nn and pygad.gann) for building and training neural networks with the genetic algorithm. -.. _header-n50: +.. _pygad-222: PyGAD 2.2.2 ----------- @@ -144,7 +142,7 @@ new gene value is **0.1**. ``crossover_type`` parameters of the pygad.GA class constructor. When ``None``, this means the step is bypassed and has no action. -.. _header-n63: +.. _pygad-230: PyGAD 2.3.0 ----------- @@ -169,7 +167,7 @@ Release date: 1 June 2020 6. The name of the ``pygad.nn.train_network()`` function is changed to ``pygad.nn.train()``. -.. _header-n78: +.. _pygad-240: PyGAD 2.4.0 ----------- @@ -203,11 +201,11 @@ through more generations because no further improvement is possible. .. code:: python - def func_generation(ga_instance): - if ga_instance.best_solution()[1] >= 70: - return "stop" + def func_generation(ga_instance): + if ga_instance.best_solution()[1] >= 70: + return "stop" -.. _header-n88: +.. _pygad-250: PyGAD 2.5.0 ----------- @@ -305,7 +303,7 @@ If the user did not assign the initial population to the randomly based on the ``gene_space`` parameter. Moreover, the mutation is applied based on this parameter. -.. _header-n116: +.. _pygad-260: PyGAD 2.6.0 ----------- @@ -323,7 +321,7 @@ Release Date: 6 August 2020 ``on_fitness``, ``on_parents``, ``on_crossover``, ``on_mutation``, ``on_generation``, and ``on_stop``. -.. _header-n125: +.. _pygad-270: PyGAD 2.7.0 ----------- @@ -382,7 +380,7 @@ parameter or set it to ``"classification"`` (default value). In this case, the activation function of the last layer can be set to any type (e.g. softmax). -.. _header-n149: +.. _pygad-271: PyGAD 2.7.1 ----------- @@ -392,7 +390,7 @@ Release Date: 11 September 2020 1. A bug fix when the ``problem_type`` argument is set to ``regression``. -.. _header-n154: +.. _pygad-272: PyGAD 2.7.2 ----------- @@ -402,7 +400,7 @@ Release Date: 14 September 2020 1. Bug fix to support building and training regression neural networks with multiple outputs. -.. _header-n159: +.. _pygad-280: PyGAD 2.8.0 ----------- @@ -412,7 +410,7 @@ Release Date: 20 September 2020 1. Support of a new module named ``kerasga`` so that the Keras models can be trained by the genetic algorithm using PyGAD. -.. _header-n164: +.. _pygad-281: PyGAD 2.8.1 ----------- @@ -425,7 +423,7 @@ Release Date: 3 October 2020 Management, Faculty of Engineering, Alexandria University, Egypt `__. -.. _header-n169: +.. _pygad-290: PyGAD 2.9.0 ----------- @@ -453,7 +451,7 @@ Release Date: 06 December 2020 ``numpy.int64``, ``numpy.float``, ``numpy.float16``, ``numpy.float32``, or ``numpy.float64``. -.. _header-n182: +.. _pygad-2100: PyGAD 2.10.0 ------------ @@ -514,7 +512,7 @@ Release Date: 03 January 2021 ``cal_pop_fitness()`` method is called to calculate the fitness values of the population. -.. _header-n207: +.. _pygad-2101: PyGAD 2.10.1 ------------ @@ -546,7 +544,7 @@ Release Date: 10 January 2021 pointing about that at `GitHub `__. -.. _header-n218: +.. _pygad-2102: PyGAD 2.10.2 ------------ @@ -557,7 +555,7 @@ Release Date: 15 January 2021 more information: https://github.com/ahmedfgad/GeneticAlgorithmPython/issues/25 -.. _header-n223: +.. _pygad-2110: PyGAD 2.11.0 ------------ @@ -590,7 +588,7 @@ Release Date: 16 February 2021 is verified that the new value is changed. So, if the current value is 0, then the new value after mutation will not be 0 but 1. -.. _header-n234: +.. _pygad-2120: PyGAD 2.12.0 ------------ @@ -632,7 +630,7 @@ of Thessaloniki (Αριστοτέλειο Πανεπιστήμιο Θεσσαλ Greece `__, for emailing me about the second issue. -.. _header-n243: +.. _pygad-2130: PyGAD 2.13.0 ------------ @@ -652,7 +650,46 @@ Release Date: 12 March 2021 most up-to-date population assigned to the ``last_generation_fitness`` parameter. -.. _header-n250: +.. _pygad-2140: + +PyGAD 2.14.0 +------------ + +Release Date: 19 May 2021 + +1. `Issue + #40 `__ + is solved. Now, the ``None`` value works with the ``crossover_type`` + and ``mutation_type`` parameters: + https://github.com/ahmedfgad/GeneticAlgorithmPython/issues/40 + +2. The ``gene_type`` parameter supports accepting a + ``list/tuple/numpy.ndarray`` of numeric data types for the genes. + This helps to control the data type of each individual gene. + Previously, the ``gene_type`` can be assigned only to a single data + type that is applied for all genes. + +3. A new ``bool`` attribute named ``gene_type_single`` is added to the + ``pygad.GA`` class. It is ``True`` when there is a single data type + assigned to the ``gene_type`` parameter. When the ``gene_type`` + parameter is assigned a ``list/tuple/numpy.ndarray``, then + ``gene_type_single`` is set to ``False``. + +4. The ``mutation_by_replacement`` flag now has no effect if + ``gene_space`` exists except for the genes with ``None`` values. For + example, for ``gene_space=[None, [5, 6]]`` the + ``mutation_by_replacement`` flag affects only the first gene which + has ``None`` for its value space. + +5. When an element has a value of ``None`` in the ``gene_space`` + parameter (e.g. ``gene_space=[None, [5, 6]]``), then its value will + be randomly generated for each solution rather than being generate + once for all solutions. Previously, the gene with ``None`` value in + ``gene_space`` is the same across all solutions + +6. Some changes in the documentation according to `issue + #32 `__: + https://github.com/ahmedfgad/GeneticAlgorithmPython/issues/32 PyGAD Projects at GitHub ======================== @@ -662,8 +699,6 @@ https://pypi.org/project/pygad. PyGAD is built out of a number of open-source GitHub projects. A brief note about these projects is given in the next subsections. -.. _header-n252: - `GeneticAlgorithmPython `__ -------------------------------------------------------------------------------- @@ -673,8 +708,6 @@ GitHub Link: https://github.com/ahmedfgad/GeneticAlgorithmPython is the first project which is an open-source Python 3 project for implementing the genetic algorithm based on NumPy. -.. _header-n255: - `NumPyANN `__ ---------------------------------------------------- @@ -687,8 +720,6 @@ neural network without using a training algorithm. Currently, it only supports classification and later regression will be also supported. Moreover, only one class is supported per sample. -.. _header-n258: - `NeuralGenetic `__ -------------------------------------------------------------- @@ -700,8 +731,6 @@ projects `GeneticAlgorithmPython `__ and `NumPyANN `__. -.. _header-n261: - `NumPyCNN `__ ---------------------------------------------------- @@ -712,8 +741,6 @@ convolutional neural networks using NumPy. The purpose of this project is to only implement the **forward pass** of a convolutional neural network without using a training algorithm. -.. _header-n264: - `CNNGenetic `__ -------------------------------------------------------- @@ -724,8 +751,6 @@ convolutional neural networks using the genetic algorithm. It uses the `GeneticAlgorithmPython `__ project for building the genetic algorithm. -.. _header-n267: - `KerasGA `__ -------------------------------------------------- @@ -737,8 +762,6 @@ the `GeneticAlgorithmPython `__ project for building the genetic algorithm. -.. _header-n270: - `TorchGA `__ -------------------------------------------------- @@ -753,33 +776,29 @@ project for building the genetic algorithm. `pygad.torchga `__: https://github.com/ahmedfgad/TorchGA -.. _header-n274: - Stackoverflow Questions about PyGAD =================================== -.. _header-n275: - -`How can I save a matplotlib plot that is the output of a function in jupyter? `__ -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +.. _how-do-i-proceed-to-load-a-gainstance-as-pkl-format-in-pygad: -.. _header-n276: +`How do I proceed to load a ga_instance as “.pkl” format in PyGad? `__ +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -`How do I query the best solution of a pyGAD GA instance? `__ -------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -.. _header-n277: +`Binary Classification NN Model Weights not being Trained in PyGAD `__ +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- `How to solve TSP problem using pyGAD package? `__ --------------------------------------------------------------------------------------------------------------------------------------------- -.. _header-n278: +`How can I save a matplotlib plot that is the output of a function in jupyter? `__ +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +`How do I query the best solution of a pyGAD GA instance? `__ +------------------------------------------------------------------------------------------------------------------------------------------------------------------- `Multi-Input Multi-Output in Genetic algorithm (python) `__ -------------------------------------------------------------------------------------------------------------------------------------------------------------- -.. _header-n279: - Submitting Issues ================= @@ -796,8 +815,6 @@ If this is not a proper option for you, then check the `Contact Us `__ section for more contact details. -.. _header-n283: - Ask for Feature =============== @@ -815,8 +832,6 @@ Also check the `Contact Us `__ section for more contact details. -.. _header-n287: - Projects Built using PyGAD ========================== @@ -836,12 +851,27 @@ Within your message, please send the following details: - Preferably, a link that directs the readers to your project -.. _header-n298: - Tutorials about PyGAD ===================== -.. _header-n299: +`Adaptive Mutation in Genetic Algorithm with Python Examples `__ +----------------------------------------------------------------------------------------------------------------------------------------------------- + +In this tutorial, we’ll see why mutation with a fixed number of genes is +bad, and how to replace it with adaptive mutation. Using the `PyGAD +Python 3 library `__, we’ll discuss a few +examples that use both random and adaptive mutation. + +`Clustering Using the Genetic Algorithm in Python `__ +------------------------------------------------------------------------------------------------------------------------- + +This tutorial discusses how the genetic algorithm is used to cluster +data, starting from random clusters and running until the optimal +clusters are found. We'll start by briefly revising the K-means +clustering algorithm to point out its weak points, which are later +solved by the genetic algorithm. The code examples in this tutorial are +implemented in Python using the `PyGAD +library `__. `Working with Different Genetic Algorithm Representations in Python `__ -------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -857,7 +887,7 @@ This tutorial discusses how the `PyGAD `__ library supports the two GA representations, binary and decimal. -.. _header-n302: +.. _5-genetic-algorithm-applications-using-pygad: `5 Genetic Algorithm Applications Using PyGAD `__ ------------------------------------------------------------------------------------------------------------------------- @@ -870,8 +900,6 @@ algorithm for various applications. Within this tutorial we'll discuss 5 different applications of the genetic algorithm and build them using PyGAD. -.. _header-n305: - `Train Neural Networks Using a Genetic Algorithm in Python with PyGAD `__ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -897,7 +925,31 @@ library that supports building and training NNs using a GA. `PyGAD `__ offers both classification and regression NNs. -.. _header-n310: +`Building a Game-Playing Agent for CoinTex Using the Genetic Algorithm `__ +---------------------------------------------------------------------------------------------------------------------------------------------------------- + +In this tutorial we'll see how to build a game-playing agent using only +the genetic algorithm to play a game called +`CoinTex `__, +which is developed in the Kivy Python framework. The objective of +CoinTex is to collect the randomly distributed coins while avoiding +collision with fire and monsters (that move randomly). The source code +of CoinTex can be found `on +GitHub `__. + +The genetic algorithm is the only AI used here; there is no other +machine/deep learning model used with it. We'll implement the genetic +algorithm using +`PyGad `__. +This tutorial starts with a quick overview of CoinTex followed by a +brief explanation of the genetic algorithm, and how it can be used to +create the playing agent. Finally, we'll see how to implement these +ideas in Python. + +The source code of the genetic algorithm agent is available +`here `__, +and you can download the code used in this tutorial from +`here `__. `How To Train Keras Models Using the Genetic Algorithm with PyGAD `__ -------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -925,8 +977,6 @@ model parameters, creating an appropriate fitness function, and more. |image1| -.. _header-n316: - `Train PyTorch Models Using Genetic Algorithm with PyGAD `__ --------------------------------------------------------------------------------------------------------------------------------------------- @@ -947,13 +997,9 @@ models. |image2| -.. _header-n321: - PyGAD in Other Languages ======================== -.. _header-n322: - French ------ @@ -973,8 +1019,6 @@ CartPole . J'utiliserai PyTorch et PyGAD . |image3| -.. _header-n327: - Spanish ------- @@ -993,13 +1037,9 @@ PyGAD . |image4| -.. _header-n332: - Korean ------ -.. _header-n333: - `[PyGAD] Python 에서 Genetic Algorithm 을 사용해보기 `__ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1019,13 +1059,9 @@ Korean 사실 완전히 흐름이나 각 parameter에 대한 이해는 부족한 상황 -.. _header-n340: - Turkish ------- -.. _header-n341: - `PyGAD ile Genetik Algoritmayı Kullanarak Keras Modelleri Nasıl Eğitilir `__ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1058,12 +1094,10 @@ fazlasını içerir. |image6| -.. _header-n348: - Hungarian --------- -.. _header-n349: +.. _tensorflow-alapozó-10-neurális-hálózatok-tenyésztése-genetikus-algoritmussal-pygad-és-openai-gym-használatával: `Tensorflow alapozó 10. Neurális hálózatok tenyésztése genetikus algoritmussal PyGAD és OpenAI Gym használatával `__ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1092,13 +1126,9 @@ initial_population paraméterben. |image7| -.. _header-n354: - Russian ------- -.. _header-n355: - `PyGAD: библиотека для имплементации генетического алгоритма `__ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1125,16 +1155,12 @@ PyGAD разрабатывали на Python 3.7.3. Зависимости вк |image8| -.. _header-n362: - For More Information ==================== There are different resources that can be used to get started with the genetic algorithm and building it in Python. -.. _header-n364: - Tutorial: Implementing Genetic Algorithm in Python -------------------------------------------------- @@ -1157,8 +1183,6 @@ good resource to start with coding the genetic algorithm. |image9| -.. _header-n375: - Tutorial: Introduction to Genetic Algorithm ------------------------------------------- @@ -1176,8 +1200,6 @@ which is available at these links: |image10| -.. _header-n385: - Tutorial: Build Neural Networks in Python ----------------------------------------- @@ -1196,8 +1218,6 @@ available at these links: |image11| -.. _header-n395: - Tutorial: Optimize Neural Networks with Genetic Algorithm --------------------------------------------------------- @@ -1216,8 +1236,6 @@ available at these links: |image12| -.. _header-n405: - Tutorial: Building CNN in Python -------------------------------- @@ -1242,8 +1260,6 @@ good resource to start with coding CNNs. |image13| -.. _header-n418: - Tutorial: Derivation of CNN from FCNN ------------------------------------- @@ -1261,8 +1277,6 @@ which is available at these links: |image14| -.. _header-n428: - Book: Practical Computer Vision Applications Using Deep Learning with CNNs -------------------------------------------------------------------------- @@ -1287,8 +1301,6 @@ Find the book at these links: .. figure:: https://user-images.githubusercontent.com/16560492/78830077-ae7c2800-79e7-11ea-980b-53b6bd879eeb.jpg :alt: -.. _header-n443: - Contact Us ========== diff --git a/docs/source/README_pygad_ReadTheDocs.rst b/docs/source/README_pygad_ReadTheDocs.rst index 2b176a0..6fda3a1 100644 --- a/docs/source/README_pygad_ReadTheDocs.rst +++ b/docs/source/README_pygad_ReadTheDocs.rst @@ -1,5 +1,3 @@ -.. _header-n0: - ``pygad`` Module ================ @@ -9,7 +7,7 @@ This section of the PyGAD's library documentation discusses the Using the ``pygad`` module, instances of the genetic algorithm can be created, run, saved, and loaded. -.. _header-n4: +.. _pygadga-class: ``pygad.GA`` Class ================== @@ -19,7 +17,7 @@ class named ``GA`` for building the genetic algorithm. The constructor, methods, function, and attributes within the class are discussed in this section. -.. _header-n6: +.. _init: ``__init__()`` -------------- @@ -63,11 +61,15 @@ The ``pygad.GA`` class constructor supports the following parameters: parameter is not needed if the user feeds the initial population to the ``initial_population`` parameter. -- ``gene_type=float``: Controls the gene type. It has an effect only - when the parameter ``gene_space`` is ``None`` (which is its default - value). Starting from PyGAD 2.9.0, the ``gene_type`` parameter can be - assigned to a numeric value of any of these types: ``int``, - ``float``, and ``numpy.int/uint/float(8-64)``. +- ``gene_type=float``: Controls the gene type. It can be assigned to a + single data type that is applied to all genes or can specify the data + type of each individual gene. It defaults to ``float`` which means + all genes are of ``float`` data type. Starting from PyGAD 2.9.0, the + ``gene_type`` parameter can be assigned to a numeric value of any of + these types: ``int``, ``float``, and ``numpy.int/uint/float(8-64)``. + Starting from PyGAD 2.14.0, it can be assigned to a ``list``, + ``tuple``, or a ``numpy.ndarray`` which hold a data type for each + gene. This helps to control the data type of each individual gene. - ``init_range_low=-4``: The lower value of the random range from which the gene values in the initial population are selected. @@ -302,8 +304,6 @@ that the best solution in the initial population. The parameters are validated within the constructor. If at least a parameter is not validated, an exception is thrown. -.. _header-n82: - Class Attributes ---------------- @@ -316,7 +316,7 @@ Class Attributes - ``supported_int_float_types``: A list of the supported types for all numbers. It just concatenates the previous 2 lists. -.. _header-n90: +.. _other-instance-attributes--methods: Other Instance Attributes & Methods ----------------------------------- @@ -328,8 +328,6 @@ attributes and methods added to the instances of the **pygad.GA** class: The next 2 subsections list such attributes and methods. -.. _header-n93: - Other Attributes ~~~~~~~~~~~~~~~~ @@ -373,11 +371,16 @@ Other Attributes applying the mutation in the last generation. `Added in PyGAD 2.12.0 `__. +- ``gene_type_single``: A flag that is set to ``True`` if the + ``gene_type`` parameter is assigned to a single data type that is + applied to all genes. If ``gene_type`` is assigned a ``list``, + ``tuple``, or ``numpy.ndarray``, then the value of + ``gene_type_single`` will be ``False``. `Added in PyGAD + 2.14.0 `__. + Note that the attributes with its name start with ``last_generation_`` are updated after each generation. -.. _header-n120: - Other Methods ~~~~~~~~~~~~~ @@ -421,7 +424,7 @@ Other Methods The next sections discuss the methods available in the **pygad.GA** class. -.. _header-n143: +.. _initializepopulation: ``initialize_population()`` --------------------------- @@ -448,7 +451,7 @@ This method assigns the values of the following 3 instance attributes: 3. ``initial_population``: Keeping the initial population. -.. _header-n159: +.. _calpopfitness: ``cal_pop_fitness()`` --------------------- @@ -462,8 +465,6 @@ constructor for each solution. It returns an array of the solutions' fitness values. -.. _header-n163: - ``run()`` --------- @@ -506,8 +507,6 @@ After the ``run()`` method completes, the following takes place: - The ``run_completed`` attribute is set to ``True``. -.. _header-n182: - Parent Selection Methods ------------------------ @@ -524,50 +523,48 @@ All of such methods return an array of the selected parents. The next subsections list the supported methods for parent selection. -.. _header-n191: +.. _steadystateselection: ``steady_state_selection()`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Selects the parents using the steady-state selection technique. -.. _header-n193: +.. _rankselection: ``rank_selection()`` ~~~~~~~~~~~~~~~~~~~~ Selects the parents using the rank selection technique. -.. _header-n195: +.. _randomselection: ``random_selection()`` ~~~~~~~~~~~~~~~~~~~~~~ Selects the parents randomly. -.. _header-n197: +.. _tournamentselection: ``tournament_selection()`` ~~~~~~~~~~~~~~~~~~~~~~~~~~ Selects the parents using the tournament selection technique. -.. _header-n199: +.. _roulettewheelselection: ``roulette_wheel_selection()`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Selects the parents using the roulette wheel selection technique. -.. _header-n201: +.. _stochasticuniversalselection: ``stochastic_universal_selection()`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Selects the parents using the stochastic universal selection technique. -.. _header-n203: - Crossover Methods ----------------- @@ -583,7 +580,7 @@ All of such methods return an array of the produced offspring. The next subsections list the supported methods for crossover. -.. _header-n212: +.. _singlepointcrossover: ``single_point_crossover()`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -591,7 +588,7 @@ The next subsections list the supported methods for crossover. Applies the single-point crossover. It selects a point randomly at which crossover takes place between the pairs of parents. -.. _header-n214: +.. _twopointscrossover: ``two_points_crossover()`` ~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -599,7 +596,7 @@ crossover takes place between the pairs of parents. Applies the 2 points crossover. It selects the 2 points randomly at which crossover takes place between the pairs of parents. -.. _header-n216: +.. _uniformcrossover: ``uniform_crossover()`` ~~~~~~~~~~~~~~~~~~~~~~~ @@ -607,7 +604,7 @@ which crossover takes place between the pairs of parents. Applies the uniform crossover. For each gene, a parent out of the 2 mating parents is selected randomly and the gene is copied from it. -.. _header-n218: +.. _scatteredcrossover: ``scattered_crossover()`` ~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -615,8 +612,6 @@ mating parents is selected randomly and the gene is copied from it. Applies the scattered crossover. It randomly selects the gene from one of the 2 parents. -.. _header-n220: - Mutation Methods ---------------- @@ -629,7 +624,7 @@ All of such methods return an array of the mutated offspring. The next subsections list the supported methods for mutation. -.. _header-n227: +.. _randommutation: ``random_mutation()`` ~~~~~~~~~~~~~~~~~~~~~ @@ -643,7 +638,7 @@ specified by the 2 attributes ``random_mutation_min_val`` and ``random_mutation_max_val``. The random value is added to the selected gene. -.. _header-n230: +.. _swapmutation: ``swap_mutation()`` ~~~~~~~~~~~~~~~~~~~ @@ -651,7 +646,7 @@ gene. Applies the swap mutation which interchanges the values of 2 randomly selected genes. -.. _header-n232: +.. _inversionmutation: ``inversion_mutation()`` ~~~~~~~~~~~~~~~~~~~~~~~~ @@ -659,7 +654,7 @@ selected genes. Applies the inversion mutation which selects a subset of genes and inverts them. -.. _header-n234: +.. _scramblemutation: ``scramble_mutation()`` ~~~~~~~~~~~~~~~~~~~~~~~ @@ -667,7 +662,7 @@ inverts them. Applies the scramble mutation which selects a subset of genes and shuffles their order randomly. -.. _header-n236: +.. _adaptivemutation: ``adaptive_mutation()`` ~~~~~~~~~~~~~~~~~~~~~~~ @@ -675,7 +670,7 @@ shuffles their order randomly. Applies the adaptive mutation which selects a subset of genes and shuffles their order randomly. -.. _header-n238: +.. _bestsolution: ``best_solution()`` ------------------- @@ -699,7 +694,7 @@ It returns the following: - ``best_match_idx``: Index of the best solution in the current population. -.. _header-n252: +.. _plotresult: ``plot_result()`` ----------------- @@ -722,8 +717,6 @@ Starting from PyGAD 2.5.0, a new optional parameter named ``linewidth`` is added to specify the width of the curve in the plot. It defaults to ``3.0``. -.. _header-n264: - ``save()`` ---------- @@ -734,8 +727,6 @@ Accepts the following parameter: - ``filename``: Name of the file to save the instance. No extension is needed. -.. _header-n270: - Functions in ``pygad`` ====================== @@ -743,7 +734,7 @@ 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()``. -.. _header-n272: +.. _pygadload: ``pygad.load()`` ---------------- @@ -760,8 +751,6 @@ Accepts the following parameter: Returns the genetic algorithm instance. -.. _header-n279: - Steps to Use ``pygad`` ====================== @@ -785,7 +774,7 @@ To use the ``pygad`` module, here is a summary of the required steps: Let's discuss how to do each of these steps. -.. _header-n299: +.. _preparing-the-fitnessfunc-parameter: Preparing the ``fitness_func`` Parameter ---------------------------------------- @@ -845,8 +834,6 @@ an exception is thrown. By creating this function, you almost did an awesome step towards using PyGAD. -.. _header-n315: - Preparing Other Parameters ~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -873,14 +860,14 @@ Here is an example for preparing the other parameters: mutation_type = "random" mutation_percent_genes = 10 -.. _header-n318: +.. _the-callbackgeneration-parameter: The ``callback_generation`` Parameter ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -==This parameter should be replaced by ``on_generation``. The +This parameter should be replaced by ``on_generation``. The ``callback_generation`` parameter will be removed in a later release of -PyGAD.== +PyGAD. In PyGAD 2.0.0 and higher, an optional parameter named ``callback_generation`` is supported which allows the user to call a @@ -910,8 +897,6 @@ generation. After the parameters are prepared, we can import PyGAD and build an instance of the **pygad.GA** class. -.. _header-n325: - Import the ``pygad`` -------------------- @@ -924,7 +909,7 @@ The next step is to import PyGAD as follows: The **pygad.GA** class holds the implementation of all methods for running the genetic algorithm. -.. _header-n329: +.. _create-an-instance-of-the-pygadga-class-1: Create an Instance of the ``pygad.GA`` Class -------------------------------------------- @@ -948,8 +933,6 @@ for creating the initial population. mutation_type=mutation_type, mutation_percent_genes=mutation_percent_genes) -.. _header-n332: - Run the Genetic Algorithm ------------------------- @@ -972,8 +955,6 @@ by doing the following tasks: 4. Repeat the process for the specified number of generations. -.. _header-n345: - Plotting Results ---------------- @@ -988,8 +969,6 @@ generations. .. figure:: https://user-images.githubusercontent.com/16560492/78830005-93111d00-79e7-11ea-9d8e-a8d8325a6101.png :alt: -.. _header-n349: - Information about the Best Solution ----------------------------------- @@ -1018,7 +997,7 @@ fitness** is reached could be fetched. if ga_instance.best_solution_generation != -1: print("Best fitness value reached after {best_solution_generation} generations.".format(best_solution_generation=ga_instance.best_solution_generation)) -.. _header-n361: +.. _saving--loading-the-results: Saving & Loading the Results ---------------------------- @@ -1051,8 +1030,6 @@ any property. print(loaded_ga_instance.best_solution()) -.. _header-n368: - Crossover, Mutation, and Parent Selection ========================================= @@ -1061,8 +1038,6 @@ the crossover & mutation operators. More features will be added in the future. To ask for a new feature, please check the **Ask for Feature** section. -.. _header-n370: - Supported Crossover Operations ------------------------------ @@ -1075,8 +1050,6 @@ The supported crossover operations at this time are: 3. Uniform: Implemented using the ``uniform_crossover()`` method. -.. _header-n379: - Supported Mutation Operations ----------------------------- @@ -1090,8 +1063,6 @@ The supported mutation operations at this time are: 4. Scramble: Implemented using the ``scramble_mutation()`` method. -.. _header-n390: - Supported Parent Selection Operations ------------------------------------- @@ -1112,8 +1083,6 @@ The supported parent selection techniques at this time are: 6. Tournament: Implemented using the ``tournament_selection()`` method. -.. _header-n405: - Life Cycle of PyGAD =================== @@ -1207,8 +1176,6 @@ argument, here is the output. on_stop() -.. _header-n412: - Adaptive Mutation ================= @@ -1269,8 +1236,6 @@ The next figure summarizes the previous steps. This strategy is applied in PyGAD. -.. _header-n434: - Use Adaptive Mutation in PyGAD ------------------------------ @@ -1373,8 +1338,6 @@ Here is an example that uses adaptive mutation. ga_instance.plot_result(title="PyGAD with Adaptive Mutation", linewidth=5) -.. _header-n463: - Limit the Gene Value Range ========================== @@ -1452,8 +1415,6 @@ take any floating-point value from the range that starts from 1 gene_space = [{'low': 1, 'high': 5}, {'low': 0.3, 'high': 1.4}, {'low': -0.2, 'high': 4.5}] -.. _header-n490: - Stop at Any Generation ====================== @@ -1481,8 +1442,6 @@ exceeds 70, then the string ``"stop"`` is returned. if ga_instance.best_solution()[1] >= 70: return "stop" -.. _header-n495: - Prevent Duplicates in Gene Values ================================= @@ -1641,8 +1600,6 @@ non-duplicating genes that may make a room for a unique value in one the duplicates. The resultant gene is then ``[3 4 2 0]``. **But this option is not yet supported in PyGAD.** -.. _header-n509: - Parallel Processing in PyGAD ============================ @@ -1680,16 +1637,12 @@ Fazekas `__: `How Genetic Algorithms Can Compete with Gradient Descent and Backprop `__ -.. _header-n520: - Examples ======== This section gives the complete code of some examples that use ``pygad``. Each subsection builds a different example. -.. _header-n522: - Linear Model Optimization ------------------------- @@ -1790,8 +1743,6 @@ which optimizes a linear model. Its complete code is listed below. loaded_ga_instance = pygad.load(filename=filename) loaded_ga_instance.plot_result() -.. _header-n525: - Reproducing Images ------------------ @@ -1811,8 +1762,6 @@ available at these links: - `LinkedIn `__: https://www.linkedin.com/pulse/reproducing-images-using-genetic-algorithm-python-ahmed-gad -.. _header-n533: - Project Steps ~~~~~~~~~~~~~ @@ -1833,8 +1782,6 @@ The steps to follow in order to reproduce an image are as follows: The next sections discusses the code of each of these steps. -.. _header-n549: - Read an Image ~~~~~~~~~~~~~ @@ -1863,8 +1810,6 @@ range from which the random values are selected during mutation and also the range of the values used in the initial population. So, be consistent. -.. _header-n556: - Prepare the Fitness Function ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1913,7 +1858,7 @@ its code is listed below. return numpy.reshape(a=vector, newshape=shape) -.. _header-n562: +.. _create-an-instance-of-the-pygadga-class-2: Create an Instance of the ``pygad.GA`` Class ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1949,8 +1894,6 @@ the full list of parameters. random_mutation_min_val=0.0, random_mutation_max_val=1.0) -.. _header-n567: - Run PyGAD ~~~~~~~~~ @@ -1960,8 +1903,6 @@ Simply, call the ``run()`` method to run PyGAD. ga_instance.run() -.. _header-n570: - Plot Results ~~~~~~~~~~~~ @@ -1977,8 +1918,6 @@ Here is the plot after 20,000 generations. .. figure:: https://user-images.githubusercontent.com/16560492/82232124-77762c00-992e-11ea-9fc6-14a1cd7a04ff.png :alt: -.. _header-n575: - Calculate Some Statistics ~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1999,8 +1938,6 @@ Here is some information about the best solution. matplotlib.pyplot.title("PyGAD & GARI for Reproducing Images") matplotlib.pyplot.show() -.. _header-n578: - Evolution by Generation ~~~~~~~~~~~~~~~~~~~~~~~ @@ -2056,8 +1993,6 @@ Here is how the image is evolved from generation 0 to generation .. figure:: https://user-images.githubusercontent.com/16560492/82232405-e0f63a80-992e-11ea-984f-b6ed76465bd1.png :alt: -.. _header-n599: - Clustering ---------- @@ -2071,8 +2006,6 @@ Soon a tutorial will be published at `Paperspace `__ to explain how clustering works using the genetic algorithm with examples in PyGAD. -.. _header-n603: - CoinTex Game Playing using PyGAD -------------------------------- diff --git a/docs/source/conf.py b/docs/source/conf.py index 6194d81..fcb93ce 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -22,7 +22,7 @@ author = 'Ahmed Fawzy Gad' # The full version, including alpha/beta/rc tags -release = '2.13.0' +release = '2.14.1' master_doc = 'index' diff --git a/docs/source/index.rst b/docs/source/index.rst index ea18d75..d8d084a 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -12,7 +12,8 @@ Welcome to PyGAD's documentation! `PyGAD `__ is an open-source Python library for building the genetic algorithm and -optimizing machine learning algorithms. +optimizing machine learning algorithms. It works with +`Keras `__ and `PyTorch `__. `PyGAD `__ supports different types of crossover, mutation, and parent selection operators. @@ -37,7 +38,7 @@ classification problems. The library is under active development and more features added regularly. Please contact us if you want a feature to be supported. -.. _header-n69: +.. _donation--support: Donation & Support ================== @@ -56,8 +57,6 @@ You can donate to PyGAD via: - Buy a product at `Teespring `__: `pygad.creator-spring.com `__ -.. _header-n62: - Installation ============ @@ -66,14 +65,7 @@ download and install the library from `PyPI `__ (Python Package Index). The library lives a PyPI at this page https://pypi.org/project/pygad. -For Windows, issue the following command: - -.. code:: python - - pip install pygad - -For Linux and Mac, replace ``pip`` by use ``pip3`` because the library -only supports Python 3. +Install PyGAD with the following command: .. code:: python