Skip to content

Commit

Permalink
Roulette: Fix how negatives fitness are handled
Browse files Browse the repository at this point in the history
  • Loading branch information
Lorenti Luciano - x_lulorent committed Feb 20, 2024
1 parent 49b42f1 commit 565530d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mealpy/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down

0 comments on commit 565530d

Please sign in to comment.