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/gp.py b/deap/gp.py index ccc47b6b..dca882b3 100644 --- a/deap/gp.py +++ b/deap/gp.py @@ -631,7 +631,7 @@ def generate(pset, min_, max_, condition, type_=None): stack = [(0, type_)] while len(stack) != 0: depth, type_ = stack.pop() - if condition(height, depth): + if condition(height, depth) or len(pset.primitives[type_]) == 0: try: term = random.choice(pset.terminals[type_]) except IndexError: 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: