print(iteration) #if the number of iterations reaches 1000 - then an optimal solution was not reached if iteration == 1000: suboptimal = suboptimal + 1 print(simulation_time) pbd = [] pbc = [] for i in range(num_agents): pbd.append([players[i].variables.p[3].x]) pbc.append([players[i].variables.p[0].x]) pbd = np.asarray(pbd) pbc = np.asarray(pbc) #update state of all batteries SOC_bat = SOC_bat - pbc*0.99 - pbd*0.99 PowerPointsDF = func.createPowerPoints(players, time_period, PowerPointsDF, solar, loads, solar_panels) TradesDF = func.createTradeFile(players, TradesDF, time_period, Price_avg, part) SOC_DF = func.createSOCFile(SOC_bat, SOC_DF, time_period) Metrics_DF = func.createMetricsFile(Metrics_DF, simulation_time, time_period, iteration) ind_row = Price_DF.shape[0] Price_DF.loc[ind_row, 'Time Period'] = time_period Price_DF.loc[ind_row, 'Avg Price (c/kwh)'] = Price_avg*100 #save values to .csv files TradesDF.to_csv(r"C:\Users\Inessa\Desktop\4th_Year\FYP\Methodology_Eth\optimisation\Final optimisation\Faster Attempts\Results\Trade_Tests.csv") SolarDF.to_csv(r'C:\Users\Inessa\Desktop\4th_Year\FYP\Methodology_Eth\optimisation\Final optimisation\Faster Attempts\Results\Solar_Tests.csv')
# print("prosumer3 grid export", players[3].variables.p[1]) # print("prosumer3 grid household load", players[3].variables.p[2]) # print("prosumer3 battery discharge", players[3].variables.p[3]) # print("prosumer3 solar", players[3].variables.p[4]) # print("prosumer3 grid import", players[3].variables.p[5]) print(simulation_time) pbd = [] pbc = [] for i in range(num_agents): pbd.append([players[i].variables.p[3].x]) pbc.append([players[i].variables.p[0].x]) pbd = np.asarray(pbd) pbc = np.asarray(pbc) #update state of all batteries SOC_bat = SOC_bat - pbc * 0.99 - pbd * 0.99 PowerPointsDF = func.createPowerPoints(players, time_period, PowerPointsDF) TradesDF = func.createTradeFile(players, TradesDF, time_period, Price_avg, part) SOC_DF = func.createSOCFile(SOC_bat, SOC_DF, time_period) Metrics_DF = func.createMetricsFile(Metrics_DF, simulation_time, time_period, iteration) ind_row = Price_DF.shape[0] Price_DF.loc[ind_row, 'Time Period'] = time_period Price_DF.loc[ind_row, 'Avg Price (c/kwh)'] = Price_avg * 100 # print('Test global prim_res', test_prim) # print('Test global dual_res', test_dual) #TradesDF.to_csv('Trade_Tests.csv') #SolarDF.to_csv('Solar_Tests.csv') #SOC_DF.to_csv('SOC_Tests.csv')