@@ -447,7 +447,7 @@ def mutation_process_random_value(self,
447447 -range_max: The maximum value in the range from which a value is selected.
448448 -solution: The solution where the target gene exists.
449449 -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.
451451 """
452452
453453 # Check if the gene has a constraint.
@@ -497,7 +497,7 @@ def mutation_randomly(self, offspring):
497497
498498 range_min , range_max = self .get_random_mutation_range (gene_idx )
499499
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.
501501 random_value = self .mutation_process_random_value (range_min = range_min ,
502502 range_max = range_max ,
503503 solution = offspring [offspring_idx ],
@@ -535,7 +535,7 @@ def mutation_probs_randomly(self, offspring):
535535 # A gene is mutated only if its mutation probability is less than or equal to the threshold.
536536 if probs [gene_idx ] <= self .mutation_probability :
537537
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.
539539 random_value = self .mutation_process_random_value (range_min = range_min ,
540540 range_max = range_max ,
541541 solution = offspring [offspring_idx ],
@@ -977,17 +977,11 @@ def adaptive_mutation_randomly(self, offspring):
977977
978978 range_min , range_max = self .get_random_mutation_range (gene_idx )
979979
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 )
991985
992986 offspring [offspring_idx , gene_idx ] = random_value
993987
@@ -1187,17 +1181,11 @@ def adaptive_mutation_probs_randomly(self, offspring):
11871181 range_min , range_max = self .get_random_mutation_range (gene_idx )
11881182
11891183 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 )
12011189
12021190 offspring [offspring_idx , gene_idx ] = random_value
12031191
0 commit comments