Updated termination related settings

This commit is contained in:
SimpleArt
2020-10-22 18:18:00 -04:00
parent df297cab20
commit 4ca859c34a
2 changed files with 3 additions and 9 deletions

View File

@ -40,7 +40,7 @@ class attributes:
self.current_generation = 0 self.current_generation = 0
self.current_fitness = 0 self.current_fitness = 0
self.generation_goal = 15 self.generation_goal = 15
self.fitness_goal = 9 self.fitness_goal = None
# Mutation variables # Mutation variables
self.mutation_rate = 0.10 self.mutation_rate = 0.10
@ -61,7 +61,7 @@ class attributes:
self.mutation_population_impl = Mutation_Methods.Population.random_selection self.mutation_population_impl = Mutation_Methods.Population.random_selection
# The type of termination to impliment # The type of termination to impliment
self.termination_impl = Termination_Methods.generation_based self.termination_impl = Termination_Methods.fitness_and_generation_based
# Getter and setters for all varibles # Getter and setters for all varibles

View File

@ -1,7 +1,7 @@
class Termination_Methods: class Termination_Methods:
"""Example functions that can be used to terminate the the algorithms loop""" """Example functions that can be used to terminate the the algorithms loop"""
def fitness_based(ga): def fitness_and_generation_based(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"""
# Need to start the algorithm if the population is None. # Need to start the algorithm if the population is None.
@ -17,10 +17,4 @@ class Termination_Methods:
return False return False
# Otherwise continue ga. # Otherwise continue ga.
return True
def generation_based(ga):
"""Generation based approach to terminate when the goal generation has been reached."""
return ga.current_generation < ga.generation_goal return ga.current_generation < ga.generation_goal