From 150457cc8e6d19b56a39df3b0edc8260a7a77f91 Mon Sep 17 00:00:00 2001 From: coolneng Date: Sat, 19 Jun 2021 20:22:39 +0200 Subject: [PATCH] Fix matching genes selection --- src/genetic_algorithm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/genetic_algorithm.py b/src/genetic_algorithm.py index cae5eb1..9fab9b3 100644 --- a/src/genetic_algorithm.py +++ b/src/genetic_algorithm.py @@ -1,4 +1,4 @@ -from numpy import sum, append, arange, delete, where +from numpy import sum, append, arange, delete, intersect1d from numpy.random import randint, choice, shuffle from pandas import DataFrame from math import ceil @@ -87,7 +87,7 @@ def repair_offspring(offspring, parents, m): def get_matching_genes(parents): first_parent = parents[0].point.values second_parent = parents[1].point.values - return where(first_parent == second_parent)[0] + return intersect1d(first_parent, second_parent) def populate_offspring(values):