<jupyter_start><jupyter_text>RASTRIGIN<jupyter_code>def rastrigin(X, *args):
    return sum(list(map(lambda x: x**2 - 10*np.cos(2*np.pi*x) + 10, list(X))))
qt_iter = 1000
xticks = np.arange(1, qt_iter+1,1)
dimentions = 30<jupyter_output><empty_output><jupyter_text>Global - Inercia Fixo<jupyter_code>myPSO_Ras_1 = PSO(number_of_particles=30, dim=dimentions, minx=-5, maxx=12, seed=1, function=rastrigin, functionArgs=[])
myPSO_Ras_1 = myPSO_Ras_1.Solver(max_epochs=qt_iter, plot_at_every=100, w=0.8, c1=2.05, c2=2.05, topology='G')
print("\nPSO completed\n")
ras_hist_fit_t1 = myPSO_Ras_1.historic_best_error
# fig= plt.figure(figsize=(10,6), dpi=300)
# plt.plot(xticks, ras_hist_fit_t1, linewidth=2)
# plt.xlabel("Iteração", fontsize=14)
# plt.ylabel("Valor objetivo", fontsize=14)
# plt.grid()<jupyter_output>13%|████████████████████                                                                                                                                          | 127/1000 [00:00<00:06, 141.94it/s]<jupyter_text>Global - Inercia Decaindo<jupyter_code>myPSO_Ras_2 = PSO(number_of_particles=30, dim=dimentions, minx=-5, maxx=12, seed=1, function=rastrigin, functionArgs=[])
myPSO_Ras_2 = myPSO_Ras_2.Solver(max_epochs=qt_iter, plot_at_every=100, w=(0.8, 0.4), c1=2.05, c2=2.05, topology='G')
print("\nPSO completed\n")
ras_hist_fit_t2 = myPSO_Ras_2.historic_best_error
# fig= plt.figure(figsize=(10,6), dpi=300)
# plt.plot(xticks, ras_hist_fit_t2, linewidth=2)
# plt.xlabel("Iteração", fontsize=14)
# plt.ylabel("Valor objetivo", fontsize=14)
# plt.grid()<jupyter_output>12%|███████████████████▎                                                                                                                                          | 122/1000 [00:00<00:06, 135.57it/s]<jupyter_text>Local - Inercia Fixo<jupyter_code>myPSO_Ras_3 = PSO(number_of_particles=30, dim=dimentions, minx=-5, maxx=12, seed=1, function=rastrigin, functionArgs=[])
myPSO_Ras_3 = myPSO_Ras_3.Solver(max_epochs=1000, plot_at_every=100, w=0.8, c1=2.05, c2=2.05, topology='L')
print("\nPSO completed\n")
ras_hist_fit_t3 = myPSO_Ras_3.historic_best_error
# fig= plt.figure(figsize=(10,6), dpi=300)
# plt.plot(xticks, ras_hist_fit_t3, linewidth=2)
# plt.xlabel("Iteração", fontsize=14)
# plt.ylabel("Valor objetivo", fontsize=14)
# plt.grid()<jupyter_output>11%|█████████████████                                                                                                                                              | 107/1000 [00:04<00:35, 25.21it/s]<jupyter_text>Local - Inercia Decaindo<jupyter_code>myPSO_Ras_4 = PSO(number_of_particles=30, dim=dimentions, minx=-5, maxx=12, seed=1, function=rastrigin, functionArgs=[])
myPSO_Ras_4 = myPSO_Ras_4.Solver(max_epochs=1000, plot_at_every=100, w=(0.8, 0.4), c1=2.05, c2=2.05, topology='L')
print("\nPSO completed\n")
ras_hist_fit_t4 = myPSO_Ras_4.historic_best_error
# fig= plt.figure(figsize=(10,6), dpi=300)
# plt.plot(xticks, ras_hist_fit_t4, linewidth=2)
# plt.xlabel("Iteração", fontsize=14)
# plt.ylabel("Valor objetivo", fontsize=14)
# plt.grid()<jupyter_output>10%|████████████████▏                                                                                                                                              | 102/1000 [00:09<01:29, 10.03it/s]<jupyter_text>Focal - Inercia Fixo<jupyter_code>myPSO_Ras_5 = PSO(number_of_particles=30, dim=dimentions, minx=-5, maxx=12, seed=1, function=rastrigin, functionArgs=[])
myPSO_Ras_5 = myPSO_Ras_5.Solver(max_epochs=1000, plot_at_every=100, w=0.8, c1=2.05, c2=2.05, topology='F')
print("\nPSO completed\n")
ras_hist_fit_t5 = myPSO_Ras_5.historic_best_error
# fig= plt.figure(figsize=(10,6), dpi=300)
# plt.plot(xticks, ras_hist_fit_t5, linewidth=2)
# plt.xlabel("Iteração", fontsize=14)
# plt.ylabel("Valor objetivo", fontsize=14)
# plt.grid()<jupyter_output>12%|███████████████████                                                                                                                                           | 121/1000 [00:00<00:04, 176.15it/s]<jupyter_text>Focal - Inercia Decaindo<jupyter_code>myPSO_Ras_6 = PSO(number_of_particles=30, dim=dimentions, minx=-5, maxx=12, seed=1, function=rastrigin, functionArgs=[])
myPSO_Ras_6 = myPSO_Ras_6.Solver(max_epochs=1000, plot_at_every=100, w=(0.8, 0.4), c1=2.05, c2=2.05, topology='F')
print("\nPSO completed\n")
ras_hist_fit_t6 = myPSO_Ras_6.historic_best_error
# fig= plt.figure(figsize=(10,6), dpi=300)
# plt.plot(xticks, ras_hist_fit_t6, linewidth=2)
# plt.xlabel("Iteração", fontsize=14)
# plt.ylabel("Valor objetivo", fontsize=14)
# plt.grid()<jupyter_output>12%|██████████████████▉                                                                                                                                           | 120/1000 [00:01<00:08, 105.49it/s]<jupyter_text>Um grafico<jupyter_code>fig= plt.figure(figsize=(12,6), dpi=300)

