You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NSGA tournament sorting only compares two solutions each round #316
Looking at the code for tournament_selection_nsga2 in parent_selection.py only the first two solutions in each round of selection are ever compared.
pareto_fronts, solutions_fronts_indices=self.non_dominated_sorting(fitness)
self.pareto_fronts=pareto_fronts.copy()
# Randomly generate pairs of indices to apply for NSGA-II tournament selection for selecting the parents solutions.rand_indices=numpy.random.randint(low=0.0,
high=len(solutions_fronts_indices),
size=(num_parents, self.K_tournament))
forparent_numinrange(num_parents):
# Return the indices of the current 2 solutions.current_indices=rand_indices[parent_num]
# Return the front index of the 2 solutions.parent_fronts_indices=solutions_fronts_indices[current_indices]
ifparent_fronts_indices[0] <parent_fronts_indices[1]:
# If the first solution is in a lower pareto front than the second, then select it.selected_parent_idx=current_indices[0]
elifparent_fronts_indices[0] >parent_fronts_indices[1]:
# If the second solution is in a lower pareto front than the first, then select it.selected_parent_idx=current_indices[1]
else:
# The 2 solutions are in the same pareto front.# The selection is made using the crowding distance.
...
K_tournament solution indexes are selected with randint though. This also happens for crowding distance as well.
NSGA-II tournament selection now considers every candidate in a tournament, including when K_tournament exceeds 2. I verified a three-candidate tournament in which the third candidate dominates the first two and is selected. See current implementation. I am closing this as fixed.
Activity
ahmedfgad commentedon Jul 9, 2025
Thanks so much! The bug is fixed and will be available in the next release soon.
ahmedfgad commentedon Oct 8, 2026
NSGA-II tournament selection now considers every candidate in a tournament, including when
K_tournamentexceeds 2. I verified a three-candidate tournament in which the third candidate dominates the first two and is selected. See current implementation. I am closing this as fixed.