From f7324ed720f9e300984037127ca4615bbda94f17 Mon Sep 17 00:00:00 2001 From: Weixuan Fu Date: Fri, 7 Apr 2017 19:07:06 -0400 Subject: [PATCH] better soluation --- tpot/gp_deap.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tpot/gp_deap.py b/tpot/gp_deap.py index 922f1cac..8714a16d 100644 --- a/tpot/gp_deap.py +++ b/tpot/gp_deap.py @@ -233,11 +233,12 @@ def cxOnePoint(ind1, ind2): else: for idx, node in enumerate(ind1[1:], 1): types1[node.ret].append(idx) + common_types = [] for idx, node in enumerate(ind2[1:], 1): + if node.ret in types1 and not node.ret in types2: + common_types.append(node.ret) types2[node.ret].append(idx) - common_types = sorted([x for x in types1 if x in types2], key=lambda X: X.__name__) - if len(common_types) > 0: type_ = np.random.choice(common_types)