2017-03-16 18:13:55 +01:00
|
|
|
|
using ArgParse
|
2017-03-13 16:18:42 +01:00
|
|
|
|
|
2017-03-26 16:06:41 +02:00
|
|
|
|
using Nemo
|
2017-06-22 15:18:26 +02:00
|
|
|
|
import SCS.SCSSolver
|
2017-06-06 12:03:58 +02:00
|
|
|
|
using PropertyT
|
2017-03-16 18:13:55 +01:00
|
|
|
|
|
2017-03-13 16:18:42 +01:00
|
|
|
|
|
2017-09-10 15:40:52 +02:00
|
|
|
|
###############################################################################
|
|
|
|
|
#
|
|
|
|
|
# Generating set
|
|
|
|
|
#
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
|
|
function E(i::Int, j::Int, M::MatSpace, val=one(M.base_ring))
|
2017-03-26 16:06:41 +02:00
|
|
|
|
@assert i≠j
|
|
|
|
|
m = one(M)
|
2017-09-10 15:40:52 +02:00
|
|
|
|
m[i,j] = val
|
2017-03-26 16:06:41 +02:00
|
|
|
|
return m
|
2017-03-13 16:18:42 +01:00
|
|
|
|
end
|
|
|
|
|
|
2017-03-31 22:41:04 +02:00
|
|
|
|
function SLsize(n,p)
|
2017-09-10 15:40:52 +02:00
|
|
|
|
result = BigInt(1)
|
2017-03-31 22:41:04 +02:00
|
|
|
|
for k in 0:n-1
|
|
|
|
|
result *= p^n - p^k
|
|
|
|
|
end
|
|
|
|
|
return div(result, p-1)
|
|
|
|
|
end
|
|
|
|
|
|
2017-09-10 15:40:52 +02:00
|
|
|
|
function SL_generatingset(n::Int, X::Bool=false)
|
|
|
|
|
indexing = [(i,j) for i in 1:n for j in 1:n if i≠j]
|
|
|
|
|
G = MatrixSpace(ZZ, n, n)
|
|
|
|
|
if X
|
|
|
|
|
S = [E(i,j,G,v) for (i,j) in indexing for v in [1, 100]]
|
|
|
|
|
else
|
|
|
|
|
S = [E(i,j,G,v) for (i,j) in indexing for v in [1]]
|
|
|
|
|
end
|
|
|
|
|
S = vcat(S, [inv(x) for x in S])
|
|
|
|
|
return G, unique(S)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function SL_generatingset(n::Int, p::Int, X::Bool=false)
|
|
|
|
|
p == 0 && return SL_generatingset(n, X)
|
|
|
|
|
(p > 1 && n > 1) || throw("Both n and p should be positive integers!")
|
|
|
|
|
info("Size(SL($n,$p)) = $(SLsize(n,p))")
|
|
|
|
|
F = ResidueRing(ZZ, p)
|
|
|
|
|
G = 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]
|
2017-03-26 16:06:41 +02:00
|
|
|
|
S = [E(i, j, G) for (i,j) in indexing]
|
2017-09-10 15:40:52 +02:00
|
|
|
|
S = vcat(S, [inv(x) for x in S])
|
|
|
|
|
return G, unique(S)
|
2017-03-13 16:18:42 +01:00
|
|
|
|
end
|
|
|
|
|
|
2017-09-10 15:40:52 +02:00
|
|
|
|
###############################################################################
|
|
|
|
|
#
|
|
|
|
|
# Parsing command line
|
|
|
|
|
#
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
2017-03-16 18:13:55 +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
|
|
|
|
|
2017-03-16 18:13:55 +01:00
|
|
|
|
function parse_commandline()
|
2017-09-10 15:40:52 +02:00
|
|
|
|
settings = ArgParseSettings()
|
2017-03-16 18:13:55 +01:00
|
|
|
|
|
2017-09-10 15:40:52 +02:00
|
|
|
|
@add_arg_table settings begin
|
2017-03-16 18:13:55 +01:00
|
|
|
|
"--tol"
|
2017-09-10 15:40:52 +02:00
|
|
|
|
help = "set numerical tolerance for the SDP solver"
|
2017-03-16 18:13:55 +01:00
|
|
|
|
arg_type = Float64
|
2017-09-10 15:40:52 +02:00
|
|
|
|
default = 1e-6
|
2017-03-16 18:13:55 +01:00
|
|
|
|
"--iterations"
|
2017-03-26 16:27:38 +02:00
|
|
|
|
help = "set maximal number of iterations for the SDP solver (default: 20000)"
|
2017-03-16 18:13:55 +01:00
|
|
|
|
arg_type = Int
|
2017-09-10 15:40:52 +02:00
|
|
|
|
default = 50000
|
2017-03-16 18:13:55 +01:00
|
|
|
|
"--upper-bound"
|
2017-09-10 15:40:52 +02:00
|
|
|
|
help = "Set an upper bound for the spectral gap"
|
2017-03-16 18:13:55 +01:00
|
|
|
|
arg_type = Float64
|
|
|
|
|
default = Inf
|
|
|
|
|
"--cpus"
|
2017-09-10 15:40:52 +02:00
|
|
|
|
help = "Set number of cpus used by solver"
|
2017-03-16 18:13:55 +01:00
|
|
|
|
arg_type = Int
|
|
|
|
|
required = false
|
|
|
|
|
"-N"
|
2017-09-10 15:40:52 +02:00
|
|
|
|
help = "Consider elementary matrices EL(N)"
|
2017-03-16 18:13:55 +01:00
|
|
|
|
arg_type = Int
|
2017-09-10 15:40:52 +02:00
|
|
|
|
default = 2
|
2017-03-16 18:13:55 +01:00
|
|
|
|
"-p"
|
2017-09-10 15:40:52 +02:00
|
|
|
|
help = "Matrices over field of p-elements (p=0 => over ZZ)"
|
2017-03-16 18:13:55 +01:00
|
|
|
|
arg_type = Int
|
|
|
|
|
default = 0
|
2017-03-31 22:40:31 +02:00
|
|
|
|
"--radius"
|
2017-09-10 15:40:52 +02:00
|
|
|
|
help = "Radius of ball B_r(e,S) to find solution over"
|
2017-03-31 22:40:31 +02:00
|
|
|
|
arg_type = Int
|
2017-06-06 12:03:58 +02:00
|
|
|
|
default = 2
|
2017-03-16 18:13:55 +01:00
|
|
|
|
end
|
|
|
|
|
|
2017-09-10 15:40:52 +02:00
|
|
|
|
return parse_args(settings)
|
2017-03-16 18:13:55 +01:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function main()
|
2017-03-17 18:09:23 +01:00
|
|
|
|
|
2017-03-16 18:13:55 +01:00
|
|
|
|
parsed_args = parse_commandline()
|
2017-06-06 12:03:58 +02:00
|
|
|
|
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
|
2017-09-10 15:40:52 +02:00
|
|
|
|
BLAS.set_num_threads(parsed_args["cpus"])
|
2017-06-06 12:03:58 +02:00
|
|
|
|
end
|
2017-03-13 16:18:42 +01:00
|
|
|
|
|
2017-03-16 18:13:55 +01:00
|
|
|
|
N = parsed_args["N"]
|
|
|
|
|
p = parsed_args["p"]
|
2017-06-06 12:03:58 +02:00
|
|
|
|
|
2017-03-16 18:13:55 +01:00
|
|
|
|
if p == 0
|
2017-09-10 15:40:52 +02:00
|
|
|
|
dirname = "SL$(N)Z"
|
2017-03-16 18:13:55 +01:00
|
|
|
|
else
|
2017-09-10 15:40:52 +02:00
|
|
|
|
dirname = "SL$(N)_$p"
|
2017-03-16 18:13:55 +01:00
|
|
|
|
end
|
2017-06-06 12:03:58 +02:00
|
|
|
|
|
2017-09-10 15:40:52 +02:00
|
|
|
|
radius = parsed_args["radius"]
|
|
|
|
|
tol = parsed_args["tol"]
|
|
|
|
|
iterations = parsed_args["iterations"]
|
|
|
|
|
upper_bound = parsed_args["upper-bound"]
|
2017-03-16 18:13:55 +01:00
|
|
|
|
|
2017-09-10 15:40:52 +02:00
|
|
|
|
dirname = "$(dirname)_$(upper_bound)_r=$radius"
|
2017-06-06 12:03:58 +02:00
|
|
|
|
|
2017-09-10 15:40:52 +02:00
|
|
|
|
logger = PropertyT.setup_logging(dirname)
|
2017-06-06 12:03:58 +02:00
|
|
|
|
|
2017-09-10 15:40:52 +02:00
|
|
|
|
info(logger, "Group: $dirname")
|
2017-06-06 12:03:58 +02:00
|
|
|
|
info(logger, "Iterations: $iterations")
|
|
|
|
|
info(logger, "Precision: $tol")
|
|
|
|
|
info(logger, "Upper bound: $upper_bound")
|
|
|
|
|
|
2017-09-10 15:40:52 +02:00
|
|
|
|
G, S = SL_generatingset(N, p)
|
|
|
|
|
info(logger, G)
|
|
|
|
|
info(logger, "Symmetric generating set of size $(length(S))")
|
2017-09-10 17:09:20 +02:00
|
|
|
|
Id = one(G)
|
2017-09-10 15:40:52 +02:00
|
|
|
|
|
|
|
|
|
solver = SCSSolver(eps=tol, max_iters=iterations, linearsolver=SCS.Direct)
|
2017-06-06 12:03:58 +02:00
|
|
|
|
|
2017-09-10 15:40:52 +02:00
|
|
|
|
@time PropertyT.check_property_T(dirname, S, Id, solver, upper_bound, tol, radius)
|
2017-03-17 16:02:50 +01:00
|
|
|
|
return 0
|
2017-03-16 18:13:55 +01:00
|
|
|
|
end
|
2017-03-13 16:18:42 +01:00
|
|
|
|
|
2017-03-16 18:13:55 +01:00
|
|
|
|
main()
|