From fb84ac40d43d82cbb86feebc789bffd86412609e Mon Sep 17 00:00:00 2001 From: SimpleArt <71458112+SimpleArt@users.noreply.github.com> Date: Wed, 2 Dec 2020 17:06:15 -0500 Subject: [PATCH] Update EasyGA.py Probably better to let fitness-based selection to work as expected than to break due to unexpected negatives. --- src/EasyGA.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/EasyGA.py b/src/EasyGA.py index 3996992..fc5c6fa 100644 --- a/src/EasyGA.py +++ b/src/EasyGA.py @@ -254,13 +254,7 @@ class GA(Attributes): max_fitness = self.population[-1].fitness min_fitness = self.population[0].fitness - # Avoid catastrophic cancellation - if min_fitness / max_fitness < 1e-5: - return -fitness_value - - # Otherwise flip values - else: - return max_fitness - fitness_value + min_fitness + return max_fitness - fitness_value + min_fitness def print_generation(self):