-
-
Save johntheo/6ca33fb96c2d24ff034b62a977a197f3 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 main(): | |
random.seed(94) | |
# cria populacao inicial | |
pop = toolbox.population(n=70) | |
# CXPB - probabilidade de crossover | |
# MUTPB - probabilidade de mutacao | |
# NGEN - numero de geracoes | |
CXPB, MUTPB, NGEN =0.8, 0.02, 60 | |
#stats a serem guardados | |
stats = tools.Statistics(key=lambda ind: ind.fitness.values) | |
stats.register("std", numpy.std) | |
stats.register("min", numpy.min) | |
stats.register("avg", numpy.mean) | |
stats.register("max", numpy.max) | |
#Roda o algoritmo | |
pop, logbook = algorithms.eaSimple(pop, toolbox, CXPB, MUTPB, NGEN, stats=stats) | |
#Seleciona o melhor individuo da populacao resultante | |
best_ind = tools.selSPEA2(pop, 1) | |
#Imprime as infromações do melhor individuo | |
print_ind(best_ind[0]) | |
#Plota o Gráfico | |
plot_log(logbook) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment