Updated fitness based termination
It now works, although it only supports a minimum approach
This commit is contained in:
@ -3,9 +3,14 @@ class Termination_Methods:
|
|||||||
|
|
||||||
def fitness_based(self, ga):
|
def fitness_based(self, ga):
|
||||||
"""Fitness based approach to terminate when the goal fitness has been reached"""
|
"""Fitness based approach to terminate when the goal fitness has been reached"""
|
||||||
|
|
||||||
status = True
|
status = True
|
||||||
if(ga.current_fitness > ga.fitness_goal):
|
if ga.population == None:
|
||||||
status = False
|
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
|
return status
|
||||||
|
|
||||||
def generation_based(self, ga):
|
def generation_based(self, ga):
|
||||||
|
|||||||
Reference in New Issue
Block a user