@@ -913,7 +913,7 @@ It returns the following:
913
913
- ``best_match_idx ``: Index of the best solution in the current
914
914
population.
915
915
916
- .. _plotfitness-1 :
916
+ .. _plotfitness :
917
917
918
918
``plot_fitness() ``
919
919
------------------
@@ -946,7 +946,7 @@ and higher, this method accepts the following parameters:
946
946
947
947
8. ``save_dir ``: Directory to save the figure.
948
948
949
- .. _plotnewsolutionrate-1 :
949
+ .. _plotnewsolutionrate :
950
950
951
951
``plot_new_solution_rate() ``
952
952
----------------------------
@@ -979,7 +979,7 @@ This method accepts the following parameters:
979
979
980
980
8. ``save_dir ``: Directory to save the figure.
981
981
982
- .. _plotgenes-1 :
982
+ .. _plotgenes :
983
983
984
984
``plot_genes() ``
985
985
----------------
@@ -1229,7 +1229,7 @@ The next step is to import PyGAD as follows:
1229
1229
The ``pygad.GA `` class holds the implementation of all methods for
1230
1230
running the genetic algorithm.
1231
1231
1232
- .. _create-an-instance-of-the-pygadga-class-1 :
1232
+ .. _create-an-instance-of-the-pygadga-class :
1233
1233
1234
1234
Create an Instance of the ``pygad.GA `` Class
1235
1235
--------------------------------------------
@@ -2403,6 +2403,8 @@ The function should return 2 outputs:
2403
2403
2. The indices of the selected parents inside the population. It is a 1D
2404
2404
list with length equal to the number of selected parents.
2405
2405
2406
+ The outputs must be of type ``numpy.ndarray ``.
2407
+
2406
2408
Here is a template for building a custom parent selection function.
2407
2409
2408
2410
.. code :: python
@@ -2427,7 +2429,7 @@ parents are selected. The number of parents is equal to the value in the
2427
2429
for parent_num in range (num_parents):
2428
2430
parents[parent_num, :] = ga_instance.population[fitness_sorted[parent_num], :].copy()
2429
2431
2430
- return parents, fitness_sorted[:num_parents]
2432
+ return parents, numpy.array( fitness_sorted[:num_parents])
2431
2433
2432
2434
Finally, the defined function is assigned to the
2433
2435
``parent_selection_type `` parameter as in the next code.
@@ -2474,7 +2476,7 @@ previous 3 user-defined functions instead of the built-in functions.
2474
2476
for parent_num in range (num_parents):
2475
2477
parents[parent_num, :] = ga_instance.population[fitness_sorted[parent_num], :].copy()
2476
2478
2477
- return parents, fitness_sorted[:num_parents]
2479
+ return parents, numpy.array( fitness_sorted[:num_parents])
2478
2480
2479
2481
def crossover_func (parents , offspring_size , ga_instance ):
2480
2482
@@ -3004,7 +3006,7 @@ methods.
3004
3006
The ``plot_fitness() `` method shows the fitness value for each
3005
3007
generation.
3006
3008
3007
- .. _plottypeplot-1 :
3009
+ .. _plottypeplot :
3008
3010
3009
3011
``plot_type="plot" ``
3010
3012
~~~~~~~~~~~~~~~~~~~~
@@ -3021,7 +3023,7 @@ line connecting the fitness values across all generations:
3021
3023
.. figure :: https://user-images.githubusercontent.com/16560492/122472609-d02f5280-cf8e-11eb-88a7-f9366ff6e7c6.png
3022
3024
:alt:
3023
3025
3024
- .. _plottypescatter-1 :
3026
+ .. _plottypescatter :
3025
3027
3026
3028
``plot_type="scatter" ``
3027
3029
~~~~~~~~~~~~~~~~~~~~~~~
@@ -3037,7 +3039,7 @@ these dots can be changed using the ``linewidth`` parameter.
3037
3039
.. figure :: https://user-images.githubusercontent.com/16560492/122473159-75e2c180-cf8f-11eb-942d-31279b286dbd.png
3038
3040
:alt:
3039
3041
3040
- .. _plottypebar-1 :
3042
+ .. _plottypebar :
3041
3043
3042
3044
``plot_type="bar" ``
3043
3045
~~~~~~~~~~~~~~~~~~~
@@ -3393,8 +3395,6 @@ parameter:
3393
3395
given the value 0, this means do not use parallel processing. This is
3394
3396
identical to ``parallel_processing=None ``.
3395
3397
3396
- .. _examples-1 :
3397
-
3398
3398
Examples
3399
3399
--------
3400
3400
0 commit comments