Updated fitness based termination

It now works, although it only supports a minimum approach
This commit is contained in:
RyleyGG
2020-10-05 20:59:21 -04:00
parent 665062fdf1
commit 3bfa962194

View File

@ -3,9 +3,14 @@ class Termination_Methods:
def fitness_based(self, ga):
"""Fitness based approach to terminate when the goal fitness has been reached"""
status = True
if(ga.current_fitness > ga.fitness_goal):
if ga.population == None:
return status
for i in range(len(ga.population.get_all_chromosomes())):
if(ga.population.get_all_chromosomes()[i].fitness >= ga.fitness_goal):
status = False
break
return status
def generation_based(self, ga):