-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBoosted_DCA_script.m
More file actions
180 lines (143 loc) · 4.86 KB
/
Copy pathBoosted_DCA_script.m
File metadata and controls
180 lines (143 loc) · 4.86 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
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
clear all; clc;
%% Figure 1
% Parameters
L1 = 2.0; mu1 = 1.0;
L2 = 2.0; mu2 = 0.0;
n_list = (1:12); % Iteration counts
alpha_list = [0, 1/4, 1/3, 1/2, 3/4]; % Different values of alpha
% Initialize result array (rows: alpha, columns: n)
pepit_taus = zeros(length(alpha_list), length(n_list));
% Compute values
for i = 1:length(alpha_list)
alpha = alpha_list(i);
for j = 1:length(n_list)
n = n_list(j);
pepit_tau = Boosted_DCA(L1, mu1, L2, mu2, alpha, n);
pepit_taus(i, j) = pepit_tau;
end
% Progress
fprintf('i = %d / %d done\n', i, length(alpha_list));
end
% Create figure
figure;
hold on;
% Plot each curve for a given alpha
for i = 1:length(alpha_list)
plot(n_list, pepit_taus(i, :), '--', 'LineWidth', 2, ...
'DisplayName', sprintf('\\alpha = %.2f', alpha_list(i)));
end
% Set labels
xlabel('Iteration count N', 'FontSize', 14, 'Color', [0.2 0.2 0.2]);
ylabel('Worst-case $\min_{0\leq i\leq n} \|g_1^i - g_2^i\|^2$', ...
'Interpreter', 'latex', 'FontSize', 14, 'Color', [0.2 0.2 0.2]);
% Title
title(sprintf('$L_1 = %.1f,\\ L_2 = %.1f,\\ \\mu_1 = %.1f,\\ \\mu_2 = %.1f$', ...
L1, L2, mu1, mu2), ...
'Interpreter', 'latex', 'FontSize', 16, 'Color', [0.2 0.2 0.2]);
% Move legend below the plot
legend('Location', 'southoutside', ...
'Orientation', 'horizontal', ...
'FontSize', 10, ...
'Box', 'off');
% Adjust layout
set(gca, 'Position', [0.1 0.3 0.85 0.6]); % Leave space at bottom for legend
% Save the figure
print(gcf, 'Figure1.eps', '-depsc');
% Show the plot
hold off;
%% Figure 2
% Parameters
L1 = 2.0; mu1 = 0.0;
L2 = 2.0; mu2 = 1.0;
n_list = (1:12); % Iteration counts
alpha_list = [0, 1/4, 1/3, 1/2, 3/4]; % Different values of alpha
% Initialize result array (rows: alpha, columns: n)
pepit_taus = zeros(length(alpha_list), length(n_list));
% Compute values
for i = 1:length(alpha_list)
alpha = alpha_list(i);
for j = 1:length(n_list)
n = n_list(j);
pepit_tau = Boosted_DCA(L1, mu1, L2, mu2, alpha, n);
pepit_taus(i, j) = pepit_tau;
end
% Progress
fprintf('i = %d / %d done\n', i, length(alpha_list));
end
% Create figure
figure;
hold on;
% Plot each curve for a given alpha
for i = 1:length(alpha_list)
plot(n_list, pepit_taus(i, :), '--', 'LineWidth', 2, ...
'DisplayName', sprintf('\\alpha = %.2f', alpha_list(i)));
end
% Set labels
xlabel('Iteration count N', 'FontSize', 14, 'Color', [0.2 0.2 0.2]);
ylabel('Worst-case $\min_{0\leq i\leq n} \|g_1^i - g_2^i\|^2$', ...
'Interpreter', 'latex', 'FontSize', 14, 'Color', [0.2 0.2 0.2]);
% Title
title(sprintf('$L_1 = %.1f,\\ L_2 = %.1f,\\ \\mu_1 = %.1f,\\ \\mu_2 = %.1f$', ...
L1, L2, mu1, mu2), ...
'Interpreter', 'latex', 'FontSize', 16, 'Color', [0.2 0.2 0.2]);
% Move legend below the plot
legend('Location', 'southoutside', ...
'Orientation', 'horizontal', ...
'FontSize', 10, ...
'Box', 'off');
% Adjust layout
set(gca, 'Position', [0.1 0.3 0.85 0.6]); % Leave space at bottom for legend
% Save the figure
print(gcf, 'Figure2.eps', '-depsc');
% Show the plot
hold off;
%% Figure 3
% Execute for different parameters
% Parameters
L1 = 1.0; mu1 = 0.5;
L2 = 2.0; mu2 = 0.25;
lower_alpha = 0.0;
upper_alpha = 1.0;
nb_alphas = 11;
n_list = [9, 10, 11];
alpha_list = linspace(lower_alpha, upper_alpha, nb_alphas);
% Initialize result array (rows: alpha, columns: n)
pepit_taus = zeros(length(alpha_list), length(n_list));
% Compute values
for i = 1:length(alpha_list)
alpha = alpha_list(i);
for j = 1:length(n_list)
n = n_list(j);
pepit_tau = Boosted_DCA(L1, mu1, L2, mu2, alpha, n);
pepit_taus(i, j) = pepit_tau;
end
% Progress indicator
fprintf('i = %d / %d done\n', i, length(alpha_list));
end
% Create figure
figure;
hold on;
% Plot each curve for a given n
for j = 1:length(n_list)
plot(alpha_list, pepit_taus(:, j), '.--', 'LineWidth', 2, ...
'DisplayName', sprintf('N = %d', n_list(j)));
end
% Set axis labels
xlabel('$\alpha$', 'Interpreter', 'latex', 'FontSize', 18, 'Color', [0.2 0.2 0.2]);
ylabel('Worst-case $\min_{0\leq i\leq n} \|g_1^i - g_2^i\|^2$', ...
'Interpreter', 'latex', 'FontSize', 18, 'Color', [0.2 0.2 0.2]);
% Title
title(sprintf('$L_1 = %.1f,\\ L_2 = %.1f,\\ \\mu_1 = %.2f,\\ \\mu_2 = %.2f$', ...
L1, L2, mu1, mu2), ...
'Interpreter', 'latex', 'FontSize', 16, 'Color', [0.2 0.2 0.2]);
% Legend below the plot
legend('Location', 'southoutside', ...
'Orientation', 'horizontal', ...
'FontSize', 10, ...
'Box', 'off');
% Adjust layout
set(gca, 'Position', [0.1 0.35 0.85 0.55]); % More space at bottom
% Save the figure
print(gcf, 'Figure3.eps', '-depsc');
% Show the plot
hold off;