-
Notifications
You must be signed in to change notification settings - Fork 5
/
dataplot3sa.m
221 lines (217 loc) · 8.48 KB
/
dataplot3sa.m
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
%% Single plot of accumulative quantity
% The independent variables is time.
line_width = [1 1 1 1 1 1];
marker_size = [6 7 6 8 6 6 6];
marker = {'none', '+', 'none', 'x', 's', 'd', 'o'};
line_style = {'-.', 'none', '-', 'none', '--', '--', '--'};
color_set = [Color.MildGreen; Color.Purple; Color.MildBlue; Color.Red; Color.Black; Color.Gray];
legend_label = {'FSR0', 'FSR', 'HSR0', 'HSR', 'Baseline', '#Variables'};
i = 4;
if strcmpi(mode, 'var-eta')
j = 1;
else
j = i;
end
tx = 50:NUM_EVENT;
t = results.DimBaseline{j}.Time(tx);
if length(tx)>=10
marker_index = round(linspace(1,length(tx), 10));
end
%% Number of Reconfiguration (with benchmark)
% TODO: exclude those with zero reconfigureation cost (linear).
if exist('fig_num_reconfig', 'var') && fig_num_reconfig.isvalid
figure(fig_num_reconfig);
else
fig_num_reconfig = figure('Name', 'Number of Reconfiguration (With benchmark)');
end
% fig_num_reconfig.OuterPosition = [100 400 400 380];
yyaxis('left');
hl = plot(t, cumsum(results.Fastconfig{i}{tx,'ReVariables'}), '-.',...
t, cumsum(results.FastconfigReserve{i}{tx,'ReVariables'}), '+',...
t, cumsum(results.Dimconfig{i}{tx,'ReVariables'}),'-',...
t, cumsum(results.DimconfigReserve{i}{tx,'ReVariables'}),'x',...
t, cumsum(results.DimBaseline{j}{tx,'ReVariables'}), '--s');
for k=1:length(hl)
hl(k).Color = color_set(k).RGB;
hl(k).LineWidth = line_width(k);
hl(k).MarkerIndices = marker_index;
hl(k).MarkerSize = marker_size(k);
end
ylabel('Number of Reconfiguration');
ylimmax = hl(1).Parent.YLim(2);
yyaxis right
hr = plot(t, cumsum(results.DimBaseline{j}{tx,'NumVariables'}), '--d');
hr(1).Color = Color.Gray.RGB;
hr(1).LineWidth = 1;
hr(1).MarkerIndices = marker_index;
ylabel('Number of Variables');
hr.Parent.YColor = Color.Gray.RGB;
% title(sprintf('\\eta=%.2f', etas(i)));
legend(legend_label(1:6), 'Location', 'northwest');
ylimmax = max(ylimmax, hr.Parent.YLim(2));
yyaxis left;
ylim(hl(1).Parent, [0, ylimmax]);
yyaxis right;
ylim(hr.Parent, [0, ylimmax]);
xlabel('Time');
xlim([t(1), t(end)]);
%% Number of Reconfiguration (No benchmark)
if exist('fig_num_reconfig_nb', 'var') && fig_num_reconfig_nb.isvalid
figure(fig_num_reconfig_nb);
else
fig_num_reconfig_nb = figure('Name', 'Number of Reconfiguration (No benchmark)');
end
% fig_num_reconfig.OuterPosition = [100 400 400 380];
hl = plot(t, cumsum(results.Fastconfig{i}{tx,'ReVariables'}), '-.',...
t, cumsum(results.FastconfigReserve{i}{tx,'ReVariables'}), '--+',...
t, cumsum(results.Dimconfig{i}{tx,'ReVariables'}),'-',...
t, cumsum(results.DimconfigReserve{i}{tx,'ReVariables'}),'--x');
for k=1:length(hl)
hl(k).Color = color_set(k).RGB;
hl(k).LineWidth = 1;
hl(k).MarkerIndices = marker_index;
hl(k).MarkerSize = marker_size(k);
end
xlabel('Time');
ylabel('Number of Reconfiguration');
legend(legend_label(1:4), 'Location', 'northwest');
xlim([t(1), t(end)]);
%% Cost of Reconfiguration (with benchmark)
% If dimensioning is triggered, the reconfiguration cost has been
% distibuted to the whole dimensioning interval. To calculate the
% reconfiguration cost conveniently, we recollect the cost to a single
% configure interval.
if exist('fig_cost_reconfig', 'var') && fig_cost_reconfig.isvalid
figure(fig_cost_reconfig);
else
fig_cost_reconfig = figure('Name', 'Cost of Reconfiguration (With benchmark)');
end
cost = [results.Fastconfig{i}{tx,'Cost'}.*results.Fastconfig{i}{tx,'Interval'}, ...
results.FastconfigReserve{i}{tx,'Cost'}.*results.FastconfigReserve{i}{tx,'Interval'},...
results.Dimconfig{i}{tx,'Cost'}.*results.Dimconfig{i}{tx,'Interval'}, ...
results.DimconfigReserve{i}{tx,'Cost'}.*results.DimconfigReserve{i}{tx,'Interval'}];
if strcmpi(mode, 'var-eta')
cost = [cost, results.DimBaseline{1}{tx,'Cost'}*(etas(i)/etas(1))...
.*results.DimBaseline{1}{tx,'Interval'}];
else
cost = [cost, results.DimBaseline{i}{tx,'Cost'}.*results.DimBaseline{i}{tx,'Interval'}];
end
hl = plot(t, cumsum(cost));
for k=1:length(hl)
hl(k).Color = color_set(k).RGB;
hl(k).LineWidth = line_width(k);
hl(k).LineStyle = line_style{k};
hl(k).Marker = marker{k};
hl(k).MarkerIndices = marker_index;
end
ylabel('Cummulated Cost');
xlabel('Time');
xlim([t(1),t(end)]);
legend(legend_label(1:5), 'Location', 'northwest');
%% Profit
% Reconfiguration cost is counted as a instantanuous value, while the profit excluding
% reconfiguration cost is distrbuted in the whole configuration interval.
if exist('fig_profit_reconfig', 'var') && fig_profit_reconfig.isvalid
figure(fig_profit_reconfig);
else
fig_profit_reconfig = figure('Name', 'Profit with Reconfiguration');
end
% fig_profit_reconfig.OuterPosition = [100 400 400 380];
profit = [results.Fastconfig{i}{tx,'Profit'}+results.Fastconfig{i}{tx,'Cost'},...
results.FastconfigReserve{i}{tx,'Profit'}+results.FastconfigReserve{i}{tx,'Cost'},...
results.Dimconfig{i}{tx,'Profit'}+results.Dimconfig{i}{tx,'Cost'},...
results.DimconfigReserve{i}{tx,'Profit'}+results.DimconfigReserve{i}{tx,'Cost'},...
results.DimBaseline{j}{tx,'Profit'}+results.DimBaseline{j}{tx,'Cost'}]; % recover profit without reconfiguration cost
% results.Dimconfig0{i}{tx,'Profit'}+results.Dimconfig0{i}{tx,'Cost'}
t_diff = diff(results.DimBaseline{j}{tx,'Time'});
cum_profit = cumsum(profit(end-1,:).*t_diff) - cumsum(cost(end-1,:),1);
hl = plot(t(1:end-1), cum_profit);
mi = marker_index;
mi(end) = mi(end) - 1;
for k=1:length(hl)
hl(k).Color = color_set(k).RGB;
hl(k).LineWidth = line_width(k);
hl(k).LineStyle = line_style{k};
hl(k).Marker = marker{k};
hl(k).MarkerIndices = mi;
end
ylabel('Cummulated Profit');
xlabel('Time');
xlim([t(1), t(end-1)]);
legend(legend_label(1:5), 'Location', 'northwest');
%% Cost of Reconfiguration (no benchmark)
if exist('fig_cost_reconfig_nb', 'var') && fig_cost_reconfig_nb.isvalid
figure(fig_cost_reconfig_nb);
else
fig_cost_reconfig_nb = figure('Name', 'Cost of Reconfiguration (No benchmark)');
end
hl = plot(t, cumsum(cost(:,1:4))); % the first four methods' cost
for k=1:length(hl)
hl(k).Color = color_set(k).RGB;
hl(k).LineWidth = line_width(k);
hl(k).LineStyle = line_style{k};
hl(k).Marker = marker{k};
hl(k).MarkerIndices = marker_index;
end
ylabel('Cummulated Cost');
xlabel('Time');
xlim([t(1),t(end)]);
legend(legend_label(1:4), 'Location', 'northwest');
%% Number of Flow Reconfiguration (with benchmark)
if exist('fig_num_reconfig_flow', 'var') && fig_num_reconfig_flow.isvalid
figure(fig_num_reconfig_flow);
else
fig_num_reconfig_flow = figure('Name', 'Number of Reconfigured Flows (With benchmark)');
end
% fig_num_reconfig.OuterPosition = [100 400 400 380];
yyaxis('left');
hl = plot(t, cumsum(results.Fastconfig{i}{tx,'ReFlows'}), '-.',...
t, cumsum(results.FastconfigReserve{i}{tx,'ReFlows'}), '+',...
t, cumsum(results.Dimconfig{i}{tx,'ReFlows'}),'-',...
t, cumsum(results.DimconfigReserve{i}{tx,'ReFlows'}),'x',...
t, cumsum(results.DimBaseline{j}{tx,'ReFlows'}), '--s');
for k=1:length(hl)
hl(k).Color = color_set(k).RGB;
hl(k).LineWidth = line_width(k);
hl(k).MarkerIndices = marker_index;
hl(k).MarkerSize = marker_size(k);
end
ylabel('Number of Reconfiguration');
ylimmax = hl(1).Parent.YLim(2);
yyaxis right
hr = plot(t, cumsum(results.DimBaseline{j}{tx,'Flows'}), '--d');
hr(1).Color = Color.Gray.RGB;
hr(1).LineWidth = 1;
hr(1).MarkerIndices = marker_index;
ylabel('Number of Flows');
hr.Parent.YColor = Color.Gray.RGB;
% title(sprintf('\\eta=%.2f', etas(i)));
legend(legend_label(1:6), 'Location', 'northwest');
ylimmax = max(ylimmax, hr.Parent.YLim(2));
yyaxis left;
ylim(hl(1).Parent, [0, ylimmax]);
yyaxis right;
ylim(hr.Parent, [0, ylimmax]);
xlabel('Time');
xlim([t(1), t(end)]);
%% Number of Flow Reconfiguration (No benchmark)
if exist('fig_num_reconfig_flow_nb', 'var') && fig_num_reconfig_flow_nb.isvalid
figure(fig_num_reconfig_flow_nb);
else
fig_num_reconfig_flow_nb = figure('Name', 'Number of Reconfigured Flows (No benchmark)');
end
% fig_num_reconfig.OuterPosition = [100 400 400 380];
hl = plot(t, cumsum(results.Fastconfig{i}{tx,'ReFlows'}), '-.',...
t, cumsum(results.FastconfigReserve{i}{tx,'ReFlows'}), '--+',...
t, cumsum(results.Dimconfig{i}{tx,'ReFlows'}),'-',...
t, cumsum(results.DimconfigReserve{i}{tx,'ReFlows'}),'--x');
for k=1:length(hl)
hl(k).Color = color_set(k).RGB;
hl(k).LineWidth = 1;
hl(k).MarkerIndices = marker_index;
hl(k).MarkerSize = marker_size(k);
end
xlabel('Time');
ylabel('Number of Reconfiguration');
legend(legend_label(1:4), 'Location', 'northwest');
xlim([t(1), t(end)]);