Untitled
unknown
matlab
4 years ago
4.2 kB
8
Indexable
clear
set(0,'DefaultTextInterpreter','none')
ddpg_s = [];
ddpg_proj_s = [];
fw_s = [];
rw_shaping_s =[];
sac_proj_s = []
count = 50 % 200
for arg_seed = 0:2
% 5G_0_DDPGProjection_before_Action_State_relate_cons
% tmp=readNPY(['5G_' num2str(arg_seed) '_DDPGProjection_eval_reward_State_relate_cons.npy']);
% ddpg_s( :, end+1 ) = tmp;
tmp=readNPY(['eval100_result/ddpg_proj/5G_' num2str(arg_seed) '_DDPGProjection_eval_reward_State_relate_cons.npy']);
ddpg_proj_s( :, end+1 ) = tmp(1:(200/count):200);
tmp=readNPY(['eval100_result/nfwpo/5G_' num2str(arg_seed) '_NFWPO_eval_reward_State_relate_cons.npy']);
fw_s( :, end+1 ) = tmp(1:(200/count):200);
tmp=readNPY(['eval100_result/reward_shaping/5G_' num2str(arg_seed) '_DDPGProjection_reward_shap_eval_reward_State_relate_cons.npy']);
rw_shaping_s( :, end+1 ) = tmp(1:(200/count):200);
% ddpg_mean = mean(ddpg_s,2);
ddpg_proj_mean = mean(ddpg_proj_s,2);
fw_mean = mean(fw_s,2);
rw_mean = mean(rw_shaping_s,2);
% ddpg_std = std(ddpg_s,1,2);
ddpg_proj_std = std(ddpg_proj_s,1,2);
fw_std = std(fw_s,1,2);
rw_std = std(rw_shaping_s,1,2);
end
x = 1:(1000000/count):1000000
% x = 1:1:count
curve1 = fw_mean + fw_std;
curve2 = fw_mean - fw_std;
x2 = [x, fliplr(x)];
inBetween = [curve1.' ,fliplr(curve2.')];
g=fill(x2, inBetween, [0.0157,0.4275,0.7020],'EdgeColor',[0.0157,0.4275,0.7020],'EdgeAlpha',.2,'FaceAlpha',.1); %color [x,x,x] can chose by c = uisetcolor([1 1 0],'Select a color')
hold on
% curve1 = ddpg_mean + ddpg_std;
% curve2 = ddpg_mean - ddpg_std;
% x2 = [x, fliplr(x)];
% inBetween = [curve1.' ,fliplr(curve2.')];
% g=fill(x2, inBetween, [0.5137 0.0863 0.7804],'FaceAlpha',.1,'EdgeColor',[0.5137 0.0863 0.7804],'EdgeAlpha',.2);
% %g=patch(x2,inBetween,[0.9294 0.8196 1.0000],'LineStyle','none','FaceAlpha',1);
% hold on
curve1 = rw_mean + rw_std;
curve2 = rw_mean - rw_std;
x2 = [x, fliplr(x)];
inBetween = [curve1.' ,fliplr(curve2.')];
g=fill(x2, inBetween, [ 0.3922 0.8314 0.0745],'EdgeColor',[ 0.3922 0.8314 0.0745],'EdgeAlpha',.2,'FaceAlpha',.1);
%g1=patch(x2,inBetween,[0.8588 1.0000 0.7608],'LineStyle','none','FaceAlpha',.5);
hold on
curve1 = ddpg_proj_mean + ddpg_proj_std;
curve2 = ddpg_proj_mean - ddpg_proj_std;
x2 = [x, fliplr(x)];
inBetween = [curve1.' ,fliplr(curve2.')];
g=fill(x2, inBetween,[0.9804 0.3961 0.1451],'EdgeColor',[0.9804 0.3961 0.1451],'EdgeAlpha',.2,'FaceAlpha',.1); %color [x,x,x] can chose by c = uisetcolor([1 1 0],'Select a color')
hold on
h1=plot(x, fw_mean(1:count), '-o', 'DisplayName','NFWPO','Color',[0.0157,0.4275,0.7020],'LineWidth',2)
hold on
% h2=plot(x, ddpg_mean(1:count),'DisplayName','DDPG+OptLayer','Color',[0.5137 0.0863 0.7804],'LineWidth',2)
% hold on
h3=plot(x, rw_mean(1:count), '-*', 'DisplayName','DDPG+Reward Shaping','Color',[ 0.3922 0.8314 0.0745],'LineWidth',2)
hold on
h4=plot(x, ddpg_proj_mean(1:count), '-s', 'DisplayName','DDPG+Projection ','Color',[ 0.9804 0.3961 0.1451],'LineWidth',2)
hold off
% set position , gcf means current figure
set(gcf,'color',[1 1 1]);
set(gcf,'position',[0,0,1000,800])
% gca means current axis
set(gca,'FontSize',24)
set(gca,'linewidth',2)
%modify the y axis
ylim(gca,[-100 600]);
% Create ylabel
ylabel('Average Return');
% Create xlabel
xlabel('Time Steps');
% Create legend
%legend
legend([h1 h3 h4])
saveas(gcf,'Avg_Return_1.png')
%{
h=gcf;
set(h,'PaperOrientation','landscape');
set(h,'PaperPosition', [1 1 28 19]);
print(gcf, '-dpdf', 'test2.pdf');
%}
%set(legend,...
%'Position',[0.231935291724779 0.731352493686703 0.179393305439331 0.157924100495552],...
%'LineWidth',1);
% ddpg_s.append(tmp[0:ran])
% tmp=np.load("Network_{}_DDPGwithOpt_NSFnet_multi_new_Reward.npy".format(arg_seed))
% ddpg_opt_s.append(tmp[0:ran])
% tmp=np.load("Network_{}_DDPGFW_NSFnet_multi_new_Reward.npy".format(arg_seed))
% fw_s.append(tmp[0:ran])
% tmp=np.load("Network_{}_DDPGwithOpt_reward_shaping2_NSFnet_multi_new_Reward.npy".format(arg_seed))
% rw_shaping_s.append(tmp) Editor is loading...