Skip to content

Commit

Permalink
modify selTournamentDCD bounds checking
Browse files Browse the repository at this point in the history
  • Loading branch information
ericf123 committed Oct 18, 2019
1 parent 99223a8 commit 87449b6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions deap/tools/emo.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ def selTournamentDCD(individuals, k):
:param k: The number of individuals to select.
:returns: A list of selected individuals.
"""

if len(individuals) % 4 != 0:
raise ValueError("selTournamentDCD: individuals length must be a multiple of 4")

if k % 4 != 0:
raise ValueError("selTournamentDCD: number of individuals to select must be a multiple of 4")
if k > len(individuals):
raise ValueError("selTournamentDCD: k must be less than or equal to individuals length")
if k == len(individuals) and k % 4 != 0:
raise ValueError("selTournamentDCD: k must be divisible by four if k == len(individuals)")

def tourn(ind1, ind2):
if ind1.fitness.dominates(ind2.fitness):
Expand Down

0 comments on commit 87449b6

Please sign in to comment.