-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhuge_benchmark.m
108 lines (76 loc) · 2.98 KB
/
huge_benchmark.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
%% Get an empty TestManager with the benchmark gardens
% tm = lhp.benchmark.prepare_tm();
% fprintf("Gardens generated\n");
%% alternatively use a given TestManager
% Datei = "tm_id31"
% load (Datei)
%% Limiting the algorithms to be considered by using a new algorithm.txt
algfilepath = mfilename("fullpath")
algfile== [algfilepath filesep '+deterministic' filesep 'algorithms.txt'];
newfile== [algfilepath filesep '+deterministic' filesep 'algorithmsneu.txt'];
allfile== [algfilepath filesep '+deterministic' filesep 'algorithmsall.txt'];
copyfile(newfile, algfile);
%% Add the algorithms to the TestManager
ren_range = [false, true];
po_range = ["None", "MaxLaub", "MinLaub", "Median", "MinKompost", "SmallestIndex", "KeepHubs"];
oml_range = [false]; %% Zweiter Durchlauf hier auf true setzen
[a, b, c] = meshgrid(ren_range, po_range, oml_range);
fact_mat = reshape(cat(4, a, b, c), [], 3)';
for col = fact_mat
str2bool = @(str) strcmp(str, "true");
ren = str2bool(col(1));
po = col(2);
oml = str2bool(col(3));
suffix = sprintf("-OML_%d-REN_%d-PO_%s", oml, ren, po);
% Convert PO to proper format
if strcmp(po, "None")
po = [];
end
det = lhp.algo.DeterministicWrapper.gather(...
"StoreResults", false, ...
"RemoveEmptyNodes", ren, ...
"PostOptimize", po, ...
"OptimizeMaxLaub", oml, ...
"NameSuffix", suffix);
for idx = 1:numel(det)
tm.addAlgorithm(det(idx));
end
end
%% Run the deterministic tests
tm.runAllTests();
tm.flatten();
save("huge-benchmark-det.mat", "-v7.3", "tm");
fprintf("Deterministic results stored!\n");
%% Switch to all algorithms
algfilepath = mfilename("fullpath")
algfile== [algfilepath filesep '+deterministic' filesep 'algorithms.txt'];
newfile== [algfilepath filesep '+deterministic' filesep 'algorithmsneu.txt'];
allfile== [algfilepath filesep '+deterministic' filesep 'algorithmsall.txt'];
copyfile(allfile, algfile);
%% Add bionic algorithms, rerun
%% Bee-Algorithm
bee = lhp.algo.stochastic.bee.wrapper("StoreRNG", true, "StorePopulations", false);
tm.addAlgorithm(bee);
tm.unflatten();
ret = tm.runAllTests();
tm.flatten();
save("huge-benchmark-bee.mat", "-v7.3", "tm");
fprintf("Bee results stored!\n");
%% Add bionic algorithms, rerun
%% genetic algorithm
gen = lhp.algo.stochastic.genetic.wrapper("StoreRNG", true, "StorePopulations", false);
tm.addAlgorithm(gen);
tm.unflatten();
ret = tm.runAllTests();
tm.flatten();
save("huge-benchmark-gen.mat", "-v7.3", "tm");
fprintf("Genetic results stored!\n");
%% Add heuristic approximation method, rerun
%% Simulated Annealing
siman = lhp.algo.stochastic.siman.wrapper("StoreRNG", true, "StorePopulations", false);
tm.addAlgorithm(siman);
tm.unflatten();
ret = tm.runAllTests();
tm.flatten();
save("huge-benchmark-siman.mat", "-v7.3", "tm");
fprintf("Simulated Annealing results stored!\n");