You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Change the data type and round a single gene value or a vector of values FOR THE SAME GENE. E.g., the input could be 6 or [6, 7, 8].
65
+
63
66
It accepts 2 parameters:
64
67
-gene_index: The index of the target gene.
65
68
-gene_value: The gene value.
69
+
66
70
If gene_value has a single value, then it returns a single number with the type changed and value rounded. If gene_value is a vector, then a vector is returned after changing the data type and rounding.
Change the data type and round the random value used to apply mutation.
110
+
106
111
It accepts:
107
112
-random_value: The random value to change its data type.
108
113
-gene_index: The index of the target gene.
109
114
-gene_value: The gene value before mutation. Only used if mutation_by_replacement=False and gene_type_single=False.
110
115
-mutation_by_replacement: A flag indicating whether mutation by replacement is enabled or not. The reason is to make this helper method usable while generating the initial population. In this case, mutation_by_replacement does not matter and should be considered False.
116
+
111
117
It returns the new value after changing the data type and being rounded.
Generate/select one or more values for the gene from the gene space.
238
+
224
239
It accepts:
225
240
-gene_idx: The index of the gene in the solution.
226
241
-mutation_by_replacement: A flag indicating whether mutation by replacement is enabled or not. The reason is to make this helper method usable while generating the initial population. In this case, mutation_by_replacement does not matter and should be considered False.
Copy file name to clipboardExpand all lines: pygad/pygad.py
+3-6Lines changed: 3 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -108,7 +108,7 @@ def __init__(self,
108
108
gene_space: It accepts a list of all possible values of the gene. This list is used in the mutation step. Should be used only if the gene space is a set of discrete values. No need for the 2 parameters (random_mutation_min_val and random_mutation_max_val) if the parameter gene_space exists. Added in PyGAD 2.5.0. In PyGAD 2.11.0, the gene_space can be assigned a dict.
109
109
110
110
gene_constraint: It accepts a list of constraints for the genes. Each constraint is a Python function. Added in PyGAD 3.5.0.
111
-
sample_size: To select a gene value that respects a constraint, this variable defines the size of the sample from which a value is selected. Useful if either allow_duplicate_genes or gene_constraint is used. Added in PyGAD 3.5.0.
111
+
sample_size: To select a gene value that respects a constraint, this variable defines the size of the sample from which a value is selected randomly. Useful if either allow_duplicate_genes or gene_constraint is used. Added in PyGAD 3.5.0.
112
112
113
113
on_start: Accepts a function/method to be called only once before the genetic algorithm starts its evolution. If functioned, then it must accept a single parameter representing the instance of the genetic algorithm. If method, then it must accept 2 parameters where the second one refers to the method's object. Added in PyGAD 2.6.0.
114
114
on_fitness: Accepts a function/method to be called after calculating the fitness values of all solutions in the population. If functioned, then it must accept 2 parameters: 1) a list of all solutions' fitness values 2) the instance of the genetic algorithm. If method, then it must accept 3 parameters where the third one refers to the method's object. Added in PyGAD 2.6.0.
0 commit comments