plt.plot(xticks[:], ras_hist_fit_t1[:], c='g', linewidth=2, label="Global - w Fixo")
plt.plot(xticks[:], ras_hist_fit_t2[:], c='b', linewidth=2, label="Global - w decaindo")
plt.plot(xticks[:], ras_hist_fit_t3[:], c='r', linewidth=2, label="Local - w Fixo")
plt.plot(xticks[:], ras_hist_fit_t4[:], c='y', linewidth=2, label="Local - w decaindo")
plt.plot(xticks[:], ras_hist_fit_t5[:], c='tab:brown', linewidth=2, label="Focal - w Fixo")
plt.plot(xticks[:], ras_hist_fit_t6[:], c='tab:gray', linewidth=2, label="Focal - w decaindo")

plt.legend(fontsize=14)
plt.xlabel("Geração", fontsize=14)
plt.ylabel("Valor objetivo", fontsize=14)
plt.grid()<jupyter_output><empty_output><jupyter_text>ROSENBROCK<jupyter_code>def rosenbrock(X, *args):
    result = 0
    for i in range(len(X)-1):
        result += 100*(X[i+1]-X[i]**2)**2 + (X[i]-1)**2
    return result<jupyter_output><empty_output><jupyter_text>Global - Inercia Fixo<jupyter_code>myPSO_Ros_1 = PSO(number_of_particles=30, dim=dimentions, minx=-5, maxx=10, seed=1, function=rosenbrock, functionArgs=[])
