Exception comes after main code

This commit is contained in:
SimpleArt
2020-11-20 09:18:23 -05:00
parent 2ad19a50d3
commit d4c9f3b926

View File

@ -11,10 +11,10 @@ def check_selection_probability(selection_method):
def check_positive_fitness(selection_method):
def helper(ga):
if ga.get_chromosome_fitness(0) == 0 or ga.get_chromosome_fitness(-1) < 0:
raise Exception("Converted fitness values must be all positive. Consider using rank selection instead.")
else:
if ga.get_chromosome_fitness(0) > 0 and ga.get_chromosome_fitness(-1) >= 0:
selection_method(ga)
else:
raise Exception("Converted fitness values must be all positive. Consider using rank selection instead.")
return helper