eckity.termination_checkers.termination_checker
1from abc import abstractmethod 2 3 4class TerminationChecker: 5 """ 6 Abstract TerminationChecker class. 7 8 This class is responsible of checking if the evolutionary algorithm should perform early termination. 9 This class can be expanded depending on the defined termination condition. 10 For example - threshold from target fitness, small change in fitness over a number of generations etc. 11 """ 12 @abstractmethod 13 def should_terminate(self, population, best_individual, gen_number): 14 """ 15 Determines if the algorithm should perform early termination. 16 17 Parameters 18 ---------- 19 population: Population 20 The population of the experiment. 21 22 best_individual: Individual 23 The best individual in the current generation of the algorithm. 24 25 gen_number: int 26 Current generation number. 27 28 Returns 29 ------- 30 bool 31 True if the algorithm should terminate early, False otherwise. 32 """ 33 pass
class
TerminationChecker:
5class TerminationChecker: 6 """ 7 Abstract TerminationChecker class. 8 9 This class is responsible of checking if the evolutionary algorithm should perform early termination. 10 This class can be expanded depending on the defined termination condition. 11 For example - threshold from target fitness, small change in fitness over a number of generations etc. 12 """ 13 @abstractmethod 14 def should_terminate(self, population, best_individual, gen_number): 15 """ 16 Determines if the algorithm should perform early termination. 17 18 Parameters 19 ---------- 20 population: Population 21 The population of the experiment. 22 23 best_individual: Individual 24 The best individual in the current generation of the algorithm. 25 26 gen_number: int 27 Current generation number. 28 29 Returns 30 ------- 31 bool 32 True if the algorithm should terminate early, False otherwise. 33 """ 34 pass
Abstract TerminationChecker class.
This class is responsible of checking if the evolutionary algorithm should perform early termination. This class can be expanded depending on the defined termination condition. For example - threshold from target fitness, small change in fitness over a number of generations etc.
@abstractmethod
def
should_terminate(self, population, best_individual, gen_number):
13 @abstractmethod 14 def should_terminate(self, population, best_individual, gen_number): 15 """ 16 Determines if the algorithm should perform early termination. 17 18 Parameters 19 ---------- 20 population: Population 21 The population of the experiment. 22 23 best_individual: Individual 24 The best individual in the current generation of the algorithm. 25 26 gen_number: int 27 Current generation number. 28 29 Returns 30 ------- 31 bool 32 True if the algorithm should terminate early, False otherwise. 33 """ 34 pass
Determines if the algorithm should perform early termination.
Parameters
- population (Population): The population of the experiment.
- best_individual (Individual): The best individual in the current generation of the algorithm.
- gen_number (int): Current generation number.
Returns
- bool: True if the algorithm should terminate early, False otherwise.