Skip to content

Instantly share code, notes, and snippets.

@rocreguant
Created January 31, 2021 16:22
Show Gist options
  • Save rocreguant/69ab5e9146b38c859c25ff6a90796b37 to your computer and use it in GitHub Desktop.
Save rocreguant/69ab5e9146b38c859c25ff6a90796b37 to your computer and use it in GitHub Desktop.
# 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