Compare commits
2 Commits
69fe33deec
...
4fd701c86c
Author | SHA1 | Date |
---|---|---|
|
4fd701c86c | |
|
21be0966dc |
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.trajectory_list = None
|
||||
|
||||
def init(self, net_dim, state_dim, action_dim, learning_rate=1e-4, if_use_gae=False, gpu_id=0):
|
||||
def init(self, net_dim, state_dim, action_dim, learning_rate=1e-4, if_use_gae=False, gpu_id=0, layer_norm=False):
|
||||
self.device = torch.device(f"cuda:{gpu_id}" if (torch.cuda.is_available() and (gpu_id >= 0)) else "cpu")
|
||||
self.trajectory_list = list()
|
||||
# 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.cri = self.ClassCri(net_dim, state_dim, action_dim).to(self.device)
|
||||
self.act = self.ClassAct(net_dim, state_dim, action_dim).to(self.device) if self.ClassAct else self.cri
|
||||
self.cri = self.ClassCri(net_dim, state_dim, action_dim, layer_norm).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.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
|
||||
|
||||
|
|
Binary file not shown.
|
@ -1,5 +1,3 @@
|
|||
import numpy as np
|
||||
|
||||
solar_parameters = {
|
||||
'I_sc0': 8.0, # 参考条件下的短路电流 (A)
|
||||
'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)])
|
||||
# plt.show()
|
||||
fig.savefig(f"{directory}/optimization_information.svg", format='svg', dpi=600, bbox_inches='tight')
|
||||
print('optimization result has been ploted')
|
||||
print('optimization results have been ploted and saved')
|
||||
|
||||
|
||||
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)
|
||||
# plt.show()
|
||||
fig.savefig(f"{directory}/Evoluation Information.svg", format='svg', dpi=600, bbox_inches='tight')
|
||||
print('the evaluation figure have been plot and saved')
|
||||
print('evaluation figure have been plot and saved')
|
||||
|
||||
|
||||
def make_dir(directory, feature_change):
|
||||
|
|
Loading…
Reference in New Issue