-
Notifications
You must be signed in to change notification settings - Fork 1
/
texconstsf.py
129 lines (107 loc) · 5.45 KB
/
texconstsf.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
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
# -*- coding: utf-8 -*-
"""
Constants to be dumped into the LaTeX file.
"""
import os
import csv
from mpmath import mp
from probabilities import C
from cost import list_decoding, log2, load_probabilities
def p(name, val):
if type(val) is int:
print("/consts/{:s}/.initial={:d},".format(name, val))
elif type(val) is str:
print("/consts/{:s}/.initial={:s},".format(name, val))
else:
print("/consts/{:s}/.initial={:.1f},".format(name, val))
def load_csv(f, metric):
filename = os.path.join("data", "cost-estimate-{f}-{metric}.csv")
filename = filename.format(f=f, metric=metric)
with open(filename, "r") as csvfile:
csvreader = csv.DictReader(csvfile, delimiter=",", quotechar='"',
quoting=csv.QUOTE_MINIMAL)
D = {int(L['d']) : L for L in csvreader}
return D
def main():
data_bgj1_g = load_csv("random_buckets", "g")
data_bgj1_dw = load_csv("random_buckets", "dw")
data_bgj1_ge19 = load_csv("random_buckets", "ge19")
data_bgj1_classical= load_csv("random_buckets", "classical")
data_bdgl_g = load_csv("list_decoding", "g")
data_bdgl_dw = load_csv("list_decoding", "dw")
data_bdgl_ge19 = load_csv("list_decoding", "ge19")
data_bdgl_classical = load_csv("list_decoding", "classical")
data_size_bits = load_csv("sieve_size", "bits")
#p("classical784", float(list_decoding(784, metric="classical").log_cost))
#p("classical1024", float(list_decoding(1024, metric="classical").log_cost))
for d in sorted(data_bgj1_g):
if float(data_bgj1_classical[d]['log_cost']) - float(data_bgj1_g[d]['log_cost']) > 0:
p("bgj1/g/crossover", d)
p("bgj1/g/crossover/cost", float(data_bgj1_g[d]['log_cost']))
p("bgj1/g/crossover/size", float(data_size_bits[d]['log2_size']))
break
for d in sorted(data_bgj1_dw):
if float(data_bgj1_classical[d]['log_cost']) - float(data_bgj1_dw[d]['log_cost']) > 0:
p("bgj1/dw/crossover", d)
p("bgj1/dw/crossover/cost", float(data_bgj1_dw[d]['log_cost']))
p("bgj1/dw/crossover/size", float(data_size_bits[d]['log2_size']))
break
for d in sorted(data_bgj1_ge19):
if float(data_bgj1_classical[d]['log_cost']) - float(data_bgj1_ge19[d]['log_cost']) > 0:
p("bgj1/ge19/crossover", d)
p("bgj1/ge19/crossover/cost", float(data_bgj1_ge19[d]['log_cost']))
p("bgj1/ge19/crossover/size", float(data_size_bits[d]['log2_size']))
break
for d in sorted(data_bdgl_g):
if float(data_bdgl_classical[d]['log_cost']) - float(data_bdgl_g[d]['log_cost']) > 0:
p("bdgl/g/crossover", d)
p("bdgl/g/crossover/cost", float(data_bdgl_g[d]['log_cost']))
p("bdgl/g/crossover/size", float(data_size_bits[d]['log2_size']))
break
for d in sorted(data_bdgl_dw):
if float(data_bdgl_classical[d]['log_cost']) - float(data_bdgl_dw[d]['log_cost']) > 0:
p("bdgl/dw/crossover", d)
p("bdgl/dw/crossover/cost", float(data_bdgl_dw[d]['log_cost']))
p("bdgl/dw/crossover/size", float(data_size_bits[d]['log2_size']))
break
for d in sorted(data_bdgl_ge19):
if float(data_bdgl_classical[d]['log_cost']) - float(data_bdgl_ge19[d]['log_cost']) > 0:
p("bdgl/ge19/crossover", d)
p("bdgl/ge19/crossover/cost", float(data_bdgl_ge19[d]['log_cost']))
p("bdgl/ge19/crossover/size", float(data_size_bits[d]['log2_size']))
break
for d in sorted(data_bdgl_ge19):
if float(data_bdgl_ge19[d]['log_cost']) > 128:
p("bdgl/ge19/dim/cost128", d)
p("bdgl/ge19/adv/cost128", float(data_bdgl_classical[d]['log_cost']) - float(data_bdgl_ge19[d]['log_cost']))
break
for d in sorted(data_bdgl_ge19):
if float(data_bdgl_ge19[d]['log_cost']) > 256:
p("bdgl/ge19/dim/cost256", d)
p("bdgl/ge19/adv/cost256", float(data_bdgl_classical[d]['log_cost']) - float(data_bdgl_ge19[d]['log_cost']))
break
for d in sorted(data_bdgl_dw):
if float(data_bdgl_dw[d]['log_cost']) > 128:
p("bdgl/dw/dim/cost128", d)
p("bdgl/dw/adv/cost128", float(data_bdgl_classical[d]['log_cost']) - float(data_bdgl_dw[d]['log_cost']))
break
for d in sorted(data_bdgl_dw):
if float(data_bdgl_dw[d]['log_cost']) > 256:
p("bdgl/dw/dim/cost256", d)
p("bdgl/dw/adv/cost256", float(data_bdgl_classical[d]['log_cost']) - float(data_bdgl_dw[d]['log_cost']))
break
for d in sorted(data_size_bits):
if d % 16 == 0 and float(data_size_bits[d]['log2_size']) > 127:
p("size128/dim", d)
p("bdgl/ge19/adv/size128", float(data_bdgl_classical[d]['log_cost']) - float(data_bdgl_ge19[d]['log_cost']))
p("bdgl/dw/adv/size128", float(data_bdgl_classical[d]['log_cost']) - float(data_bdgl_dw[d]['log_cost']))
break
# Assume a moon sized memory with 1 petabyte per gram density
for d in sorted(data_size_bits):
if d % 16 == 0 and float(data_size_bits[d]['log2_size']) > 139:
p("size140/dim", d)
p("bdgl/ge19/adv/size140", float(data_bdgl_classical[d]['log_cost']) - float(data_bdgl_ge19[d]['log_cost']))
p("bdgl/dw/adv/size140", float(data_bdgl_classical[d]['log_cost']) - float(data_bdgl_dw[d]['log_cost']))
break
if __name__ == "__main__":
main()