GroupsWithPropertyT/AutFN_orbit.jl

161 lines
4.6 KiB
Julia
Raw Normal View History

2017-06-22 15:18:26 +02:00
using ArgParse
using SCS
2017-11-03 16:37:45 +01:00
# using Mosek
2017-06-22 15:18:26 +02:00
using Nemo
if VERSION >= v"0.6.0"
import Nemo.Generic.perm
end
2017-10-04 21:33:20 +02:00
addprocs(2)
2017-06-22 15:18:26 +02:00
using PropertyT
using Groups
2017-06-08 20:09:27 +02:00
###############################################################################
#
# Action of WreathProductElems on AutGroupElem
#
###############################################################################
function AutFG_emb(A::AutGroup, g::WreathProductElem)
isa(A.objectGroup, FreeGroup) || throw("Not an Aut(Fₙ)")
parent(g).P.n == length(A.objectGroup.gens) || throw("No natural embedding of $(parent(g)) into $A")
powers = [(elt == parent(elt)() ? 0: 1) for elt in g.n.elts]
elt = reduce(*, [A(Groups.flip_autsymbol(i))^pow for (i,pow) in enumerate(powers)])
Groups.r_multiply!(elt, [Groups.perm_autsymbol(g.p)])
return elt
end
function AutFG_emb(A::AutGroup, p::perm)
isa(A.objectGroup, FreeGroup) || throw("Not an Aut(Fₙ)")
parent(p).n == length(A.objectGroup.gens) || throw("No natural embedding of $(parent(g)) into $A")
return A(Groups.perm_autsymbol(p))
end
2017-06-08 20:09:27 +02:00
function (g::WreathProductElem)(a::AutGroupElem)
g = AutFG_emb(parent(a),g)
return g*a*g^-1
end
function (p::perm)(a::AutGroupElem)
g = AutFG_emb(parent(a),p)
return g*a*g^-1
end
2017-06-08 20:09:27 +02:00
###############################################################################
#
# Generating set
#
###############################################################################
2017-10-04 21:32:23 +02:00
function SAutFN_generating_set(N::Int)
2017-06-08 20:09:27 +02:00
2017-10-04 21:32:23 +02:00
SAutFN = AutGroup(FreeGroup(N), special=true)
S = gens(SAutFN);
2017-06-08 20:09:27 +02:00
S = [S; [inv(s) for s in S]]
2017-10-04 21:32:23 +02:00
return SAutFN, unique(S)
2017-06-08 20:09:27 +02:00
end
###############################################################################
#
# Parsing command line
#
###############################################################################
2017-09-10 16:20:36 +02: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-06-08 20:09:27 +02:00
function parse_commandline()
settings = ArgParseSettings()
@add_arg_table settings begin
"--tol"
2017-09-10 16:20:36 +02:00
help = "set numerical tolerance for the SDP solver"
2017-06-08 20:09:27 +02:00
arg_type = Float64
2017-09-10 16:20:36 +02:00
default = 1e-14
2017-06-08 20:09:27 +02:00
"--iterations"
help = "set maximal number of iterations for the SDP solver (default: 20000)"
arg_type = Int
2017-09-10 16:20:36 +02:00
default = 100000
2017-06-08 20:09:27 +02:00
"--upper-bound"
2017-09-10 16:20:36 +02:00
help = "Set an upper bound for the spectral gap"
2017-06-08 20:09:27 +02:00
arg_type = Float64
default = Inf
"--cpus"
help = "Set number of cpus used by solver (default: auto)"
arg_type = Int
required = false
"-N"
2017-09-10 16:20:36 +02:00
help = "Consider automorphisms of free group on N generators"
2017-06-08 20:09:27 +02:00
arg_type = Int
default = 2
"--radius"
2017-09-10 16:20:36 +02:00
help = "Radius of ball B_r(e,S) to find solution over"
2017-06-08 20:09:27 +02:00
arg_type = Int
default = 2
end
return parse_args(settings)
end
###############################################################################
#
# main
#
###############################################################################
function main()
parsed_args = parse_commandline()
2017-09-10 16:20:36 +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
BLAS.set_num_threads(parsed_args["cpus"])
end
2017-06-08 20:09:27 +02:00
N = parsed_args["N"]
radius = parsed_args["radius"]
2017-06-08 21:44:20 +02:00
tol = parsed_args["tol"]
iterations = parsed_args["iterations"]
upper_bound = parsed_args["upper-bound"]
2017-06-08 20:09:27 +02:00
dirname = "oSAutF$(N)_r$radius"
isdir(dirname) || mkdir(dirname)
2017-06-09 22:05:55 +02:00
logger = PropertyT.setup_logging(joinpath(dirname, "$(upper_bound)"))
2017-06-08 20:09:27 +02:00
2017-06-08 21:44:20 +02:00
info(logger, "Group: $dirname")
info(logger, "Iterations: $iterations")
info(logger, "Precision: $tol")
info(logger, "Upper bound: $upper_bound")
2017-10-04 21:32:23 +02:00
G, S = SAutFN_generating_set(N)
2017-06-08 20:09:27 +02:00
info(logger, G)
info(logger, "Symmetric generating set of size $(length(S))")
info(logger, S)
2017-06-22 15:18:26 +02:00
AutS = WreathProduct(FiniteField(2,1, "a")[1], PermutationGroup(N))
# AutS = PermutationGroup(N)
2017-06-08 20:09:27 +02:00
2017-09-10 16:20:36 +02:00
solver = SCSSolver(eps=tol, max_iters=iterations, linearsolver=SCS.Direct)
2017-11-03 16:37:45 +01:00
# solver = Mosek.MosekSolver(
# MSK_DPAR_INTPNT_CO_TOL_REL_GAP=tol,
# MSK_IPAR_INTPNT_MAX_ITERATIONS=iterations,
# QUIET=false)
2017-06-08 20:09:27 +02:00
2017-06-08 21:35:27 +02:00
sett = Settings(dirname, N, G, S, AutS, radius, solver, upper_bound, tol)
2017-06-22 15:18:26 +02:00
PropertyT.check_property_T(sett)
2017-06-08 20:09:27 +02:00
end
main()