Skip to content

Commit

Permalink
Update to check whether individual is in evaluated individuals
Browse files Browse the repository at this point in the history
Update to check whether the individual is in evaluated individuals instead of checking whether the individual is the same as parents.
  • Loading branch information
HyunjunA committed Jul 29, 2022
1 parent 44faaf2 commit 9e6ad7e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tpot/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1812,7 +1812,7 @@ def _mate_operator(self, ind1, ind2):
offspring.statistics["generation"] = "INVALID"
break

return offspring, offspring2
return offspring, offspring2, self.evaluated_individuals_

@_pre_test
def _random_mutation_operator(self, individual, allow_shrink=True):
Expand Down
4 changes: 2 additions & 2 deletions tpot/gp_deap.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ def varOr(population, toolbox, lambda_, cxpb, mutpb):
if op_choice < cxpb: # Apply crossover
ind1, ind2 = pick_two_individuals_eligible_for_crossover(population)
if ind1 is not None:
ind1, _ = toolbox.mate(ind1, ind2)
ind1_cx, _, evaluated_individuals_= toolbox.mate(ind1, ind2)
del ind1.fitness.values

if str(ind1_cx) == str(ind1) or str(ind1_cx) == str(ind2):
if str(ind1_cx) in evaluated_individuals_:
ind1_cx = mutate_random_individual(population, toolbox)
offspring.append(ind1_cx)
else:
Expand Down

0 comments on commit 9e6ad7e

Please sign in to comment.