From 565530d61cd98c34742e6a2beb0315842b567524 Mon Sep 17 00:00:00 2001 From: Lorenti Luciano - x_lulorent Date: Tue, 20 Feb 2024 09:34:52 +0100 Subject: [PATCH] Roulette: Fix how negatives fitness are handled --- mealpy/optimizer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mealpy/optimizer.py b/mealpy/optimizer.py index 870284a9..5ef45de0 100644 --- a/mealpy/optimizer.py +++ b/mealpy/optimizer.py @@ -632,7 +632,7 @@ def get_index_roulette_wheel_selection(self, list_fitness: np.array): list_fitness = np.array(list_fitness).flatten() if list_fitness.ptp() == 0: return int(self.generator.integers(0, len(list_fitness))) - if np.any(list_fitness) < 0: + if np.any(list_fitness < 0): list_fitness = list_fitness - np.min(list_fitness) final_fitness = list_fitness if self.problem.minmax == "min":