From ad8243fb6c0490966ad3db5762ff8864b7bb0e99 Mon Sep 17 00:00:00 2001 From: SimpleArt <71458112+SimpleArt@users.noreply.github.com> Date: Thu, 12 Nov 2020 17:14:16 -0500 Subject: [PATCH] Added percent_converged Termination when a specified percent of the population has converged. --- src/termination_point/termination_methods.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/termination_point/termination_methods.py b/src/termination_point/termination_methods.py index 6bdea5e..d9e7480 100644 --- a/src/termination_point/termination_methods.py +++ b/src/termination_point/termination_methods.py @@ -31,10 +31,10 @@ class Termination_Methods: if ga.tolerance_goal is not None: best_fitness = ga.population.get_chromosome(0).get_fitness() - threshhold_fitness = ga.population.get_chromosome(int(0.1*ga.population.size())).get_fitness() + threshhold_fitness = ga.population.get_chromosome(int(ga.percent_converged*ga.population.size())).get_fitness() tol = ga.tolerance_goal * (1 + abs(best_fitness)) - # Terminate if 10% of the population has converged + # Terminate if the specified amount of the population has converged to the specified tolerance if abs(best_fitness - threshhold_fitness) < tol: return False