From f5c3a5833a644277e1c9244e88f0369bf51501d3 Mon Sep 17 00:00:00 2001 From: SimpleArt <71458112+SimpleArt@users.noreply.github.com> Date: Mon, 9 Nov 2020 16:08:30 -0500 Subject: [PATCH] Improved tolerance termination --- src/termination_point/termination_methods.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/termination_point/termination_methods.py b/src/termination_point/termination_methods.py index 2cacdca..a2b93af 100644 --- a/src/termination_point/termination_methods.py +++ b/src/termination_point/termination_methods.py @@ -27,16 +27,11 @@ class Termination_Methods: if ga.tolerance_goal is not None: best_fitness = ga.population.get_chromosome(0).get_fitness() - convergence_count = 0 + threshhold_fitness = ga.population.get_chromosome(int(0.1*ga.population.size())).get_fitness() tol = ga.tolerance_goal * (1 + abs(best_fitness)) - # Find out how many chromosomes have converged - for chromosome in ga.population.get_chromosome_list(): - if abs(best_fitness - chromosome.get_fitness()) < tol: - convergence_count += 1 - # Terminate if 10% of the population has converged - if convergence_count > 0.1*ga.population.size(): + if abs(best_fitness - threshhold_fitness) < tol: return False return True