@@ -447,7 +447,7 @@ def mutation_process_random_value(self,
447
447
-range_max: The maximum value in the range from which a value is selected.
448
448
-solution: The solution where the target gene exists.
449
449
-gene_idx: The index of the gene in the solution.
450
- It returns either a single numeric value or multiple values based on whether a gene constraint exists in the gene_constraint parameter.
450
+ It returns a single numeric value the satisfies the gene constraint if exists in the gene_constraint parameter.
451
451
"""
452
452
453
453
# Check if the gene has a constraint.
@@ -497,7 +497,7 @@ def mutation_randomly(self, offspring):
497
497
498
498
range_min , range_max = self .get_random_mutation_range (gene_idx )
499
499
500
- # Generate one or more random values that meet the gene constraint if exists.
500
+ # Generate a random value fpr mutation that meet the gene constraint if exists.
501
501
random_value = self .mutation_process_random_value (range_min = range_min ,
502
502
range_max = range_max ,
503
503
solution = offspring [offspring_idx ],
@@ -535,7 +535,7 @@ def mutation_probs_randomly(self, offspring):
535
535
# A gene is mutated only if its mutation probability is less than or equal to the threshold.
536
536
if probs [gene_idx ] <= self .mutation_probability :
537
537
538
- # Generate one or more random values that meet the gene constraint if exists.
538
+ # Generate a random value fpr mutation that meet the gene constraint if exists.
539
539
random_value = self .mutation_process_random_value (range_min = range_min ,
540
540
range_max = range_max ,
541
541
solution = offspring [offspring_idx ],
@@ -977,17 +977,11 @@ def adaptive_mutation_randomly(self, offspring):
977
977
978
978
range_min , range_max = self .get_random_mutation_range (gene_idx )
979
979
980
- # Generating a random value.
981
- random_value = numpy .random .uniform (low = range_min ,
982
- high = range_max ,
983
- size = 1 )[0 ]
984
- # Change the random mutation value data type.
985
- random_value = self .change_random_mutation_value_dtype (random_value ,
986
- gene_idx ,
987
- offspring [offspring_idx , gene_idx ])
988
-
989
- # Round the gene.
990
- random_value = self .round_random_mutation_value (random_value , gene_idx )
980
+ # Generate a random value fpr mutation that meet the gene constraint if exists.
981
+ random_value = self .mutation_process_random_value (range_min = range_min ,
982
+ range_max = range_max ,
983
+ solution = offspring [offspring_idx ],
984
+ gene_idx = gene_idx )
991
985
992
986
offspring [offspring_idx , gene_idx ] = random_value
993
987
@@ -1187,17 +1181,11 @@ def adaptive_mutation_probs_randomly(self, offspring):
1187
1181
range_min , range_max = self .get_random_mutation_range (gene_idx )
1188
1182
1189
1183
if probs [gene_idx ] <= adaptive_mutation_probability :
1190
- # Generating a random value.
1191
- random_value = numpy .random .uniform (low = range_min ,
1192
- high = range_max ,
1193
- size = 1 )[0 ]
1194
- # Change the random mutation value data type.
1195
- random_value = self .change_random_mutation_value_dtype (random_value ,
1196
- gene_idx ,
1197
- offspring [offspring_idx , gene_idx ])
1198
-
1199
- # Round the gene.
1200
- random_value = self .round_random_mutation_value (random_value , gene_idx )
1184
+ # Generate a random value fpr mutation that meet the gene constraint if exists.
1185
+ random_value = self .mutation_process_random_value (range_min = range_min ,
1186
+ range_max = range_max ,
1187
+ solution = offspring [offspring_idx ],
1188
+ gene_idx = gene_idx )
1201
1189
1202
1190
offspring [offspring_idx , gene_idx ] = random_value
1203
1191
0 commit comments