From d7cf32446843f112c8e9a84b78f039f1986762e4 Mon Sep 17 00:00:00 2001 From: wukan Date: Thu, 4 Jan 2024 19:20:10 +0800 Subject: [PATCH] support evaluate function return nan --- deap/base.py | 4 ++-- deap/tools/support.py | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/deap/base.py b/deap/base.py index f9d84ba6..3fd2a518 100644 --- a/deap/base.py +++ b/deap/base.py @@ -232,10 +232,10 @@ def __hash__(self): return hash(self.wvalues) def __gt__(self, other): - return not self.__le__(other) + return self.wvalues > other.wvalues def __ge__(self, other): - return not self.__lt__(other) + return self.wvalues >= other.wvalues def __le__(self, other): return self.wvalues <= other.wvalues diff --git a/deap/tools/support.py b/deap/tools/support.py index 2f7433bd..95948f70 100644 --- a/deap/tools/support.py +++ b/deap/tools/support.py @@ -522,10 +522,12 @@ def update(self, population): update the hall of fame with. """ for ind in population: + if ind.fitness.values[0] != ind.fitness.values[0]: + continue if len(self) == 0 and self.maxsize != 0: # Working on an empty hall of fame is problematic for the # "for else" - self.insert(population[0]) + self.insert(ind) continue if ind.fitness > self[-1].fitness or len(self) < self.maxsize: for hofer in self: