-
Notifications
You must be signed in to change notification settings - Fork 1
/
plotMetricsVsId.m
213 lines (200 loc) · 7.18 KB
/
plotMetricsVsId.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
% Script for plotting landscape metrics against the BBOB function ID
%
% Copyright (C) 2015 Rachael Morgan ([email protected])
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
addpath(genpath('../COMMON'));
clear all;
clc;
dim = [2, 5, 10, 20];
colors = {'b', 'r', 'g', 'k'};
legendLabels = {'2D', '5D', '10D', '20D'};
axisFontSize = 18;
labelFontSize = 14;
legendFontSize = 14;
seeds = 1:30;
walks = 1:30;
bbob = 1:24;
dirName = 'data/';
dirNameSuffix = 'D/metrics/metrics.mat';
dirNameSave = 'figures/';
% Autocorrelation
f1 = figure;
hold on;
xlabel('Distance');
ylabel('Autocorrelation Function');
f2 = figure;
set(gca, 'FontSize', axisFontSize);
hold on;
xlabel('Problem ID', 'FontSize', labelFontSize);
ylabel('Correlation Length', 'FontSize', labelFontSize);
corrLengthM = zeros(length(dim), length(bbob));
corrLengthS = zeros(length(dim), length(bbob));
for i=1:length(dim)
load([dirName, num2str(dim(i)), dirNameSuffix], 'autoCorrelation', 'timeSteps', 'nBins');
autoCorrelation(isnan(autoCorrelation)) = 0;
a = reshape(autoCorrelation(seeds, walks, bbob, :), length(seeds) * length(walks), length(bbob), nBins);
figure(f1);
ind = a~=0;
corrLength = sum(a, 3) ./ sum(ind, 3);
corrLength = corrLength(~isnan(corrLength(:, 1)), :);
corrLengthM(i, :) = mean(corrLength, 1);
corrLengthS(i, :) = std(corrLength,[], 1);
figure(f2);
errorbar(bbob, corrLengthM, corrLengthS, colors{i});
t = reshape(timeSteps, length(seeds) * length(walks), length(bbob), nBins);
plot(t, a, colors{i});
end
axis([0 25 -1 1]);
leg = legend(legendLabels{1:length(dim)});
set(leg, 'FontSize', legendFontSize);
% print(f2, [dirNameSave, 'compare_corr_length.eps'], '-depsc');
% saveas(f2, [dirNameSave, 'compare_corr_length.fig']);
clear 'autoCorrelation' 'timeSteps' 'nBins';
% Dispersion
f1 = figure;
set(gca, 'FontSize', axisFontSize);
hold on;
xlabel('Problem ID', 'FontSize', labelFontSize);
ylabel('Dispersion', 'FontSize', labelFontSize);
for i=1:length(dim)
load([dirName, num2str(dim(i)), dirNameSuffix], 'disperse');
normalisation = 10*sqrt(dim(i)); % Theoretically: min d = 0, max d = sqrt(10^2*dim)
d = reshape(disperse(seeds, walks, bbob), length(seeds) * length(walks), length(bbob)) / normalisation;
dM = mean(d);
dS = std(d);
range(dM)
errorbar(bbob, dM, dS, colors{i});
end
axis([0 25 0 1]);
leg = legend(legendLabels{1:length(dim)});
set(leg, 'FontSize', legendFontSize);
% print(f1,[dirNameSave, 'compare_dispersion.eps'], '-depsc');
% saveas(f1,[dirNameSave, 'compare_dispersion.fig']);
clear 'disperse';
% FDC
f1 = figure;
set(gca, 'FontSize', axisFontSize);
hold on;
xlabel('Problem ID');
ylabel('FDC');
axis([0 25 -1 1]);
f2 = figure;
set(gca, 'FontSize', axisFontSize);
hold on;
xlabel('Problem ID', 'FontSize', labelFontSize);
ylabel('Estimated FDC', 'FontSize', labelFontSize);
axis([0 25 -1 1]);
for i=1:length(dim)
load([dirName, num2str(dim(i)), dirNameSuffix], 'fdc', 'fdcEst');
fdcTemp = reshape(fdc(seeds,walks,bbob), length(seeds) * length(walks), length(bbob));
fdcM = mean(fdcTemp);
fdcS = std(fdcTemp);
fdcEstTemp = reshape(fdcEst(seeds, walks, bbob), length(seeds) * length(walks), length(bbob));
fdcEstM = mean(fdcEstTemp);
fdcEstS = std(fdcEstTemp);
figure(f1);
errorbar(bbob, fdcM, fdcS, colors{i});
figure(f2);
errorbar(bbob, fdcEstM, fdcEstS, colors{i});
end
figure(f1);
leg = legend(legendLabels{1:length(dim)});
set(leg, 'FontSize', legendFontSize);
print(f1,[dirNameSave, 'compare_fdc.eps'], '-depsc');
saveas(f1,[dirNameSave, 'compare_fdc.fig']);
figure(f2);
leg = legend(legendLabels{1:length(dim)});
set(leg, 'FontSize', legendFontSize);
print(f2,[dirNameSave, 'compare_fdc_est.eps'], '-depsc');
saveas(f2,[dirNameSave, 'compare_fdc_est.fig']);
clear 'fdc' 'fdcEst';
% Information Distance
f1 = figure;
set(gca, 'FontSize', axisFontSize);
hold on;
xlabel('Problem ID', 'FontSize', labelFontSize);
ylabel('Information Content', 'FontSize', labelFontSize);
f2 = figure;
set(gca, 'FontSize', axisFontSize);
hold on;
xlabel('Problem ID', 'FontSize', labelFontSize);
ylabel('Partial Information Content', 'FontSize', labelFontSize);
f3 = figure;
set(gca, 'FontSize', axisFontSize);
hold on;
xlabel('Problem ID', 'FontSize', labelFontSize);
ylabel('Information Stability', 'FontSize', labelFontSize);
for i=1:length(dim)
load([dirName, num2str(dim(i)), dirNameSuffix], 'iContent', 'iContentPartial', 'iContentStability');
ic = reshape(iContent(seeds, walks, bbob), length(seeds) * length(walks), length(bbob));
ip = reshape(iContentPartial(seeds, walks, bbob), length(seeds) * length(walks), length(bbob));
is = reshape(iContentStability(seeds, walks, bbob), length(seeds) * length(walks), length(bbob));
icM = mean(ic);
isM = mean(is);
ipM = mean(ip);
icS = std(ic);
ipS = std(ip);
isS = std(is);
figure(f1);
errorbar(bbob, icM, icS, colors{i});
figure(f2);
errorbar(bbob, ipM, ipS, colors{i});
figure(f3);
errorbar(bbob, isM, isS, colors{i});
end
figure(f1);
leg = legend(legendLabels{1:length(dim)});
axis([0 25 0 1]);
set(leg, 'FontSize', legendFontSize);
print(f1,[dirNameSave, 'compare_info_content.eps'], '-depsc');
saveas(f1,[dirNameSave, 'compare_info_content.fig']);
figure(f2);
leg = legend(legendLabels{1:length(dim)});
set(leg, 'FontSize', legendFontSize);
axis([0 25 0 1]);
print(f2,[dirNameSave, 'compare_info_content_partial.eps'], '-depsc');
saveas(f2,[dirNameSave, 'compare_info_content_partial.fig']);
figure(f3);
% axes('YScale', 'log');
leg = legend(legendLabels{1:length(dim)});
set(leg, 'FontSize', legendFontSize);
print(f3,[dirNameSave, 'compare_info_content_stability.eps'], '-depsc');
saveas(f3,[dirNameSave, 'compare_info_content_stability.fig']);
clear 'iContent' 'iContentPartial' 'iContentStability';
% Import the BBOB performance
precision = 1e-8;
data = importdata('H:\PhD\Python\BBOB ERT Calculator\ert.csv', ', ');
ert = data.data;
clear data;
% Length Scale
f1 = figure;
set(gca, 'FontSize', axisFontSize);
hold on;
for i=1:length(dim)
ind = (ert(:,2) == dim(i)) & (ert(:,4) == precision) & (~isinf(ert(:,5)));
ert = ert(ind, :);
load([dirName, num2str(dim(i)), dirNameSuffix], 'rMedian');
rH = reshape(rMedian(seeds, walks, bbob), length(seeds) * length(walks), length(bbob));
rHM = mean(rH);
rHS = std(rH);
errorbar(rHM, rHS, colors{i});
end
xlabel('Problem ID', 'FontSize', labelFontSize);
ylabel('$median(r)$', 'FontSize', labelFontSize);
leg = legend(legendLabels{1:length(dim)});
set(leg, 'FontSize', legendFontSize);
% print(f1,[dirNameSave, 'compare_length_scale.eps'], '-depsc');
% saveas(f1,[dirNameSave, 'compare_length_scale.fig']);
clear 'rEntropy';