Compare commits
No commits in common. "4fd701c86cf8d448ba5a7670ec4963c5a9b30be4" and "69fe33deec23b1580e74cd958a943d3ff6e5e1cc" have entirely different histories.
4fd701c86c
...
69fe33deec
6
PPO.py
6
PPO.py
|
@ -106,14 +106,14 @@ class AgentPPO:
|
||||||
self.get_reward_sum = None # self.get_reward_sum_gae if if_use_gae else self.get_reward_sum_raw
|
self.get_reward_sum = None # self.get_reward_sum_gae if if_use_gae else self.get_reward_sum_raw
|
||||||
self.trajectory_list = None
|
self.trajectory_list = None
|
||||||
|
|
||||||
def init(self, net_dim, state_dim, action_dim, learning_rate=1e-4, if_use_gae=False, gpu_id=0, layer_norm=False):
|
def init(self, net_dim, state_dim, action_dim, learning_rate=1e-4, if_use_gae=False, gpu_id=0):
|
||||||
self.device = torch.device(f"cuda:{gpu_id}" if (torch.cuda.is_available() and (gpu_id >= 0)) else "cpu")
|
self.device = torch.device(f"cuda:{gpu_id}" if (torch.cuda.is_available() and (gpu_id >= 0)) else "cpu")
|
||||||
self.trajectory_list = list()
|
self.trajectory_list = list()
|
||||||
# choose whether to use gae or not
|
# choose whether to use gae or not
|
||||||
self.get_reward_sum = self.get_reward_sum_gae if if_use_gae else self.get_reward_sum_raw
|
self.get_reward_sum = self.get_reward_sum_gae if if_use_gae else self.get_reward_sum_raw
|
||||||
|
|
||||||
self.cri = self.ClassCri(net_dim, state_dim, action_dim, layer_norm).to(self.device)
|
self.cri = self.ClassCri(net_dim, state_dim, action_dim).to(self.device)
|
||||||
self.act = self.ClassAct(net_dim, state_dim, action_dim, layer_norm).to(self.device) if self.ClassAct else self.cri
|
self.act = self.ClassAct(net_dim, state_dim, action_dim).to(self.device) if self.ClassAct else self.cri
|
||||||
self.cri_target = deepcopy(self.cri) if self.if_use_cri_target else self.cri
|
self.cri_target = deepcopy(self.cri) if self.if_use_cri_target else self.cri
|
||||||
self.act_target = deepcopy(self.act) if self.if_use_act_target else self.act
|
self.act_target = deepcopy(self.act) if self.if_use_act_target else self.act
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -1,3 +1,5 @@
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
solar_parameters = {
|
solar_parameters = {
|
||||||
'I_sc0': 8.0, # 参考条件下的短路电流 (A)
|
'I_sc0': 8.0, # 参考条件下的短路电流 (A)
|
||||||
'V_b': 25, # 基准电压
|
'V_b': 25, # 基准电压
|
||||||
|
|
|
@ -64,7 +64,7 @@ def plot_optimization_result(datasource, directory): # data source is dataframe
|
||||||
# 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()
|
# 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 result has been ploted')
|
||||||
|
|
||||||
|
|
||||||
def plot_evaluation_information(datasource, directory):
|
def plot_evaluation_information(datasource, directory):
|
||||||
|
@ -134,7 +134,7 @@ def plot_evaluation_information(datasource, directory):
|
||||||
axs[0, 1].legend(loc='upper right', fontsize=12, frameon=False, labelspacing=0.3)
|
axs[0, 1].legend(loc='upper right', fontsize=12, frameon=False, labelspacing=0.3)
|
||||||
# plt.show()
|
# 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('the evaluation figure have been plot and saved')
|
||||||
|
|
||||||
|
|
||||||
def make_dir(directory, feature_change):
|
def make_dir(directory, feature_change):
|
||||||
|
|
Loading…
Reference in New Issue