Created
November 27, 2017 17:08
-
-
Save NicolleLouis/2945f064fd16213d00c17d9c753e6311 to your computer and use it in GitHub Desktop.
Create individuals
This file contains hidden or 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 generate_one_individual(item_set): | |
individual = [] | |
for i in range(len(item_set)): | |
if (100 * random.random() < 50): | |
individual.append(True) | |
else: | |
individual.append(False) | |
return individual | |
def generate_first_population(item_set, size_of_population): | |
population = [] | |
for i in range(size_of_population): | |
population.append(generate_one_individual(item_set)) | |
return population | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment