Created
January 31, 2021 16:35
-
-
Save rocreguant/59863a98621f9774b5b041dd79e06baf 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
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