-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestII.py
81 lines (62 loc) · 1.92 KB
/
testII.py
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
import InvertedIndexCreator
import math
tcl = math.floor(131072 / 36)
#print(tcl)
lamb = 400
II = InvertedIndexCreator.InvertedIndexCreator(35484770, tcl, 30, 30, lamb)
qc, ii = II.create_index()
## lambda section
# pct diff between largest (approx. C-1) and avg size (target; EMMA paper; LARGE)
pct_diff = 1000000 / 2486
# sorted by size
lc = sorted(qc, reverse=True)
# diff between largest (approx. C-1) and avg size (target)
actual_diff = lc[0] / II.pro_region
adjust_rate = 0.5
#while percentual difference is more than 2% (either plus/minus)
while (abs(actual_diff - pct_diff) > 2):
if actual_diff - pct_diff < 0:
lamb += adjust_rate
else:
lamb -= adjust_rate
print(lamb)
II = InvertedIndexCreator.InvertedIndexCreator(35484770, tcl, 30, 30, lamb)
qc, ii = II.create_index()
# sorted by size
lc = sorted(qc, reverse=True)
print(lc[0])
# pct diff between largest and avg size (target)
actual_diff = lc[0] / II.pro_region
print("1st veri")
print(lc[0])
print(lamb)
# advocates 434.5 lambda
# pct diff between 2nd largest (approx. C-2) and avg size (target; EMMA paper; LARGE)
pct_diff = 900000 / 2486
#2nd lambda adjustment (approx. C-2)
while (abs(actual_diff - pct_diff) > 2):
if actual_diff - pct_diff < 0:
lamb += adjust_rate
else:
lamb -= adjust_rate
print(lamb)
II = InvertedIndexCreator.InvertedIndexCreator(35484770, tcl, 30, 30, lamb)
qc, ii = II.create_index()
# sorted by size
lc = sorted(qc, reverse=True)
print(lc[1])
# pct diff between 2th largest and avg size (target)
actual_diff = lc[1] / II.pro_region
print(lamb)
# advocates 460.0 lambda
## verification section
# print(len(qc))
# print(len(ii))
# print("---")
# print(qc[int((len(qc)/2))])
# print(sum(ii[0]))
# n = 0
# for i in ii:
# for j in i:
# n += j
# print(n)