forked from nmslib/nmslib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRunAllProjSmall.pl
executable file
·226 lines (197 loc) · 7.96 KB
/
RunAllProjSmall.pl
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
214
215
216
217
218
219
220
221
222
223
224
225
226
#!/usr/bin/perl -w
require "./RunCommon.pm";
my $DataDir=$ENV{"DATA_DIR"};
defined($DataDir) or die("Define the environemnt variable DATA_DIR, which contains data files.");
my $CacheDir=$ENV{"CACHE_DIR"};
defined($CacheDir) or die("Define the environemnt variable CACHE_DIR, which contains gold standard cache files.");
-d $DataDir or die("DATA_DIR='$DataDir' is not a directory");
my $BinDir=$ENV{"BIN_DIR"};
defined($BinDir) or die("Define the environemnt variable BIN_DIR, which contains binary files.");
-d $BinDir or die("BIN_DIR='$BinDir' is not a directory");
-f "$BinDir/experiment" or die("Missing file '$BinDir/experiment'");
my @ProjType = (
["rand", "perm", "randrefpt", "fastmap"],
["rand", "perm", "randrefpt", "fastmap"],
["rand", "perm"],
["rand", "perm", "randrefpt", "fastmap"],
["perm"],
["perm"],
["perm"],
["perm"],
);
my @IntermDim = (0, 0, 4096, 0, 0, 0, 0, 0);
my @UseCosine = (0, 0, 1, 0, 0, 0, 0, 0);
my @ProjDim = (
[8, 16, 32, 64, 128, 256, 512, 1024],
[8, 16, 32, 64, 128, 256, 512, 1024],
[4, 16, 64, 128, 256, 512, 1024],
[4, 16, 64, 128, 256, 512, 1024],
[4, 16, 64, 128, 256, 512, 1024],
[4, 16, 64, 128, 256, 512, 1024],
[4, 16, 64, 128, 256, 512, 1024],
[4, 16, 64, 128, 256, 512, 1024],
);
my @knnAmp = (
[10, 40, 60, 100, 400, 600, 1000, 4000],
[10, 40, 60, 100, 400, 600, 1000, 4000],
[10, 40, 60, 100, 400, 600, 1000, 4000],
[10, 40, 60, 100, 400, 600, 1000, 4000],
[10, 40, 60, 100, 400, 600, 1000, 4000],
[10, 40, 60, 100, 400, 600, 1000, 4000],
[10, 40, 60, 100, 400, 600, 1000, 4000],
[10, 40, 60, 100, 400, 600, 1000, 4000],
);
my @SpaceType = ("l2",
"l2",
"cosinesimil_sparse_fast",
"kldivgenfast",
"normleven",
"sqfd_heuristic_func:alpha=1",
"kldivgenfast",
"jsdivfast",
);
my @DataSetName = ("cophir",
"sift",
"wikipedia",
"wikipedia_lda128",
"dna32_4",
"sqfd20_10k",
"wikipedia_lda8",
"wikipedia_lda128"
);
my @DataSetFile = ("cophir/full.txt",
"sift_texmex_learn5m.txt",
"wikipedia.txt",
"wikipedia_lda128.txt",
"StringSpaces/dna5M_32_4.txt",
"SQFD/in_20_10k.txt",
"wikipedia_lda8.txt",
"wikipedia_lda128.txt"
);
my @CachePrefix = ("cophir1M",
"sift1M",
"cosinesimil_sparse_1M",
"wikipedia_lda1M_128_kldiv",
"dna1M_normleven_32_4",
"sqfd_20_10k_heuristic_func_alpha=1_1M",
"wikipedia_lda1M_8_kldiv",
"wikipedia_lda1M_128_jsdiv",
);
my @MaxNumData = (1000000,
1000000,
1000000,
1000000,
1000000,
1000000,
1000000,
1000000
);
my @MaxNumQuery = (200,
200,
200,
200,
200,
200,
200,
200);
my @TestSetQty = (1,
1,
1,
1,
1,
1,
1,
1);
my @Use = (0,
0,
0,
0,
0,
0,
0,
1);
my $DataSetQty = scalar(@DataSetName);
scalar(@ProjType) == $DataSetQty or die("ProjType has wrong number of elems");
scalar(@IntermDim) == $DataSetQty or die("IntermDim has wrong number of elems");
scalar(@UseCosine) == $DataSetQty or die("UseCosine has wrong number of elems");
scalar(@ProjDim) == $DataSetQty or die("ProjDim has wrong number of elems");
scalar(@knnAmp) == $DataSetQty or die("knnAmp has wrong number of elems");
scalar(@SpaceType) == $DataSetQty or die("SpaceType has wrong number of elems");
scalar(@DataSetFile) == $DataSetQty or die("DataSetFile has wrong number of elems");
scalar(@DataSetName) == $DataSetQty or die("DataSetName has wrong number of elems");
scalar(@MaxNumData) == $DataSetQty or die("MaxNumData has wrong number of elems");
scalar(@MaxNumQuery) == $DataSetQty or die("MaxNumQuery has wrong number of elems");
scalar(@CachePrefix) == $DataSetQty or die("CachePrefix has wrong number of elems");
scalar(@Use) == $DataSetQty or die("Use has wrong number of elems");
scalar(@TestSetQty) == $DataSetQty or die("TestSetQty has wrong number of elems");
print "# of data sets $DataSetQty\n";
#RunTest(1);
RunTest(10);
sub RunTest {
my ($K) = @_;
for (my $dn = 0; $dn < $DataSetQty; ++$dn) {
my $Name = $DataSetName[$dn];
my $DataQty = $MaxNumData[$dn];
my $space = $SpaceType[$dn];
if (!$Use[$dn]) {
print "Skipping $Name K=$K (qty=$DataQty)\n";
next;
}
my $OutFileDir="ResultsProjData/${Name}_$space";
!system("mkdir -p $OutFileDir") or die("Cannot create $OutFileDir");
my $OutFilePrefix="$OutFileDir/res";
for my $pt (@{$ProjType[$dn]}) {
for my $pd (@{$ProjDim[$dn]}) {
my $uc = $UseCosine[$dn] && $pt eq "rand" ? 1 :0;
RunProjIncSortVer0($BinDir, $DataDir, $CacheDir,
$space,
$DataSetFile[$dn],
$DataQty,
$TestSetQty[$dn],
$MaxNumQuery[$dn],
$CachePrefix[$dn],
$K, $OutFilePrefix,
$pt,
$IntermDim[$dn],
$uc,
$pd, $knnAmp[$dn]
);
}
}
}
}
sub RunProjIncSortVer0 {
my ($BinDir, $DataDir, $CacheDir,
$SpaceTypeLoc,
$DataNameLoc,
$MaxNumDataLoc, $TestSetQtyLoc, $MaxNumQueryLoc,
$CachePrefixLoc,
$KLoc,
$OutFilePrefixLoc,
$projTypeLoc,
$intermDimLoc, # Can be zero for everything than coseine/sparse random projections
$useCosine,
$projDimLoc,$knnAmpLoc) = @_;
defined($BinDir) or die("undefined BinDir");
defined($DataDir) or die("undefined DataDir");
defined($CacheDir) or die("undefined CacheDir");
defined($SpaceTypeLoc) or die("undefined SpaceTypeLoc");
defined($projTypeLoc) or die("projTypeLoc undefined!");
defined($knnAmpLoc) or die("knnAmpLoc undefined!");
defined($projDimLoc) or die("projDimLoc undefined!");
defined($useCosine) or die("useCosine undefined!");
defined($intermDimLoc) or die("intermDimLoc undefined!");
my @MethArray = ();
for my $knnAmp (@$knnAmpLoc) {
push(@MethArray, " --method proj_incsort:projType=$projTypeLoc,intermDim=$intermDimLoc,projDim=$projDimLoc,knnAmp=$knnAmp,useCosine=$useCosine");
}
# We should run them all at once, so that we create only index!
RunCmd($BinDir, $DataDir, $CacheDir,
$SpaceTypeLoc,
$DataNameLoc, $MaxNumDataLoc, $TestSetQtyLoc,
$MaxNumQueryLoc,
$CachePrefixLoc,
$KLoc,
$OutFilePrefixLoc,
\@MethArray);
}