Skip to content

Commit b91a206

Browse files
committed
Update example
1 parent 464bfd6 commit b91a206

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

docs/source/README_pygad_ReadTheDocs.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ It returns the following:
913913
- ``best_match_idx``: Index of the best solution in the current
914914
population.
915915

916-
.. _plotfitness-1:
916+
.. _plotfitness:
917917

918918
``plot_fitness()``
919919
------------------
@@ -946,7 +946,7 @@ and higher, this method accepts the following parameters:
946946

947947
8. ``save_dir``: Directory to save the figure.
948948

949-
.. _plotnewsolutionrate-1:
949+
.. _plotnewsolutionrate:
950950

951951
``plot_new_solution_rate()``
952952
----------------------------
@@ -979,7 +979,7 @@ This method accepts the following parameters:
979979

980980
8. ``save_dir``: Directory to save the figure.
981981

982-
.. _plotgenes-1:
982+
.. _plotgenes:
983983

984984
``plot_genes()``
985985
----------------
@@ -1229,7 +1229,7 @@ The next step is to import PyGAD as follows:
12291229
The ``pygad.GA`` class holds the implementation of all methods for
12301230
running the genetic algorithm.
12311231

1232-
.. _create-an-instance-of-the-pygadga-class-1:
1232+
.. _create-an-instance-of-the-pygadga-class:
12331233

12341234
Create an Instance of the ``pygad.GA`` Class
12351235
--------------------------------------------
@@ -2403,6 +2403,8 @@ The function should return 2 outputs:
24032403
2. The indices of the selected parents inside the population. It is a 1D
24042404
list with length equal to the number of selected parents.
24052405

2406+
The outputs must be of type ``numpy.ndarray``.
2407+
24062408
Here is a template for building a custom parent selection function.
24072409

24082410
.. code:: python
@@ -2427,7 +2429,7 @@ parents are selected. The number of parents is equal to the value in the
24272429
for parent_num in range(num_parents):
24282430
parents[parent_num, :] = ga_instance.population[fitness_sorted[parent_num], :].copy()
24292431
2430-
return parents, fitness_sorted[:num_parents]
2432+
return parents, numpy.array(fitness_sorted[:num_parents])
24312433
24322434
Finally, the defined function is assigned to the
24332435
``parent_selection_type`` parameter as in the next code.
@@ -2474,7 +2476,7 @@ previous 3 user-defined functions instead of the built-in functions.
24742476
for parent_num in range(num_parents):
24752477
parents[parent_num, :] = ga_instance.population[fitness_sorted[parent_num], :].copy()
24762478
2477-
return parents, fitness_sorted[:num_parents]
2479+
return parents, numpy.array(fitness_sorted[:num_parents])
24782480
24792481
def crossover_func(parents, offspring_size, ga_instance):
24802482
@@ -3004,7 +3006,7 @@ methods.
30043006
The ``plot_fitness()`` method shows the fitness value for each
30053007
generation.
30063008

3007-
.. _plottypeplot-1:
3009+
.. _plottypeplot:
30083010

30093011
``plot_type="plot"``
30103012
~~~~~~~~~~~~~~~~~~~~
@@ -3021,7 +3023,7 @@ line connecting the fitness values across all generations:
30213023
.. figure:: https://user-images.githubusercontent.com/16560492/122472609-d02f5280-cf8e-11eb-88a7-f9366ff6e7c6.png
30223024
:alt:
30233025

3024-
.. _plottypescatter-1:
3026+
.. _plottypescatter:
30253027

30263028
``plot_type="scatter"``
30273029
~~~~~~~~~~~~~~~~~~~~~~~
@@ -3037,7 +3039,7 @@ these dots can be changed using the ``linewidth`` parameter.
30373039
.. figure:: https://user-images.githubusercontent.com/16560492/122473159-75e2c180-cf8f-11eb-942d-31279b286dbd.png
30383040
:alt:
30393041

3040-
.. _plottypebar-1:
3042+
.. _plottypebar:
30413043

30423044
``plot_type="bar"``
30433045
~~~~~~~~~~~~~~~~~~~
@@ -3393,8 +3395,6 @@ parameter:
33933395
given the value 0, this means do not use parallel processing. This is
33943396
identical to ``parallel_processing=None``.
33953397

3396-
.. _examples-1:
3397-
33983398
Examples
33993399
--------
34003400

0 commit comments

Comments
 (0)