@@ -1578,12 +1578,16 @@ def mutation_randomly(self, offspring):
15781578 random_value = self .gene_type (random_value )
15791579 else :
15801580 random_value = self .gene_type [gene_idx ](random_value )
1581- # If the mutation_by_replacement attribute is False, then the random value is added to the gene value.
1581+ if type (random_value ) is numpy .ndarray :
1582+ random_value = random_value [0 ]
1583+ # If the mutation_by_replacement attribute is False, then the random value is added to the gene value.
15821584 else :
15831585 if self .gene_type_single == True :
15841586 random_value = self .gene_type (offspring [offspring_idx , gene_idx ] + random_value )
15851587 else :
15861588 random_value = self .gene_type [gene_idx ](offspring [offspring_idx , gene_idx ] + random_value )
1589+ if type (random_value ) is numpy .ndarray :
1590+ random_value = random_value [0 ]
15871591
15881592 offspring [offspring_idx , gene_idx ] = random_value
15891593
@@ -1621,12 +1625,16 @@ def mutation_probs_randomly(self, offspring):
16211625 random_value = self .gene_type (random_value )
16221626 else :
16231627 random_value = self .gene_type [gene_idx ](random_value )
1628+ if type (random_value ) is numpy .ndarray :
1629+ random_value = random_value [0 ]
16241630 # If the mutation_by_replacement attribute is False, then the random value is added to the gene value.
16251631 else :
16261632 if self .gene_type_single == True :
16271633 random_value = self .gene_type (offspring [offspring_idx , gene_idx ] + random_value )
16281634 else :
16291635 random_value = self .gene_type [gene_idx ](offspring [offspring_idx , gene_idx ] + random_value )
1636+ if type (random_value ) is numpy .ndarray :
1637+ random_value = random_value [0 ]
16301638
16311639 offspring [offspring_idx , gene_idx ] = random_value
16321640
@@ -1872,12 +1880,16 @@ def adaptive_mutation_randomly(self, offspring):
18721880 random_value = self .gene_type (random_value )
18731881 else :
18741882 random_value = self .gene_type [gene_idx ](random_value )
1883+ if type (random_value ) is numpy .ndarray :
1884+ random_value = random_value [0 ]
18751885 # If the mutation_by_replacement attribute is False, then the random value is added to the gene value.
18761886 else :
18771887 if self .gene_type_single == True :
18781888 random_value = self .gene_type (offspring [offspring_idx , gene_idx ] + random_value )
18791889 else :
18801890 random_value = self .gene_type [gene_idx ](offspring [offspring_idx , gene_idx ] + random_value )
1891+ if type (random_value ) is numpy .ndarray :
1892+ random_value = random_value [0 ]
18811893
18821894 offspring [offspring_idx , gene_idx ] = random_value
18831895
@@ -2011,12 +2023,16 @@ def adaptive_mutation_probs_randomly(self, offspring):
20112023 random_value = self .gene_type (random_value )
20122024 else :
20132025 random_value = self .gene_type [gene_idx ](random_value )
2026+ if type (random_value ) is numpy .ndarray :
2027+ random_value = random_value [0 ]
20142028 # If the mutation_by_replacement attribute is False, then the random value is added to the gene value.
20152029 else :
20162030 if self .gene_type_single == True :
20172031 random_value = self .gene_type (offspring [offspring_idx , gene_idx ] + random_value )
20182032 else :
20192033 random_value = self .gene_type [gene_idx ](offspring [offspring_idx , gene_idx ] + random_value )
2034+ if type (random_value ) is numpy .ndarray :
2035+ random_value = random_value [0 ]
20202036
20212037 offspring [offspring_idx , gene_idx ] = random_value
20222038
0 commit comments