myPSO_Ros_1 = myPSO_Ros_1.Solver(max_epochs=qt_iter, plot_at_every=100, w=0.8, c1=2.05, c2=2.05, topology='G')
print("\nPSO completed\n")
ros_hist_fit_t1 = myPSO_Ros_1.historic_best_error
# fig= plt.figure(figsize=(10,6), dpi=300)
# plt.plot(xticks, ros_hist_fit_t1, linewidth=2)
# plt.xlabel("Iteração", fontsize=14)
# plt.ylabel("Valor objetivo", fontsize=14)
# plt.grid()<jupyter_output>16%|█████████████████████████▌                                                                                                                                    | 162/1000 [00:00<00:01, 509.88it/s]<jupyter_text>Global - Inercia Decaindo<jupyter_code>myPSO_Ros_2 = PSO(number_of_particles=30, dim=dimentions, minx=-5, maxx=10, seed=1, function=rosenbrock, functionArgs=[])
myPSO_Ros_2 = myPSO_Ros_2.Solver(max_epochs=qt_iter, plot_at_every=100, w=(0.8, 0.4), c1=2.05, c2=2.05, topology='G')
print("\nPSO completed\n")
ros_hist_fit_t2 = myPSO_Ros_2.historic_best_error
# fig= plt.figure(figsize=(10,6), dpi=300)
# plt.plot(xticks, ros_hist_fit_t2, linewidth=2)
# plt.xlabel("Iteração", fontsize=14)
# plt.ylabel("Valor objetivo", fontsize=14)
# plt.grid()<jupyter_output>12%|██████████████████▊                                                                                                                                           | 119/1000 [00:00<00:05, 159.26it/s]<jupyter_text>Local - Inercia Fixo<jupyter_code>myPSO_Ros_3 = PSO(number_of_particles=30, dim=dimentions, minx=-5, maxx=10, seed=1, function=rosenbrock, functionArgs=[])
myPSO_Ros_3 = myPSO_Ros_3.Solver(max_epochs=1000, plot_at_every=100, w=0.8, c1=2.05, c2=2.05, topology='L')
print("\nPSO completed\n")
ros_hist_fit_t3 = myPSO_Ros_3.historic_best_error
# fig= plt.figure(figsize=(10,6), dpi=300)
# plt.plot(xticks, ros_hist_fit_t3, linewidth=2)
# plt.xlabel("Iteração", fontsize=14)
# plt.ylabel("Valor objetivo", fontsize=14)
# plt.grid()<jupyter_output>10%|████████████████▋                                                                                                                                              | 105/1000 [00:04<00:35, 25.56it/s]<jupyter_text>Local - Inercia Decaindo<jupyter_code>myPSO_Ros_4 = PSO(number_of_particles=30, dim=dimentions, minx=-5, maxx=10, seed=1, function=rosenbrock, functionArgs=[])
myPSO_Ros_4 = myPSO_Ros_4.Solver(max_epochs=1000, plot_at_every=100, w=(0.8, 0.4), c1=2.05, c2=2.05, topology='L')
print("\nPSO completed\n")
ros_hist_fit_t4 = myPSO_Ros_4.historic_best_error
# fig= plt.figure(figsize=(10,6), dpi=300)
# plt.plot(xticks, ros_hist_fit_t4, linewidth=2)
# plt.xlabel("Iteração", fontsize=14)
# plt.ylabel("Valor objetivo", fontsize=14)
# plt.grid()<jupyter_output>10%|████████████████▌                                                                                                                                              | 104/1000 [00:08<01:05, 13.70it/s]<jupyter_text>Focal - Inercia Fixo<jupyter_code>myPSO_Ros_5 = PSO(number_of_particles=30, dim=dimentions, minx=-5, maxx=10, seed=1, function=rosenbrock, functionArgs=[])
myPSO_Ros_5 = myPSO_Ros_5.Solver(max_epochs=1000, plot_at_every=100, w=0.8, c1=2.05, c2=2.05, topology='F')
print("\nPSO completed\n")
ros_hist_fit_t5 = myPSO_Ros_5.historic_best_error
# fig= plt.figure(figsize=(10,6), dpi=300)
# plt.plot(xticks, ros_hist_fit_t5, linewidth=2)
# plt.xlabel("Iteração", fontsize=14)
# plt.ylabel("Valor objetivo", fontsize=14)
# plt.grid()<jupyter_output>15%|███████████████████████▏                                                                                                                                      | 147/1000 [00:00<00:01, 461.46it/s]<jupyter_text>Focal - Inercia Decaindo<jupyter_code>myPSO_Ros_6 = PSO(number_of_particles=30, dim=dimentions, minx=-5, maxx=10, seed=1, function=rosenbrock, functionArgs=[])
myPSO_Ros_6 = myPSO_Ros_6.Solver(max_epochs=1000, plot_at_every=100, w=(0.8, 0.4), c1=2.05, c2=2.05, topology='F')
print("\nPSO completed\n")
ros_hist_fit_t6 = myPSO_Ros_6.historic_best_error
# fig= plt.figure(figsize=(10,6), dpi=300)
# plt.plot(xticks, ros_hist_fit_t6, linewidth=2)
# plt.xlabel("Iteração", fontsize=14)
# plt.ylabel("Valor objetivo", fontsize=14)
# plt.grid()<jupyter_output>14%|█████████████████████▎                                                                                                                                        | 135/1000 [00:00<00:04, 186.65it/s]<jupyter_text>Um grafico<jupyter_code>fig= plt.figure(figsize=(10,6), dpi=300)

plt.plot(xticks[:], ros_hist_fit_t1[:], c='g', linewidth=2, label="Global - w Fixo")
plt.plot(xticks[:], ros_hist_fit_t2[:], c='b', linewidth=2, label="Global - w decaindo")
plt.plot(xticks[:], ros_hist_fit_t3[:], c='r', linewidth=2, label="Local - w Fixo")
plt.plot(xticks[:], ros_hist_fit_t4[:], c='y', linewidth=2, label="Local - w decaindo")
plt.plot(xticks[:], ros_hist_fit_t5[:], c='tab:brown', linewidth=2, label="Focal - w Fixo")
plt.plot(xticks[:], ros_hist_fit_t6[:], c='tab:gray', linewidth=2, label="Focal - w decaindo")

plt.legend(fontsize=14)
plt.xlabel("Geração", fontsize=14)
plt.ylabel("Valor objetivo", fontsize=14)
plt.grid()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17382302637501126, 'fraction_numerical': 0.0728238365289405, 'mean_word_length': 3.2243346007604563, 'pattern_counts': {'":': 0, '<': 65, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 79, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '16', 'dir': 'jupyter-structured-clean-dedup', 'id': '649487', 'license': 'MIT', 'n_tokens_mistral': 4945, 'n_tokens_neox': 4461, 'n_words': 560, 'path': 'examples/myPSO.ipynb', 'repo_name': 'hugoabreu1002/ML_Algorithms', 'size': '11109'}