import numpy as np

Losses_20 = np.load("results/Losses_0.001_20.npy", allow_pickle=True).item()
Losses_50 = np.load("results/Losses_0.001_50.npy", allow_pickle=True).item()
Losses_100 = np.load("results/Losses_0.001_100.npy", allow_pickle=True).item()
Losses_200 = np.load("results/Losses_0.001_200.npy", allow_pickle=True).item()

store_2_20 = np.load("results/store_0.01_20.npy", allow_pickle=True).item()
store_2_50 = np.load("results/store_0.01_50.npy", allow_pickle=True).item()
store_2_100 = np.load("results/store_0.01_100.npy", allow_pickle=True).item()
store_2_200 = np.load("results/store_0.01_200.npy", allow_pickle=True).item()
store_3_20 = np.load("results/store_0.001_20.npy", allow_pickle=True).item()
store_3_50 = np.load("results/store_0.001_50.npy", allow_pickle=True).item()
store_3_100 = np.load("results/store_0.001_100.npy", allow_pickle=True).item()
store_3_200 = np.load("results/store_0.001_200.npy", allow_pickle=True).item()
store_4_20 = np.load("results/store_0.0001_20.npy", allow_pickle=True).item()
store_4_50 = np.load("results/store_0.0001_50.npy", allow_pickle=True).item()
store_4_100 = np.load("results/store_0.0001_100.npy", allow_pickle=True).item()
store_4_200 = np.load("results/store_0.0001_200.npy", allow_pickle=True).item()
store_5_20 = np.load("results/store_1e-05_20.npy", allow_pickle=True).item()
store_5_50 = np.load("results/store_1e-05_50.npy", allow_pickle=True).item()
store_5_100 = np.load("results/store_1e-05_100.npy", allow_pickle=True).item()
store_5_200 = np.load("results/store_1e-05_200.npy", allow_pickle=True).item()


for i in range(6):
    j = np.argmin([store_2_20['FEDAC1'][i][1], store_3_20['FEDAC1'][i][1], store_4_20['FEDAC1'][i][1], store_5_20['FEDAC1'][i][1]])
    min_mu = [0.01, 0.001, 0.0001, 1e-05][j] 
    Losses_20['FEDAC1'][i] = np.load(f"results/Losses_{min_mu}_20.npy", allow_pickle=True).item()['FEDAC1'][i]
    j = np.argmin([store_2_20['FEDAC2'][i][1], store_3_20['FEDAC2'][i][1], store_4_20['FEDAC2'][i][1], store_5_20['FEDAC2'][i][1]])
    min_mu = [0.01, 0.001, 0.0001, 1e-05][j] 
    Losses_20['FEDAC2'][i] = np.load(f"results/Losses_{min_mu}_20.npy", allow_pickle=True).item()['FEDAC2'][i]    
    
    j = np.argmin([store_2_50['FEDAC1'][i][1], store_3_50['FEDAC1'][i][1], store_4_50['FEDAC1'][i][1], store_5_50['FEDAC1'][i][1]])
    min_mu = [0.01, 0.001, 0.0001, 1e-05][j] 
    Losses_50['FEDAC1'][i] = np.load(f"results/Losses_{min_mu}_50.npy", allow_pickle=True).item()['FEDAC1'][i]
    j = np.argmin([store_2_50['FEDAC2'][i][1], store_3_50['FEDAC2'][i][1], store_4_50['FEDAC2'][i][1], store_5_50['FEDAC2'][i][1]])
    min_mu = [0.01, 0.001, 0.0001, 1e-05][j] 
    Losses_50['FEDAC2'][i] = np.load(f"results/Losses_{min_mu}_50.npy", allow_pickle=True).item()['FEDAC2'][i]

    j = np.argmin([store_2_100['FEDAC1'][i][1], store_3_100['FEDAC1'][i][1], store_4_100['FEDAC1'][i][1], store_5_100['FEDAC1'][i][1]])
    min_mu = [0.01, 0.001, 0.0001, 1e-05][j] 
    Losses_100['FEDAC1'][i] = np.load(f"results/Losses_{min_mu}_100.npy", allow_pickle=True).item()['FEDAC1'][i]
    j = np.argmin([store_2_100['FEDAC2'][i][1], store_3_100['FEDAC2'][i][1], store_4_100['FEDAC2'][i][1], store_5_100['FEDAC2'][i][1]])
    min_mu = [0.01, 0.001, 0.0001, 1e-05][j] 
    Losses_100['FEDAC2'][i] = np.load(f"results/Losses_{min_mu}_100.npy", allow_pickle=True).item()['FEDAC2'][i]

    j = np.argmin([store_2_200['FEDAC1'][i][1], store_3_200['FEDAC1'][i][1], store_4_200['FEDAC1'][i][1], store_5_200['FEDAC1'][i][1]])
    min_mu = [0.01, 0.001, 0.0001, 1e-05][j] 
    Losses_200['FEDAC1'][i] = np.load(f"results/Losses_{min_mu}_200.npy", allow_pickle=True).item()['FEDAC1'][i]
    j = np.argmin([store_2_200['FEDAC2'][i][1], store_3_200['FEDAC2'][i][1], store_4_200['FEDAC2'][i][1], store_5_200['FEDAC2'][i][1]])
    min_mu = [0.01, 0.001, 0.0001, 1e-05][j] 
    Losses_200['FEDAC2'][i] = np.load(f"results/Losses_{min_mu}_200.npy", allow_pickle=True).item()['FEDAC2'][i]

np.save("results/Losses_20.npy", Losses_20)
np.save("results/Losses_50.npy", Losses_50)
np.save("results/Losses_100.npy", Losses_100)
np.save("results/Losses_200.npy", Losses_200)