Skip to content

Commit 282b6c6

Browse files
committed
Update genetic_algorithm_optimization.py
1 parent cd4f6f3 commit 282b6c6

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

genetic_algorithm/genetic_algorithm_optimization.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ def crossover(self, parent1, parent2):
6767
return parent1, parent2 # No crossover needed for single-variable functions
6868

6969
if self.rng.random() < self.crossover_prob:
70-
point = self.rng.integers(
71-
1, self.num_variables
72-
) # Updated to handle edge case
70+
point = self.rng.integers(1, self.num_variables)
7371
child1 = np.concatenate((parent1[:point], parent2[point:]))
7472
child2 = np.concatenate((parent2[:point], parent1[point:]))
7573
return child1, child2

0 commit comments

Comments
 (0)