Untitled

 avatar
unknown
matlab
3 years ago
4.2 kB
4
Indexable
clear 
set(0,'DefaultTextInterpreter','none')

color_vrfwA = [0.0157, 0.4275, 0.7020]
color_vrfwC = [0.5137, 0.0863, 0.7804]
color_vrfwAC = [0.9804, 0.3961, 0.1451]
color_nfwpo = [0.3922, 0.8314, 0.0745]
color_nfwpo_b512 = [1, 0, 0]

vrfwA_s = []
vrfwAC_s = []
vrfwC_s = []
nfwpo_s = []
nfwpo512_s = []
count = 20 % 200
for arg_seed = 0:2
    tmp=readNPY(['NSFnet/VRonA/Network_' num2str(arg_seed) '_DDPGFW_NSFnet_multi_new_eval_reward.npy']);
    tmp_step = tmp(1:(50/count):50)
    vrfwA_s(:, end+1) = [tmp_step', tmp(end)]';

    tmp=readNPY(['NSFnet/VRonC/Network_' num2str(arg_seed) '_DDPGFW_NSFnet_multi_new_eval_reward.npy']);
    tmp_step = tmp(1:(50/count):50)
    vrfwC_s(:, end+1) = [tmp_step', tmp(end)]';

    tmp=readNPY(['NSFnet/VRonAC/Network_' num2str(arg_seed) '_DDPGFW_NSFnet_multi_new_eval_reward.npy']);
    tmp_step = tmp(1:(50/count):50)
    vrfwAC_s(:, end+1) = [tmp_step', tmp(end)]';

    tmp=readNPY(['NSFnet/NFWPO/Network_' num2str(arg_seed) '_DDPGFW_NSFnet_multi_new_eval_reward.npy']);
    tmp_step = tmp(1:(50/count):50)
    nfwpo_s(:, end+1) = [tmp_step', tmp(end)]';

    
end
x = 0:(500000/count):500000
% x = 1:1:count

vrfwA_mean = mean(vrfwA_s,2);
vrfwA_std = std(vrfwA_s,1,2);

vrfwC_mean = mean(vrfwC_s,2);
vrfwC_std = std(vrfwC_s,1,2);

vrfwAC_mean = mean(vrfwAC_s,2);
vrfwAC_std = std(vrfwAC_s,1,2);

nfwpo_mean = mean(nfwpo_s,2);
nfwpo_std = std(nfwpo_s,1,2);


curve1 = vrfwA_mean + vrfwA_std;
curve2 = vrfwA_mean - vrfwA_std;
x2 = [x, fliplr(x)];
inBetween = [curve1.' ,fliplr(curve2.')];
g=fill(x2, inBetween, color_vrfwA,'EdgeColor',color_vrfwA,'EdgeAlpha',.2,'FaceAlpha',.1);  %color [x,x,x] can chose by c = uisetcolor([1 1 0],'Select a color')
hold on

curve1 = vrfwC_mean + vrfwC_std;
curve2 = vrfwC_mean - vrfwC_std;
x2 = [x, fliplr(x)];
inBetween = [curve1.' ,fliplr(curve2.')];
g=fill(x2, inBetween, color_vrfwC,'EdgeColor',color_vrfwC,'EdgeAlpha',.2,'FaceAlpha',.1);  %color [x,x,x] can chose by c = uisetcolor([1 1 0],'Select a color')
hold on

curve1 = vrfwAC_mean + vrfwAC_std;
curve2 = vrfwAC_mean - vrfwAC_std;
x2 = [x, fliplr(x)];
inBetween = [curve1.' ,fliplr(curve2.')];
g=fill(x2, inBetween, color_vrfwAC,'EdgeColor',color_vrfwAC,'EdgeAlpha',.2,'FaceAlpha',.1);  %color [x,x,x] can chose by c = uisetcolor([1 1 0],'Select a color')
hold on

curve1 = nfwpo_mean + nfwpo_std;
curve2 = nfwpo_mean - nfwpo_std;
x2 = [x, fliplr(x)];
inBetween = [curve1.' ,fliplr(curve2.')];
g=fill(x2, inBetween, color_nfwpo,'EdgeColor',color_nfwpo,'EdgeAlpha',.2,'FaceAlpha',.1);  %color [x,x,x] can chose by c = uisetcolor([1 1 0],'Select a color')
hold on



h1=plot(x, vrfwA_mean, '-o', 'DisplayName','VRFWPO on Actor','Color',color_vrfwA,'LineWidth',2)
hold on 
h2=plot(x, vrfwC_mean, '-o', 'DisplayName','VRFWPO on Critic','Color',color_vrfwC,'LineWidth',2)
hold on 
h3=plot(x, vrfwAC_mean, '-o', 'DisplayName','VRFWPO on Actor Critic','Color',color_vrfwAC,'LineWidth',2)
hold on 
h4=plot(x, nfwpo_mean, '-o', 'DisplayName','NFWPO','Color',color_nfwpo,'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 


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,[-0.5 25000]);

title('NSFnet seed 0')

% Create ylabel
ylabel('Average Return');

% Create xlabel
xlabel('Time Steps');
% Create legend
%legend
legend([h1 h2 h3 h4], 'Location', 'southeast')
% saveas(gcf,'NFWPO_1024.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...