eckity.multi_objective_evolution.crowding_termination_checker
1from eckity.termination_checkers.termination_checker import TerminationChecker 2 3 4class CrowdingTerminationChecker(TerminationChecker): 5 """ 6 Concrete Termination Checker that checks the distance from best existing fitness value to target fitness value. 7 8 Parameters 9 ---------- 10 threshold: float, default=0.1 11 what is the maximal value of crowding that should be allowed in he population 12 """ 13 14 def __init__(self, threshold=0.1): 15 super().__init__() 16 self.threshold = threshold 17 18 def should_terminate(self, population=None, best_individual=None, gen_number=None): 19 """ 20 allawys return false so the program wont terminate until it finishes its iteration 21 Parameters 22 ---------- 23 population: Population 24 The evolutionary experiment population of individuals. 25 26 best_individual: Individual 27 The individual that has the best fitness of the current generation. 28 29 gen_number: int 30 Current generation number. 31 32 Returns 33 ------- 34 bool 35 True if the algorithm should terminate early, False otherwise. 36 """ 37 max_crwding_in_pop = self._find_max_crowding(population) 38 return max_crwding_in_pop < self.threshold and max_crwding_in_pop != 0 39 40 def _find_max_crowding(self, population): 41 crowdings = [] 42 for sup_pop in population.sub_populations: 43 crowdings.append( 44 max([ind.fitness.crowding for ind in sup_pop.individuals if ind.fitness.crowding != float("inf")])) 45 return max(crowdings)
class
CrowdingTerminationChecker(eckity.termination_checkers.termination_checker.TerminationChecker):
5class CrowdingTerminationChecker(TerminationChecker): 6 """ 7 Concrete Termination Checker that checks the distance from best existing fitness value to target fitness value. 8 9 Parameters 10 ---------- 11 threshold: float, default=0.1 12 what is the maximal value of crowding that should be allowed in he population 13 """ 14 15 def __init__(self, threshold=0.1): 16 super().__init__() 17 self.threshold = threshold 18 19 def should_terminate(self, population=None, best_individual=None, gen_number=None): 20 """ 21 allawys return false so the program wont terminate until it finishes its iteration 22 Parameters 23 ---------- 24 population: Population 25 The evolutionary experiment population of individuals. 26 27 best_individual: Individual 28 The individual that has the best fitness of the current generation. 29 30 gen_number: int 31 Current generation number. 32 33 Returns 34 ------- 35 bool 36 True if the algorithm should terminate early, False otherwise. 37 """ 38 max_crwding_in_pop = self._find_max_crowding(population) 39 return max_crwding_in_pop < self.threshold and max_crwding_in_pop != 0 40 41 def _find_max_crowding(self, population): 42 crowdings = [] 43 for sup_pop in population.sub_populations: 44 crowdings.append( 45 max([ind.fitness.crowding for ind in sup_pop.individuals if ind.fitness.crowding != float("inf")])) 46 return max(crowdings)
Concrete Termination Checker that checks the distance from best existing fitness value to target fitness value.
Parameters
- threshold (float, default=0.1): what is the maximal value of crowding that should be allowed in he population
def
should_terminate(self, population=None, best_individual=None, gen_number=None):
19 def should_terminate(self, population=None, best_individual=None, gen_number=None): 20 """ 21 allawys return false so the program wont terminate until it finishes its iteration 22 Parameters 23 ---------- 24 population: Population 25 The evolutionary experiment population of individuals. 26 27 best_individual: Individual 28 The individual that has the best fitness of the current generation. 29 30 gen_number: int 31 Current generation number. 32 33 Returns 34 ------- 35 bool 36 True if the algorithm should terminate early, False otherwise. 37 """ 38 max_crwding_in_pop = self._find_max_crowding(population) 39 return max_crwding_in_pop < self.threshold and max_crwding_in_pop != 0
allawys return false so the program wont terminate until it finishes its iteration
Parameters
- population (Population): The evolutionary experiment population of individuals.
- best_individual (Individual): The individual that has the best fitness of the current generation.
- gen_number (int): Current generation number.
Returns
- bool: True if the algorithm should terminate early, False otherwise.