-
Notifications
You must be signed in to change notification settings - Fork 0
/
thesis_ex3_nesdisred_reduction_time.m
124 lines (100 loc) · 4.07 KB
/
thesis_ex3_nesdisred_reduction_time.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
% Experiment 2: nesdisres algorithm vs others
testcases = dir(fullfile('test_suites', 'big', '*.mat'));
testcases = testcases(1:end-1);
tc_count = length(testcases);
RESULTS_DIR = fullfile('results', 'ex3_nesdisred_reduction_time');
mkdir(RESULTS_DIR);
EXPORTS_DIR = fullfile('exports', 'ex3_nesdisred_reduction_time');
mkdir(EXPORTS_DIR);
% Test matrix definition - reduction params
testMatrix_costFuncs = {@cost_res2_nodes};
testMatrix_costFuncs_empty = {[]};
testMatrix_nesDisOpts = {[1000 0 1 0]};
testMatrix_nesDisDummyOpts = {[5 0 1 0]};
testMatrix_emptyNesDisOpts = {[]};
testMatrix = [
allcomb({'nesdis_camd'}, testMatrix_costFuncs, testMatrix_nesDisOpts);
allcomb({'nesdis_dummy'}, testMatrix_costFuncs_empty, testMatrix_nesDisDummyOpts);
allcomb({'camd'}, testMatrix_costFuncs, testMatrix_emptyNesDisOpts);
];
for c = testMatrix'
elimScheme = c{1};
costFunc = c{2};
nesdisOpts = c{3};
results_group = elimScheme;
% build struct
options = struct;
options.verbose = 0;
options.nodewise_algorithm = elimScheme;
options.graph_algorithm = 'standard';
if ~isempty(costFunc)
options.cost_function = costFunc;
end
if ~isempty(costFunc)
options.nesdis_opts = nesdisOpts;
end
reducer_warmup(options);
% Run testcases
for f = testcases'
fname = fullfile('test_suites', 'big', f.name);
[tc_dir, tc_name, ext] = fileparts(f.name);
output_filename = @(suffix) fullfile(RESULTS_DIR, [tc_name suffix]);
if exist(output_filename([results_group '.mat']), 'file') == 2
continue
end
tc_name
load(fname);
input_circuit_info = circuit_info(G, is_ext_node);
tic
output = reducer(G, is_ext_node, options);
output.total_time = toc;
i = input_for_circuit_composite_info(output);
output_circuit_info = circuit_composite_info(i{:});
save(output_filename([results_group '.mat']), 'input_circuit_info', 'output', 'output_circuit_info', 'G', 'is_ext_node');
end
end
selectMatrix = [
allcomb({'nesdis_camd'}, testMatrix_costFuncs, testMatrix_nesDisOpts);
allcomb({'nesdis_dummy'}, testMatrix_costFuncs_empty, testMatrix_nesDisDummyOpts);
allcomb({'camd'}, testMatrix_costFuncs, testMatrix_emptyNesDisOpts);
];
group_count = size(selectMatrix, 1);
num_nodes_orig = nan(tc_count, 1);
num_nodes_red = nan(tc_count, group_count);
num_term_orig = nan(tc_count, 1);
num_term_red = nan(tc_count, group_count);
num_res_orig = nan(tc_count, 1);
num_res_red = nan(tc_count, group_count);
red_total_time = nan(tc_count, group_count);
tc_num = 0;
for f = testcases'
[tc_dir, tc_name, ext] = fileparts(f.name);
tc_name
output_filename = @(suffix) fullfile(RESULTS_DIR, [tc_name suffix]);
tc_num = tc_num+1;
group_num = 0;
for c=selectMatrix'
group_num = group_num+1;
elimScheme = c{1};
costFunc = c{2};
nesdisOpts = c{3};
results_group = elimScheme;
try
load(output_filename([results_group '.mat']), 'input_circuit_info', 'output', 'output_circuit_info', 'G', 'is_ext_node');
catch error
continue
end
num_nodes_orig(tc_num, 1) = input_circuit_info.num_nodes;
num_nodes_red(tc_num, group_num) = output_circuit_info.num_nodes;
num_term_orig(tc_num, 1) = input_circuit_info.num_external;
num_term_red(tc_num, group_num) = output_circuit_info.num_external;
num_res_orig(tc_num, 1) = input_circuit_info.num_resistors;
num_res_red(tc_num, group_num) = output_circuit_info.num_resistors;
red_total_time(tc_num, group_num) = output.total_time;
end
end
reduction_speedup = 100 * (red_total_time(:, 2) ./ red_total_time(:, 1) - 1);
T = table(num_nodes_orig,num_term_orig,num_res_orig,...
num_nodes_red,num_res_red, red_total_time, reduction_speedup, ...
'RowNames', arrayfun(@(s) s.name, testcases, 'UniformOutput', false))
writetable(T, fullfile(EXPORTS_DIR, 'nesdisred_speedup.csv'))