Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cdc-counting
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Radek Hušek
cdc-counting
Commits
bce3fc3b
Commit
bce3fc3b
authored
4 years ago
by
Radek Hušek
Browse files
Options
Downloads
Patches
Plain Diff
Flower snark experiment
parent
5b3b8563
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
experiments/flower-snarks.py
+88
-0
88 additions, 0 deletions
experiments/flower-snarks.py
with
88 additions
and
0 deletions
experiments/flower-snarks.py
0 → 100755
+
88
−
0
View file @
bce3fc3b
#!/usr/bin/python
DOC
=
"""
Calculate that the number of CDCs of Flower snark $J_k$ is $16^{(1-o(1))k}$.
We calculate the step matrix $M$, show that 16 is its eigenvalue by finding
its eigenvector. The eigenvector is guessed for the ratios of coefficients
of $M^10 x$ and $M^9 x$ where $x$ is the initial vector. This eigenvector
shares one non-zero coordinate with the final vector.
"""
import
sys
,
os
sys
.
path
.
append
(
os
.
path
.
dirname
(
__file__
)
+
"
/..
"
)
from
graph_tools.all
import
*
from
sage.all
import
identity_matrix
,
QQ
,
DiGraph
,
matrix
def
test_eigenvalue
(
M
,
x
):
H
=
M
-
x
*
identity_matrix
(
QQ
,
M
.
ncols
(),
sparse
=
True
)
if
H
.
is_singular
():
print
(
"
Value %i is an eigenvalue of M with geometric multiplicity %i
"
%
(
x
,
H
.
ncols
()
-
H
.
rank
()))
def
matrix_to_rev_graph
(
M
):
assert
M
.
ncols
()
==
M
.
nrows
()
return
DiGraph
([
range
(
M
.
ncols
()),
M
.
dict
().
keys
()],
format
=
"
vertices_and_edges
"
,
loops
=
True
)
if
__name__
==
"
__main__
"
:
print
(
DOC
)
print
(
"
Stabilizing...
"
)
S
=
FlowerSnark
.
stabilize
(
CircuitDoubleCover
,
jordan
=
False
)
print
(
"
Done
"
)
M
=
S
[
"
step_matrix
"
]
print
(
"
\n
The rank of the step matrix M: %s
"
%
M
.
rank
())
upto
=
16
print
(
"
Testing if integers up to %i are eigenvalues:
"
%
upto
)
for
x
in
range
(
upto
+
1
):
test_eigenvalue
(
M
,
x
)
fin
=
S
[
"
finalize
"
]
print
(
"
\n
Cheking correctness of the matrix
"
)
N
=
16
A
=
S
[
"
initial_vector
"
]
for
i
in
range
(
3
,
N
):
nu1
=
FlowerSnark
.
graph
(
i
).
eval
(
CircuitDoubleCover
)
A
=
M
*
A
nu2
=
fin
*
A
assert
nu1
==
nu2
print
(
"
ν(J_%i) = %i
"
%
(
i
,
nu1
))
print
(
"
Done
"
)
print
(
"
\n
Calculating the eigenvector for eigenvalue 16
"
)
to_dict
=
lambda
g
:
{
b
.
boundary
:
b
.
value
for
b
in
g
}
gadget_to_dict
=
lambda
i
:
to_dict
(
FlowerSnark
.
gadget
(
i
).
eval_gadget
(
CircuitDoubleCover
))
X10
=
gadget_to_dict
(
10
)
X9
=
gadget_to_dict
(
9
)
B
=
[
b
for
b
in
X10
.
keys
()
if
b
in
X9
and
X10
[
b
]
/
X9
[
b
]
>
15
]
m
=
min
(
X10
[
b
]
for
b
in
B
)
vec
=
{
b
:
int
(
round
(
X10
[
b
]
/
m
))
for
b
in
B
}
print
(
"
Guessed eigenvector (with %i non-zero coordinates):
"
%
len
(
vec
))
for
b
,
v
in
sorted
(
vec
.
items
()):
print
(
"
%i at %s
"
%
(
v
,
b
))
print
(
"
Checking it...
"
)
nex
=
to_dict
(
FlowerSnark
.
_next_gadget
(
FakeGadget
(
6
,
[
Boundary
(
b
,
v
)
for
b
,
v
in
vec
.
items
()
])).
eval_gadget
(
CircuitDoubleCover
))
assert
nex
.
keys
()
==
vec
.
keys
()
for
b
in
vec
:
assert
vec
[
b
]
*
16
==
nex
[
b
],
"
Oops at %b
"
%
b
assert
set
(
S
[
"
variables
"
]).
issuperset
(
vec
.
keys
())
index
=
{
b
:
i
for
i
,
b
in
enumerate
(
S
[
"
variables
"
])
}
vec_
=
matrix
(
QQ
,
M
.
ncols
(),
1
,
{
(
index
[
b
],
0
):
v
for
b
,
v
in
vec
.
items
()
})
assert
M
*
vec_
==
16
*
vec_
print
(
"
Done
"
)
print
(
"
Boundaries of with the non-zero value in both the eigenvector and the final vector:
"
)
for
i
in
range
(
vec_
.
nrows
()):
if
vec_
[
i
,
0
]
>
0
and
fin
[
0
,
i
]
>
0
:
print
(
"
%s
"
%
(
S
[
"
variables
"
][
i
],))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment