From ea93ad8796bb7db8d5d4eb265c93b0c78a198e15 Mon Sep 17 00:00:00 2001 From: SimpleArt <71458112+SimpleArt@users.noreply.github.com> Date: Sun, 6 Dec 2020 11:35:30 -0500 Subject: [PATCH] Mathematically solved for weight --- src/EasyGA.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/EasyGA.py b/src/EasyGA.py index 25cf8de..d847c8a 100644 --- a/src/EasyGA.py +++ b/src/EasyGA.py @@ -204,14 +204,13 @@ class GA(Attributes): for n in range(i, len(self.population)): # Strongly cross with the best chromosome - # May reject negative weight + # May reject negative weight or division by 0 try: - tol_n = tol(n) self.population[n] = self.crossover_individual_impl( self, self.population[n], best_chromosome, - min(0.25, (2*tol_n - tol_j) / tol_n) + min(0.25, 2 * tol_j / (tol(n) - tol_j)) ) # If negative weights can't be used,