-
-
Save johntheo/28670affa2a09c55550c14fd042f7657 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
# Definindo a estrutura do indivíduo | |
IND_SIZE = 20 # Tamanho do individuo - 10 para cada gene | |
GENES = 2 | |
creator.create("Individual", list, fitness=creator.FitnessMax) | |
# funcao para gerar o gene com alelos 0 ou 1 randomicamente uniforme | |
toolbox.register("attr_bool", random.randint, 0, 1) | |
# funcao para gerar o indivíduo (nome, forma de gerar, Estrutura, funcao geradora, tamanho) | |
toolbox.register("individual", tools.initRepeat, creator.Individual, toolbox.attr_bool, n=IND_SIZE) | |
# funcao para gerar a populacao | |
toolbox.register("population", tools.initRepeat, list, toolbox.individual) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment