-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_results.m
More file actions
135 lines (96 loc) · 3.51 KB
/
Copy pathplot_results.m
File metadata and controls
135 lines (96 loc) · 3.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
close all; clear; clc;
result_parent_dir = './results';
result_dir = {
% 'dqn_agent__UGV2_20211126_224503',...
% 'dqn_agent__UGV3_20211126_224503',...
% 'dqn_agent__UGV4_20211126_224503',...
% 'dqn_agent__UGV5_20211126_224503',...
% 'dqn_agent__UGV6_20211126_224503',...
'atpc_agent__UGV1_20211127_121051'...
'atpc_agent__UGV2_20211127_121051'...
'atpc_agent__UGV3_20211127_121051'...
'atpc_agent__UGV4_20211127_121051'...
'atpc_agent__UGV6_20211127_121051'...
'atpc_agent__UGV7_20211127_121051'...
};
result_algorithms = {
% 'DQN',...
% 'WIFI',...
% 'DQN UAV1',...
% 'DQN UAV2',...
% 'DQN UAV3',...
% 'DQN UAV4',...
% 'DQN UAV5',...
'ATPC UAV1',...
'ATPC UAV2',...
'ATPC UAV3',...
'ATPC UAV4',...
'ATPC UAV5',...
'ATPC UAV6',...
};
result_number = length(result_dir);
figure_titles = {
'frame_loss', ...
'Date latency (s)', ...
'Power (dBm)', ...
};
figure_plot_data = {
'frame_loss', ...
'latency', ...
'power',...
};
figure_number = length(figure_titles);
plot_handlers = gobjects(figure_number, result_number);
double_cell = cell(1, figure_number);
[double_cell{:}] = deal('double');
T = table(...
'Size', [result_number, figure_number], ...
'VariableTypes', double_cell, ...
'VariableNames', figure_plot_data, ...
'RowNames', result_algorithms);
move_destination_table = zeros(4,result_number);
channel_table = zeros(2,result_number);
for result_idx = 1:result_number
result_path = sprintf('%s/%s/results.mat', result_parent_dir, result_dir{result_idx});
load(result_path);
latency = data_latency./(51.*ones(1,800)-packet_loss);
frame_loss = packet_loss/50;
for fig_idx = 1:figure_number
plot_data = eval(figure_plot_data{fig_idx});
plot_handlers(fig_idx, result_idx) = plot_one_figure(fig_idx, plot_data(1,1:500));
% T(result_idx, fig_idx) = {mean(plot_data(10:100,:), 'all')};
T(result_idx, fig_idx) = {mean(plot_data(1:500), 'all')};
end
% move_destination_table(1,result_idx) = sum(move_destination == 0, 'all');
% move_destination_table(2,result_idx) = sum(move_destination == 2, 'all');
% move_destination_table(3,result_idx) = sum(move_destination == 4, 'all');
% move_destination_table(4,result_idx) = sum(move_destination == 6, 'all');
% move_destination_table = move_destination_table';
channel_table(1,result_idx) = 800%sum(channel == 1, 'all');
channel_table(2,result_idx) = 0%sum(channel == 6, 'all');
% channel_table = channel_table'
end
for fig_idx = 1:figure_number
figure(fig_idx);
legend(plot_handlers(fig_idx, :), result_algorithms);
xlabel('time slot.');
ylabel(figure_titles{fig_idx});
end
figure; hold on;
bar([1,6],channel_table);
legend(result_algorithms, 'location', 'southeast');
xticks([1,6]);
xlabel('Channel');
ylabel('Switch times');
% figure; hold on;
% bar([0,2,4,6],move_destination_table);
% legend(result_algorithms, 'location', 'southeast');
% xticks([0, 2, 4 ,6]);
% xlabel('Move destination');
% ylabel('Switch times');
figure_number = figure_number + 1;
T
% for fig_idx = 1:figure_number
% figure(fig_idx);
% saveas(gcf, sprintf('figures/%d.emf', fig_idx));
% end