Created
January 31, 2021 16:22
-
-
Save rocreguant/69ab5e9146b38c859c25ff6a90796b37 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Pairs crossover | |
def mate_progenitors(prog_a, prog_b): | |
offspring = prog_a[0:5] | |
for city in prog_b: | |
if not city in offspring: | |
offspring = np.concatenate((offspring,[city])) | |
return offspring | |
# Finding pairs of mates | |
def mate_population(progenitor_list): | |
new_population_set = [] | |
for i in range(progenitor_list.shape[1]): | |
prog_a, prog_b = progenitor_list[0][i], progenitor_list[1][i] | |
offspring = mate_progenitors(prog_a, prog_b) | |
new_population_set.append(offspring) | |
return new_population_set |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment