GroupsWithPropertyT/SL.jl

174 lines
4.5 KiB
Julia
Raw Normal View History

using ArgParse
using GroupAlgebras
using PropertyT
2017-03-13 16:18:42 +01:00
using Nemo
import SCS.SCSSolver
2017-03-13 16:18:42 +01:00
function E(i::Int, j::Int, M::Nemo.MatSpace)
@assert i≠j
m = one(M)
m[i,j] = m[1,1]
return m
2017-03-13 16:18:42 +01:00
end
function SL_generatingset(n::Int)
indexing = [(i,j) for i in 1:n for j in 1:n if i≠j]
G = Nemo.MatrixSpace(Nemo.ZZ, n,n)
S = [E(i,j,G) for (i,j) in indexing];
S = vcat(S, [transpose(x) for x in S]);
S = vcat(S, [inv(x) for x in S]);
return unique(S), one(G)
2017-03-13 16:18:42 +01:00
end
2017-03-31 22:41:04 +02:00
function SLsize(n,p)
result = 1
for k in 0:n-1
result *= p^n - p^k
end
return div(result, p-1)
end
2017-03-13 16:18:42 +01:00
function SL_generatingset(n::Int, p::Int)
p == 0 && return SL_generatingset(n)
(p > 1 && n > 0) || throw(ArgumentError("Both n and p should be positive integers!"))
2017-03-31 22:41:04 +02:00
println("Size(SL(n,p)) = $(SLsize(n,p))")
F = Nemo.ResidueRing(Nemo.ZZ, p)
G = Nemo.MatrixSpace(F, n,n)
2017-03-13 16:18:42 +01:00
indexing = [(i,j) for i in 1:n for j in 1:n if i≠j]
S = [E(i, j, G) for (i,j) in indexing]
S = vcat(S, [transpose(x) for x in S])
2017-03-13 16:18:42 +01:00
S = vcat(S, [inv(s) for s in S])
return unique(S), one(G)
2017-03-13 16:18:42 +01:00
end
function products{T}(U::AbstractVector{T}, V::AbstractVector{T})
result = Vector{T}()
for u in U
for v in V
push!(result, u*v)
end
end
return unique(result)
end
2017-03-31 22:40:31 +02:00
function ΔandSDPconstraints(Id, S, radius)
radius *=2
sizes = Vector{Int}()
2017-03-26 16:08:49 +02:00
S = vcat([Id], S)
B = S
2017-03-31 22:40:31 +02:00
push!(sizes,length(B))
2017-03-26 16:08:49 +02:00
for i in 2:radius
B = products(S, B);
2017-03-31 22:40:31 +02:00
push!(sizes, length(B))
2017-03-26 16:08:49 +02:00
end
2017-03-31 22:40:31 +02:00
println("Generated balls of sizes $sizes")
2017-03-26 16:08:49 +02:00
k = div(radius,2)
2017-03-31 22:40:31 +02:00
basis = B[1:sizes[k]]
2017-03-26 16:08:49 +02:00
2017-03-31 22:40:31 +02:00
product_matrix = PropertyT.create_product_matrix(B, sizes[k]);
2017-03-26 16:08:49 +02:00
sdp_constraints = PropertyT.constraints_from_pm(product_matrix, length(B))
L_coeff = PropertyT.splaplacian_coeff(S, basis, length(B));
2017-03-13 16:18:42 +01:00
Δ = GroupAlgebraElement(L_coeff, product_matrix)
return Δ, sdp_constraints
end
2017-03-13 20:38:07 +01:00
#=
To use file property(T).jl (specifically: check_property_T function)
You need to define:
2017-03-13 16:18:42 +01:00
2017-03-13 20:38:07 +01:00
function ΔandSDPconstraints(identity, S):: (Δ, sdp_constraints)
2017-03-13 16:18:42 +01:00
2017-03-13 20:38:07 +01:00
=#
2017-03-13 16:18:42 +01:00
function cpuinfo_physicalcores()
maxcore = -1
for line in eachline("/proc/cpuinfo")
if startswith(line, "core id")
maxcore = max(maxcore, parse(Int, split(line, ':')[2]))
end
end
maxcore < 0 && error("failure to read core ids from /proc/cpuinfo")
return maxcore + 1
end
2017-03-13 16:18:42 +01:00
function parse_commandline()
s = ArgParseSettings()
@add_arg_table s begin
"--tol"
2017-03-26 16:27:38 +02:00
help = "set numerical tolerance for the SDP solver (default: 1e-5)"
arg_type = Float64
2017-03-26 16:27:38 +02:00
default = 1e-5
"--iterations"
2017-03-26 16:27:38 +02:00
help = "set maximal number of iterations for the SDP solver (default: 20000)"
arg_type = Int
2017-03-26 16:27:38 +02:00
default = 20000
"--upper-bound"
2017-03-26 16:27:38 +02:00
help = "Set an upper bound for the spectral gap (default: Inf)"
arg_type = Float64
default = Inf
"--cpus"
2017-03-26 16:27:38 +02:00
help = "Set number of cpus used by solver (default: auto)"
arg_type = Int
required = false
"-N"
2017-03-26 16:27:38 +02:00
help = "Consider matrices of size N (default: N=3)"
arg_type = Int
default = 3
"-p"
2017-03-26 16:27:38 +02:00
help = "Matrices over filed of p-elements (default: p=0 => over ZZ)"
arg_type = Int
default = 0
2017-03-31 22:40:31 +02:00
"--radius"
help = "Find the decomposition over B_r(e,S)"
arg_type = Int
default = 0
end
return parse_args(s)
end
function main()
2017-03-17 18:09:23 +01:00
parsed_args = parse_commandline()
2017-03-13 16:18:42 +01:00
tol = parsed_args["tol"]
iterations = parsed_args["iterations"]
solver = SCSSolver(eps=tol, max_iters=iterations, verbose=true)
N = parsed_args["N"]
upper_bound = parsed_args["upper-bound"]
p = parsed_args["p"]
if p == 0
name = "SL$(N)Z"
else
2017-03-17 16:02:34 +01:00
name = "SL$(N)_$p"
end
2017-03-31 22:40:31 +02:00
radius = parsed_args["radius"]
if radius == 0
name = name*"-$(string(upper_bound))"
2017-03-31 22:40:31 +02:00
radius = 2
else
name = name*"-$(string(upper_bound))-r=$radius"
end
S() = SL_generatingset(N, p)
if parsed_args["cpus"] nothing
if parsed_args["cpus"] > cpuinfo_physicalcores()
warn("Number of specified cores exceeds the physical core cound. Performance will suffer.")
end
Blas.set_num_threads(parsed_args["cpus"])
end
2017-03-31 22:40:31 +02:00
@time PropertyT.check_property_T(name, S, solver, upper_bound, tol, radius)
2017-03-17 16:02:50 +01:00
return 0
end
2017-03-13 16:18:42 +01:00
main()