@@ -53,7 +53,7 @@ def solve_duplicate_genes_randomly(self,
53
53
else :
54
54
temp_val = numpy .random .uniform (low = min_val ,
55
55
high = max_val ,
56
- size = 1 )
56
+ size = 1 )[ 0 ]
57
57
if mutation_by_replacement :
58
58
pass
59
59
else :
@@ -69,7 +69,7 @@ def solve_duplicate_genes_randomly(self,
69
69
else :
70
70
temp_val = numpy .random .uniform (low = min_val ,
71
71
high = max_val ,
72
- size = 1 )
72
+ size = 1 )[ 0 ]
73
73
if mutation_by_replacement :
74
74
pass
75
75
else :
@@ -229,7 +229,7 @@ def unique_int_gene_from_range(self,
229
229
# Note that we already know that the data type is integer.
230
230
all_gene_values = numpy .asarray (all_gene_values ,
231
231
gene_type [gene_index ][0 ])
232
-
232
+
233
233
values_to_select_from = list (set (all_gene_values ) - set (solution ))
234
234
235
235
if len (values_to_select_from ) == 0 :
@@ -347,12 +347,12 @@ def unique_gene_by_space(self,
347
347
348
348
value_from_space = numpy .random .uniform (low = low ,
349
349
high = high ,
350
- size = 1 )
350
+ size = 1 )[ 0 ]
351
351
# TODO: Remove check for mutation_by_replacement when solving duplicates. Just replace the gene by the selected value from space.
352
- if self .mutation_by_replacement :
353
- pass
354
- else :
355
- value_from_space = solution [gene_idx ] + value_from_space
352
+ # if self.mutation_by_replacement:
353
+ # pass
354
+ # else:
355
+ # value_from_space = solution[gene_idx] + value_from_space
356
356
else :
357
357
if gene_type [gene_idx ][0 ] in pygad .GA .supported_int_types :
358
358
if build_initial_pop == True :
@@ -378,12 +378,12 @@ def unique_gene_by_space(self,
378
378
379
379
value_from_space = numpy .random .uniform (low = low ,
380
380
high = high ,
381
- size = 1 )
381
+ size = 1 )[ 0 ]
382
382
# TODO: Remove check for mutation_by_replacement when solving duplicates. Just replace the gene by the selected value from space.
383
- if self .mutation_by_replacement :
384
- pass
385
- else :
386
- value_from_space = solution [gene_idx ] + value_from_space
383
+ # if self.mutation_by_replacement:
384
+ # pass
385
+ # else:
386
+ # value_from_space = solution[gene_idx] + value_from_space
387
387
388
388
elif type (curr_gene_space ) is dict :
389
389
if self .gene_type_single == True :
@@ -409,12 +409,12 @@ def unique_gene_by_space(self,
409
409
else :
410
410
value_from_space = numpy .random .uniform (low = curr_gene_space ['low' ],
411
411
high = curr_gene_space ['high' ],
412
- size = 1 )
412
+ size = 1 )[ 0 ]
413
413
# TODO: Remove check for mutation_by_replacement when solving duplicates. Just replace the gene by the selected value from space.
414
- if self .mutation_by_replacement :
415
- pass
416
- else :
417
- value_from_space = solution [gene_idx ] + value_from_space
414
+ # if self.mutation_by_replacement:
415
+ # pass
416
+ # else:
417
+ # value_from_space = solution[gene_idx] + value_from_space
418
418
else :
419
419
# Use index 0 to return the type from the list (e.g. [int, None] or [float, 2]).
420
420
if gene_type [gene_idx ][0 ] in pygad .GA .supported_int_types :
@@ -439,12 +439,12 @@ def unique_gene_by_space(self,
439
439
else :
440
440
value_from_space = numpy .random .uniform (low = curr_gene_space ['low' ],
441
441
high = curr_gene_space ['high' ],
442
- size = 1 )
442
+ size = 1 )[ 0 ]
443
443
# TODO: Remove check for mutation_by_replacement when solving duplicates. Just replace the gene by the selected value from space.
444
- if self .mutation_by_replacement :
445
- pass
446
- else :
447
- value_from_space = solution [gene_idx ] + value_from_space
444
+ # if self.mutation_by_replacement:
445
+ # pass
446
+ # else:
447
+ # value_from_space = solution[gene_idx] + value_from_space
448
448
449
449
else :
450
450
# Selecting a value randomly based on the current gene's space in the 'gene_space' attribute.
@@ -503,12 +503,12 @@ def unique_gene_by_space(self,
503
503
else :
504
504
value_from_space = numpy .random .uniform (low = self .gene_space ['low' ],
505
505
high = self .gene_space ['high' ],
506
- size = 1 )
506
+ size = 1 )[ 0 ]
507
507
# TODO: Remove check for mutation_by_replacement when solving duplicates. Just replace the gene by the selected value from space.
508
- if self .mutation_by_replacement :
509
- pass
510
- else :
511
- value_from_space = solution [gene_idx ] + value_from_space
508
+ # if self.mutation_by_replacement:
509
+ # pass
510
+ # else:
511
+ # value_from_space = solution[gene_idx] + value_from_space
512
512
else :
513
513
if gene_type [gene_idx ][0 ] in pygad .GA .supported_int_types :
514
514
if 'step' in self .gene_space .keys ():
@@ -533,12 +533,12 @@ def unique_gene_by_space(self,
533
533
else :
534
534
value_from_space = numpy .random .uniform (low = self .gene_space ['low' ],
535
535
high = self .gene_space ['high' ],
536
- size = 1 )
536
+ size = 1 )[ 0 ]
537
537
# TODO: Remove check for mutation_by_replacement when solving duplicates. Just replace the gene by the selected value from space.
538
- if self .mutation_by_replacement :
539
- pass
540
- else :
541
- value_from_space = solution [gene_idx ] + value_from_space
538
+ # if self.mutation_by_replacement:
539
+ # pass
540
+ # else:
541
+ # value_from_space = solution[gene_idx] + value_from_space
542
542
543
543
else :
544
544
# If the space type is not of type dict, then a value is randomly selected from the gene_space attribute.
@@ -562,7 +562,7 @@ def unique_gene_by_space(self,
562
562
563
563
value_from_space = numpy .random .uniform (low = low ,
564
564
high = high ,
565
- size = 1 )
565
+ size = 1 )[ 0 ]
566
566
567
567
# Similar to the round_genes() method in the pygad module,
568
568
# Create a round_gene() method to round a single gene.
@@ -722,7 +722,7 @@ def unpack_gene_space(self,
722
722
for idx in none_indices :
723
723
random_value = numpy .random .uniform (low = self .random_mutation_min_val ,
724
724
high = self .random_mutation_max_val ,
725
- size = 1 )
725
+ size = 1 )[ 0 ]
726
726
gene_space_unpacked [space_idx ][idx ] = random_value
727
727
728
728
if self .gene_type_single == True : # self.gene_type_single
0 commit comments