forked from GuanyuCui/BiSPER
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_experiment.py
More file actions
164 lines (161 loc) · 7.59 KB
/
run_experiment.py
File metadata and controls
164 lines (161 loc) · 7.59 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
import itertools
import subprocess
from argparse import ArgumentParser
if __name__ == '__main__':
parser = ArgumentParser()
parser.add_argument('--experiment', type = str, default = '0', help = 'Experiment number. (default = 0)')
parser.add_argument('--dataset', type = str, default = 'Facebook', help = 'Dataset. (default = Facebook)')
parser.add_argument('--algorithm', type = str, default = 'Power-Iteration', help = 'Algorithm name. (default = Power-Iteration)')
parser.add_argument('--num_query', type = str, default = '100', help = 'Number of query pairs. (default = 100)')
parser.add_argument('--L_max', type = str, default = '100', help = 'L_max. (default = 100)')
args = parser.parse_args()
experiment = args.experiment
dataset = args.dataset
algorithm = args.algorithm
num_query = args.num_query
L_max = args.L_max
program_path = './SPER'
if experiment == '0':
assert dataset == 'Facebook' and algorithm == 'Power-Iteration' and num_query == '1'
command = [program_path, '--dataset', 'Facebook', '--algorithm', 'Power-Iteration', '--num_query', '1', '--L_max', L_max, '--eps', '0.0']
try:
subprocess.run(command, check = True)
except subprocess.CalledProcessError as e:
print(f"Error calling C++ program: {e}")
elif experiment == 'I':
if algorithm == 'AMC':
epsilons = ['1e-1', '2e-1', '5e-1']
elif algorithm == 'GEER' and dataset == 'Friendster':
epsilons = ['1e-2', '2e-2', '5e-2', '1e-1', '2e-1', '5e-1']
else:
epsilons = ['1e-3', '2e-3', '5e-3', '1e-2', '2e-2', '5e-2', '1e-1']
for eps in epsilons:
command = [program_path, '--dataset', dataset, '--algorithm', algorithm, '--num_query', num_query, '--L_max', L_max, '--eps', eps]
try:
subprocess.run(command, check = True)
except subprocess.CalledProcessError as e:
print(f"Error calling C++ program: {e}")
elif experiment == 'II':
assert dataset in ['Facebook']
if algorithm == 'Bipush':
num_sampless = ['1000', '10000', '100000']
r_maxs = ['1e-6', '1e-5', '1e-4']
for r_max, num_samples in itertools.product(r_maxs, num_sampless):
command = [program_path, '--dataset', dataset, '--algorithm', algorithm, '--num_query', num_query, '--num_samples', num_samples, '--r_max', r_max]
try:
subprocess.run(command, check = True)
except subprocess.CalledProcessError as e:
print(f"Error calling C++ program: {e}")
elif algorithm == 'Push':
r_maxs = ['1e-10', '1e-9', '1e-8', '1e-7', '1e-6', '1e-5', '1e-4']
for r_max in r_maxs:
command = [program_path, '--dataset', dataset, '--algorithm', algorithm, '--num_query', num_query, '--r_max', r_max]
try:
subprocess.run(command, check = True)
except subprocess.CalledProcessError as e:
print(f"Error calling C++ program: {e}")
elif algorithm == 'AbWalk':
num_sampless = ['100000', '500000', '1000000']
for num_samples in num_sampless:
command = [program_path, '--dataset', dataset, '--algorithm', algorithm, '--num_query', num_query, '--num_samples', num_samples]
try:
subprocess.run(command, check = True)
except subprocess.CalledProcessError as e:
print(f"Error calling C++ program: {e}")
elif algorithm == 'Bipush-vl':
num_sampless = ['1000']
r_maxs = ['1e-7', '2e-7', '3e-7']
for r_max, num_samples in itertools.product(r_maxs, num_sampless):
command = [program_path, '--dataset', dataset, '--algorithm', algorithm, '--num_query', num_query, '--num_samples', num_samples, '--r_max', r_max]
try:
subprocess.run(command, check = True)
except subprocess.CalledProcessError as e:
print(f"Error calling C++ program: {e}")
elif algorithm == 'Push-vl':
r_maxs = ['1e-7', '2e-7', '3e-7']
for r_max in r_maxs:
command = [program_path, '--dataset', dataset, '--algorithm', algorithm, '--num_query', num_query, '--r_max', r_max]
try:
subprocess.run(command, check = True)
except subprocess.CalledProcessError as e:
print(f"Error calling C++ program: {e}")
elif algorithm == 'RW-vl':
num_sampless = ['1000000', '5000000', '10000000']
for num_samples in num_sampless:
command = [program_path, '--dataset', dataset, '--algorithm', algorithm, '--num_query', num_query, '--num_samples', num_samples]
try:
subprocess.run(command, check = True)
except subprocess.CalledProcessError as e:
print(f"Error calling C++ program: {e}")
else:
if algorithm == "GEER":
epsilons = ['1e-3', '1e-2', '1e-1']
else:
epsilons = ['1e-7', '1e-6', '1e-5', '1e-4', '1e-3', '1e-2', '1e-1']
for eps in epsilons:
command = [program_path, '--dataset', dataset, '--algorithm', algorithm, '--num_query', num_query, '--L_max', 'auto', '--eps', eps]
try:
subprocess.run(command, check = True)
except subprocess.CalledProcessError as e:
print(f"Error calling C++ program: {e}")
elif experiment == 'III':
assert dataset == 'synthetic'
dataset = 'synthetic'
if algorithm == 'Bipush':
num_sampless = ['1000', '10000']
r_maxs = ['1e-6', '1e-5', '1e-4']
for r_max, num_samples in itertools.product(r_maxs, num_sampless):
command = [program_path, '--dataset', dataset, '--algorithm', algorithm, '--num_query', num_query, '--num_samples', num_samples, '--r_max', r_max]
try:
subprocess.run(command, check = True)
except subprocess.CalledProcessError as e:
print(f"Error calling C++ program: {e}")
elif algorithm == 'Push':
r_maxs = ['1e-7', '1e-6', '1e-5', '1e-4', '1e-3', '1e-2', '1e-1']
for r_max in r_maxs:
command = [program_path, '--dataset', dataset, '--algorithm', algorithm, '--num_query', num_query, '--num_samples', '0', '--r_max', r_max]
try:
subprocess.run(command, check = True)
except subprocess.CalledProcessError as e:
print(f"Error calling C++ program: {e}")
elif algorithm == 'AbWalk':
num_sampless = ['1000', '5000', '10000']
for num_samples in num_sampless:
command = [program_path, '--dataset', dataset, '--algorithm', algorithm, '--num_query', num_query, '--num_samples', num_samples]
try:
subprocess.run(command, check = True)
except subprocess.CalledProcessError as e:
print(f"Error calling C++ program: {e}")
elif algorithm == 'Bipush-vl':
num_sampless = ['1000']
r_maxs = ['1e-7', '2e-7', '3e-7']
for r_max, num_samples in itertools.product(r_maxs, num_sampless):
command = [program_path, '--dataset', dataset, '--algorithm', algorithm, '--num_query', num_query, '--num_samples', num_samples, '--r_max', r_max]
try:
subprocess.run(command, check = True)
except subprocess.CalledProcessError as e:
print(f"Error calling C++ program: {e}")
elif algorithm == 'Push-vl':
r_maxs = ['1e-7', '2e-7', '3e-7']
for r_max in r_maxs:
command = [program_path, '--dataset', dataset, '--algorithm', algorithm, '--num_query', num_query, '--r_max', r_max]
try:
subprocess.run(command, check = True)
except subprocess.CalledProcessError as e:
print(f"Error calling C++ program: {e}")
elif algorithm == 'RW-vl':
num_sampless = ['10000', '50000', '100000']
for num_samples in num_sampless:
command = [program_path, '--dataset', dataset, '--algorithm', algorithm, '--num_query', num_query, '--num_samples', num_samples]
try:
subprocess.run(command, check = True)
except subprocess.CalledProcessError as e:
print(f"Error calling C++ program: {e}")
else:
epsilons = ['1e-7', '1e-6', '1e-5', '1e-4', '1e-3', '1e-2', '1e-1']
for eps in epsilons:
command = [program_path, '--dataset', dataset, '--algorithm', algorithm, '--num_query', num_query, '--L_max', 'auto', '--eps', eps]
try:
subprocess.run(command, check = True)
except subprocess.CalledProcessError as e:
print(f"Error calling C++ program: {e}")