plot
This commit is contained in:
parent
80344bd10a
commit
9d0b220b54
4
PPO.py
4
PPO.py
|
@ -331,8 +331,8 @@ if __name__ == '__main__':
|
||||||
buffer = list()
|
buffer = list()
|
||||||
'''init training parameters'''
|
'''init training parameters'''
|
||||||
num_episode = args.num_episode
|
num_episode = args.num_episode
|
||||||
# args.train = False
|
args.train = False
|
||||||
# args.save_network = False
|
args.save_network = False
|
||||||
# args.test_network = False
|
# args.test_network = False
|
||||||
# args.save_test_data = False
|
# args.save_test_data = False
|
||||||
# args.compare_with_gurobi = False
|
# args.compare_with_gurobi = False
|
||||||
|
|
37
plotDRL.py
37
plotDRL.py
|
@ -62,7 +62,7 @@ def plot_optimization_result(datasource, directory): # data source is dataframe
|
||||||
axs[1, 0].plot(T, datasource['netload'], label='Netload', drawstyle='steps-mid', alpha=0.7)
|
axs[1, 0].plot(T, datasource['netload'], label='Netload', drawstyle='steps-mid', alpha=0.7)
|
||||||
axs[1, 0].legend(loc='upper right', fontsize=12, frameon=False, labelspacing=0.3)
|
axs[1, 0].legend(loc='upper right', fontsize=12, frameon=False, labelspacing=0.3)
|
||||||
# axs[1,0].set_xticks([i for i in range(24)],[i for i in range(1,25)])
|
# axs[1,0].set_xticks([i for i in range(24)],[i for i in range(1,25)])
|
||||||
# plt.show()
|
|
||||||
fig.savefig(f"{directory}/optimization_information.svg", format='svg', dpi=600, bbox_inches='tight')
|
fig.savefig(f"{directory}/optimization_information.svg", format='svg', dpi=600, bbox_inches='tight')
|
||||||
print('optimization results have been ploted and saved')
|
print('optimization results have been ploted and saved')
|
||||||
|
|
||||||
|
@ -78,9 +78,9 @@ def plot_evaluation_information(datasource, directory):
|
||||||
plt.autoscale(tight=True)
|
plt.autoscale(tight=True)
|
||||||
|
|
||||||
# prepare data for evaluation the environment here
|
# prepare data for evaluation the environment here
|
||||||
eval_data = pd.DataFrame(test_data['information'])
|
eval_data = pd.DataFrame(test_data['system_info'])
|
||||||
eval_data.columns = ['time_step', 'price', 'netload', 'action', 'real_action', 'soc', 'battery', 'gen1', 'gen2',
|
eval_data.columns = ['time_step', 'price', 'netload', 'action', 'real_action', 'soc', 'battery', 'gen1', 'gen2',
|
||||||
'gen3', 'unbalance', 'operation_cost']
|
'gen3', 'temperature', 'irradiance', 'unbalance', 'operation_cost']
|
||||||
|
|
||||||
# plot unbalance in axs[0]
|
# plot unbalance in axs[0]
|
||||||
axs[0, 0].cla()
|
axs[0, 0].cla()
|
||||||
|
@ -90,10 +90,17 @@ def plot_evaluation_information(datasource, directory):
|
||||||
axs[0, 0].legend(loc='upper right', fontsize=12, frameon=False, labelspacing=0.5)
|
axs[0, 0].legend(loc='upper right', fontsize=12, frameon=False, labelspacing=0.5)
|
||||||
# axs[0,0].set_xticks([i for i in range(24)],[i for i in range(1,25)])
|
# axs[0,0].set_xticks([i for i in range(24)],[i for i in range(1,25)])
|
||||||
|
|
||||||
# plot reward in axs[1]
|
# plot energy charge/discharge with price in ax[1]
|
||||||
axs[1, 1].cla()
|
axs[0, 1].cla()
|
||||||
axs[1, 1].set_ylabel('Costs')
|
axs[0, 1].set_ylabel('Price')
|
||||||
axs[1, 1].bar(eval_data['time_step'], eval_data['operation_cost'])
|
axs[0, 1].set_xlabel('Time Steps')
|
||||||
|
|
||||||
|
axs[0, 1].plot(eval_data['time_step'], eval_data['price'], drawstyle='steps-mid', label='Price', color='pink')
|
||||||
|
axs[0, 1] = axs[0, 1].twinx()
|
||||||
|
axs[0, 1].set_ylabel('SOC')
|
||||||
|
# axs[0,1].set_xticks([i for i in range(24)], [i for i in range(1, 25)])
|
||||||
|
axs[0, 1].plot(eval_data['time_step'], eval_data['soc'], drawstyle='steps-mid', label='SOC', color='grey')
|
||||||
|
axs[0, 1].legend(loc='upper right', fontsize=12, frameon=False, labelspacing=0.3)
|
||||||
|
|
||||||
# plot generation and netload in ax[2]
|
# plot generation and netload in ax[2]
|
||||||
axs[1, 0].cla()
|
axs[1, 0].cla()
|
||||||
|
@ -121,18 +128,10 @@ def plot_evaluation_information(datasource, directory):
|
||||||
axs[1, 0].plot(x, eval_data['netload'], drawstyle='steps-mid', label='Netload')
|
axs[1, 0].plot(x, eval_data['netload'], drawstyle='steps-mid', label='Netload')
|
||||||
axs[1, 0].legend(loc='upper right', fontsize=12, frameon=False, labelspacing=0.3)
|
axs[1, 0].legend(loc='upper right', fontsize=12, frameon=False, labelspacing=0.3)
|
||||||
|
|
||||||
# plot energy charge/discharge with price in ax[3].
|
# plot reward in axs[3]
|
||||||
axs[0, 1].cla()
|
axs[1, 1].cla()
|
||||||
axs[0, 1].set_ylabel('Price')
|
axs[1, 1].set_ylabel('Costs')
|
||||||
axs[0, 1].set_xlabel('Time Steps')
|
axs[1, 1].bar(eval_data['time_step'], eval_data['operation_cost'])
|
||||||
|
|
||||||
axs[0, 1].plot(eval_data['time_step'], eval_data['price'], drawstyle='steps-mid', label='Price', color='pink')
|
|
||||||
axs[0, 1] = axs[0, 1].twinx()
|
|
||||||
axs[0, 1].set_ylabel('SOC')
|
|
||||||
# axs[0,1].set_xticks([i for i in range(24)], [i for i in range(1, 25)])
|
|
||||||
axs[0, 1].plot(eval_data['time_step'], eval_data['soc'], drawstyle='steps-mid', label='SOC', color='grey')
|
|
||||||
axs[0, 1].legend(loc='upper right', fontsize=12, frameon=False, labelspacing=0.3)
|
|
||||||
# plt.show()
|
|
||||||
fig.savefig(f"{directory}/Evoluation Information.svg", format='svg', dpi=600, bbox_inches='tight')
|
fig.savefig(f"{directory}/Evoluation Information.svg", format='svg', dpi=600, bbox_inches='tight')
|
||||||
print('evaluation figure have been plot and saved')
|
print('evaluation figure have been plot and saved')
|
||||||
|
|
||||||
|
|
2
tools.py
2
tools.py
|
@ -7,7 +7,7 @@ import torch
|
||||||
from gurobipy import GRB
|
from gurobipy import GRB
|
||||||
|
|
||||||
|
|
||||||
def optimization_base_result(env,month,day,initial_soc):
|
def optimization_base_result(env, month, day, initial_soc):
|
||||||
price = env.data_manager.get_series_price_data(month, day)
|
price = env.data_manager.get_series_price_data(month, day)
|
||||||
load = env.data_manager.get_series_load_cons_data(month, day)
|
load = env.data_manager.get_series_load_cons_data(month, day)
|
||||||
temperature = env.data_manager.get_series_temperature_data(month, day)
|
temperature = env.data_manager.get_series_temperature_data(month, day)
|
||||||
|
|
Loading…
Reference in New Issue