-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_all_paper_circuits.m
78 lines (65 loc) · 2.49 KB
/
run_all_paper_circuits.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
% Test matrix definition - test cases
% See create_test_suite_basic.
testcases = dir(fullfile('test_suites', 'basic', '*.mat'));
testcases = testcases(4:end);
tc_count = length(testcases);
% Test matrix definition - reduction params
testMatrix_costFuncs_empty = {[]};
testMatrix_costFuncs = {@count_resistors, @cost_nnz_size};
testMatrix_nesDisOpts = {[5 0 1 0], [10 0 1 0], [20 0 1 0], [50 0 1 0], [100 0 1 0], [200 0 1 0]};
testMatrix_emptyNesDisOpts = {[]};
testMatrix = [
allcomb({'camd', 'recursive_amd'}, testMatrix_costFuncs, testMatrix_emptyNesDisOpts);
allcomb({'nesdis_dummy'}, testMatrix_costFuncs_empty, testMatrix_nesDisOpts);
allcomb({'nesdis_camd'}, testMatrix_costFuncs, testMatrix_nesDisOpts);
];
mkdir('results')
for c = testMatrix'
elimScheme = c{1};
costFunc = c{2};
nesdisOpts = c{3};
if isempty(costFunc) costFuncName = ''; else costFuncName = func2str(costFunc); end
if isempty(nesdisOpts) nesDisSuffix = ''; else nesDisSuffix = num2str(nesdisOpts(1)); end
results_group = strjoin({elimScheme costFuncName num2str(nesDisSuffix)}, '-')
result_dir = fullfile('results', results_group);
mkdir(result_dir);
% 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
options
% Dummy throwaway run to allow JIT to do it's magic
disp('Warmup run')
N = 8;
G = gallery('tridiag', N, -1, 2, -1);
G(1,1) = 1;
G(N,N) = 1;
is_ext_node = [1 zeros(1, N-2) 1]';
reducer(G, is_ext_node, options);
% Run actual testcases
for f = testcases'
fname = fullfile('test_suites', 'basic', f.name);
[tc_dir, tc_name, ext] = fileparts(f.name);
dst = fullfile(result_dir, [tc_name '.mat']);
if exist(dst, '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{:});
dst = fullfile(result_dir, [tc_name '.mat']);
save(dst, 'input_circuit_info', 'output', 'output_circuit_info', 'G', 'is_ext_node');
end
end