Created
January 31, 2021 16:21
-
-
Save rocreguant/e89b2efde4246c1d91847b467064776b 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
# 3. Selecting the progenitors | |
def progenitor_selection(population_set,fitnes_list): | |
total_fit = fitnes_list.sum() | |
prob_list = fitnes_list/total_fit | |
#Notice there is the chance that a progenitor. mates with oneself | |
progenitor_list_a = np.random.choice(list(range(len(population_set))), len(population_set),p=prob_list, replace=True) | |
progenitor_list_b = np.random.choice(list(range(len(population_set))), len(population_set),p=prob_list, replace=True) | |
progenitor_list_a = population_set[progenitor_list_a] | |
progenitor_list_b = population_set[progenitor_list_b] | |
return np.array([progenitor_list_a,progenitor_list_b]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment