Updated termination related settings
This commit is contained in:
@ -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
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user