@@ -1695,7 +1695,7 @@ def single_point_crossover(self, parents, offspring_size):
1695
1695
# The new offspring has its second half of its genes from the second parent.
1696
1696
offspring [k , crossover_point :] = parents [parent2_idx , crossover_point :]
1697
1697
1698
- if ( self .mutation_type is None ) and ( self . allow_duplicate_genes == False ) :
1698
+ if self .allow_duplicate_genes == False :
1699
1699
if self .gene_space is None :
1700
1700
offspring [k ], _ , _ = self .solve_duplicate_genes_randomly (solution = offspring [k ],
1701
1701
min_val = self .random_mutation_min_val ,
@@ -1761,7 +1761,7 @@ def two_points_crossover(self, parents, offspring_size):
1761
1761
# The genes between the 2 points are copied from the second parent.
1762
1762
offspring [k , crossover_point1 :crossover_point2 ] = parents [parent2_idx , crossover_point1 :crossover_point2 ]
1763
1763
1764
- if ( self .mutation_type is None ) and ( self . allow_duplicate_genes == False ) :
1764
+ if self .allow_duplicate_genes == False :
1765
1765
if self .gene_space is None :
1766
1766
offspring [k ], _ , _ = self .solve_duplicate_genes_randomly (solution = offspring [k ],
1767
1767
min_val = self .random_mutation_min_val ,
@@ -1821,7 +1821,7 @@ def uniform_crossover(self, parents, offspring_size):
1821
1821
# The gene will be copied from the second parent if the current gene index is 1.
1822
1822
offspring [k , gene_idx ] = parents [parent2_idx , gene_idx ]
1823
1823
1824
- if ( self .mutation_type is None ) and ( self . allow_duplicate_genes == False ) :
1824
+ if self .allow_duplicate_genes == False :
1825
1825
if self .gene_space is None :
1826
1826
offspring [k ], _ , _ = self .solve_duplicate_genes_randomly (solution = offspring [k ],
1827
1827
min_val = self .random_mutation_min_val ,
@@ -1877,7 +1877,7 @@ def scattered_crossover(self, parents, offspring_size):
1877
1877
gene_sources = numpy .random .randint (0 , 2 , size = self .num_genes )
1878
1878
offspring [k , :] = numpy .where (gene_sources == 0 , parents [parent1_idx , :], parents [parent2_idx , :])
1879
1879
1880
- if ( self .mutation_type is None ) and ( self . allow_duplicate_genes == False ) :
1880
+ if self .allow_duplicate_genes == False :
1881
1881
if self .gene_space is None :
1882
1882
offspring [k ], _ , _ = self .solve_duplicate_genes_randomly (solution = offspring [k ],
1883
1883
min_val = self .random_mutation_min_val ,
0 commit comments