Skip to content

Commit 76bb230

Browse files
authored
Fix issue ahmedfgad#89
Fixes this issue: ahmedfgad#89 In the tournament_selection() method, this line: parents_indices.append(selected_parent_idx) is replaced by this line: parents_indices.append(rand_indices[selected_parent_idx])
1 parent e7e8d22 commit 76bb230

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pygad.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1412,7 +1412,7 @@ def tournament_selection(self, fitness, num_parents):
14121412
rand_indices = numpy.random.randint(low=0.0, high=len(fitness), size=self.K_tournament)
14131413
K_fitnesses = fitness[rand_indices]
14141414
selected_parent_idx = numpy.where(K_fitnesses == numpy.max(K_fitnesses))[0][0]
1415-
parents_indices.append(selected_parent_idx)
1415+
parents_indices.append(rand_indices[selected_parent_idx])
14161416
parents[parent_num, :] = self.population[rand_indices[selected_parent_idx], :].copy()
14171417

14181418
return parents, parents_indices

0 commit comments

Comments
 (0)