From 7c434fb9cd5b36553f34f52ab9bbc3bd4e097b44 Mon Sep 17 00:00:00 2001 From: coolneng Date: Thu, 17 Jun 2021 22:45:14 +0200 Subject: [PATCH] Return 2 offsprings in the position crossover --- src/genetic_algorithm.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/genetic_algorithm.py b/src/genetic_algorithm.py index ca3b16b..c163779 100644 --- a/src/genetic_algorithm.py +++ b/src/genetic_algorithm.py @@ -104,8 +104,9 @@ def uniform_crossover(parents, m): def position_crossover(parents, m): matching_genes = get_matching_genes(parents) shuffled_genes = select_random_genes(matching_genes, parents, m) - offspring = populate_offspring(values=[matching_genes, shuffled_genes]) - return offspring + first_offspring = populate_offspring(values=[matching_genes, shuffled_genes]) + second_offspring = populate_offspring(values=[matching_genes, shuffled_genes]) + return [first_offspring, second_offspring] def crossover(mode, parents, m):