Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 8800
1
r"""
2
Populate the cast128 database.
3
"""
4
5
#*****************************************************************************
6
# Copyright (C) 2017 Paul Leopardi [email protected]
7
#
8
# Distributed under the terms of the GNU General Public License (GPL)
9
# as published by the Free Software Foundation; either version 2 of
10
# the License, or (at your option) any later version.
11
# http://www.gnu.org/licenses/
12
#*****************************************************************************
13
14
import datetime
15
import json
16
import psycopg2
17
18
from boolean_cayley_graphs.bent_function import BentFunction
19
from boolean_cayley_graphs.bent_function_cayley_graph_classification import BentFunctionCayleyGraphClassification
20
from boolean_cayley_graphs.classification_database_psycopg2 import *
21
22
with open("BCG-DB.json") as auth_file:
23
auth = json.load(auth_file)
24
25
conn = create_classification_tables(
26
"cast128",
27
user=auth["user"],
28
password=auth["passwd"],
29
host=auth["host"])
30
31
for i in range(1,9):
32
stri = "%01d" % i
33
for j in range(32):
34
strj = "%02d" % j
35
sobj_name = "cast128_" + stri + "_" + str(j) + ".sobj"
36
name = "cast128_" + stri + "_" + strj
37
cgc = BentFunctionCayleyGraphClassification.load_mangled(
38
sobj_name,
39
directory="/data/sobj")
40
print(datetime.datetime.now(), stri, strj)
41
insert_classification(conn, cgc, name)
42
print(datetime.datetime.now())
43
44
curs = conn.cursor()
45
print(datetime.datetime.now(), "before")
46
curs.execute("SELECT COUNT(*) FROM cayley_graph")
47
print(datetime.datetime.now(), "after")
48
for row in curs:
49
for x in row:
50
print(x)
51
52
print(datetime.datetime.now(), "before")
53
curs.execute("SELECT COUNT(*) FROM graph")
54
print(datetime.datetime.now(), "after")
55
for row in curs:
56
for x in row:
57
print(x)
58
59
cgc1 = select_classification_where_name(
60
conn,
61
"cast128_1_09")
62
cgc1.report()
63
64
cgc2 = BentFunctionCayleyGraphClassification.load_mangled(
65
"cast128_1_9",
66
directory="/data/sobj")
67
bentf = BentFunction(cgc.algebraic_normal_form)
68
69
cgc3 = select_classification_where_bent_function(
70
conn,
71
bentf)
72
cgc3.report()
73
74
conn.close()
75
76
77