Last active
October 3, 2019 09:20
-
-
Save fyr91/def2a7ea5bea7a2c5349f1314fbc5196 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
population = [] | |
offsprings = [] | |
# when offspring not enough for 10% of the population | |
# breed | |
while len(offsprings) < len(elite): | |
# select parent pairs for breeding | |
parents_pairs = np.random.choice(elite, size=(int(len(elite)/2),2), replace=False) | |
for parents in parents_pairs: | |
# pre-pregancy checkup | |
if breedable(parents): | |
lineup1, lineup2 = breed(parents) | |
offsprings.append(lineup1) | |
if len(offsprings) < len(elite): | |
offsprings.append(lineup2) | |
population.extend(elite) | |
population.extend(offsprings) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment