Fixed termination related stuff
This commit is contained in:
@ -8,13 +8,16 @@ class Termination_Methods:
|
||||
if ga.population == None:
|
||||
return True
|
||||
|
||||
# If minimum fitness goal reached, stop ga.
|
||||
if ga.target_fitness_type == 'min' and ga.get_chromosome_fitness(0) >= ga.convert_fitness(ga.fitness_goal):
|
||||
return False
|
||||
# If fitness goal is set, check it.
|
||||
if ga.fitness_goal is not None:
|
||||
|
||||
# If maximum fitness goal reached, stop ga.
|
||||
if ga.target_fitness_type == 'max' and ga.get_chromosome_fitness(0) >= ga.convert_fitness(ga.fitness_goal):
|
||||
return False
|
||||
|
||||
# Otherwise continue ga.
|
||||
return ga.current_generation < ga.generation_goal
|
||||
# If minimum fitness goal reached, stop ga.
|
||||
if ga.target_fitness_type == 'min' and ga.get_chromosome_fitness(0) >= ga.convert_fitness(ga.fitness_goal):
|
||||
return False
|
||||
|
||||
# If maximum fitness goal reached, stop ga.
|
||||
if ga.target_fitness_type == 'max' and ga.get_chromosome_fitness(0) >= ga.convert_fitness(ga.fitness_goal):
|
||||
return False
|
||||
|
||||
# If generation goal is set, check it.
|
||||
return ga.generation_goal is not None and ga.current_generation < ga.generation_goal
|
||||
|
||||
Reference in New Issue
Block a user