-
-
Save johntheo/1a17ac547766d39c8839bccc73c300f8 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
#Imprimir indivíduo | |
def print_ind(individual): | |
l = int("".join(str(i) for i in individual[:int(IND_SIZE / GENES)]), 2) # gene quantidade de garrafas de leite | |
s = int("".join(str(i) for i in individual[int(IND_SIZE / GENES):]), 2) # gene quantidade de garrafas de suco | |
g = 5*l + 4.5*s | |
print('Individuo:' + str(individual)) | |
print('Quantidade de garrafas de leite: ' + str(l)) | |
print('Quantidade de garrafas de suco: ' + str(s)) | |
print('Lucro: ' + str(g)) | |
#Plotar Gráfico | |
def plot_log(logbook): | |
gen = logbook.select("gen") | |
min = logbook.select("min") | |
avg = logbook.select("avg") | |
max = logbook.select("max") | |
import matplotlib.pyplot as plt | |
fig, ax1 = plt.subplots() | |
line1 = ax1.plot(gen, min, "b-", label="Minimum Fitness") | |
ax1.set_xlabel("Generation") | |
ax1.set_ylabel("Fitness", color="b") | |
for tl in ax1.get_yticklabels(): | |
tl.set_color("b") | |
ax2 = ax1.twinx() | |
line2 = ax2.plot(gen, avg, "g-", label="Average Fitness") | |
for tl in ax2.get_yticklabels(): | |
tl.set_color("g") | |
ax3 = ax1.twinx() | |
line3 = ax3.plot(gen, max, "y-", label="Maximum Fitness") | |
ax3.set_ylabel("Size") | |
for tl in ax3.get_yticklabels(): | |
tl.set_color("y") | |
lns = line1 + line2 + line3 | |
labs = [l.get_label() for l in lns] | |
ax1.legend(lns, labs, loc="center right") | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment