update tests and test spectral_gap directly

This commit is contained in:
kalmarek 2019-07-01 01:38:30 +02:00
parent cc9d3db846
commit 75e997b2e8
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
5 changed files with 125 additions and 98 deletions

View File

@ -2,38 +2,50 @@
@testset "SL(2,Z)" begin
N = 2
G = MatrixSpace(Nemo.ZZ, N,N)
S = Groups.gens(G)
S = [S; inv.(S)]
G = MatrixAlgebra(zz, N)
S = PropertyT.generating_set(G)
rm("SL($N,Z)", recursive=true, force=true)
sett = PropertyT.Settings("SL($N,Z)", G, S, solver(20000, accel=20); upper_bound=0.1)
@test PropertyT.check_property_T(sett) == false
sett = PropertyT.Settings("SL($N,Z)", G, S, with_SCS(20000, accel=20); upper_bound=0.1)
PropertyT.print_summary(sett)
λ = PropertyT.spectral_gap(sett)
@test λ < 0.0
@test PropertyT.interpret_results(sett, λ) == false
end
@testset "SL(3,Z)" begin
N = 3
G = MatrixSpace(Nemo.ZZ, N,N)
S = Groups.gens(G)
S = [S; inv.(S)]
G = MatrixAlgebra(zz, N)
S = PropertyT.generating_set(G)
rm("SL($N,Z)", recursive=true, force=true)
sett = PropertyT.Settings("SL($N,Z)", G, S, solver(1000, accel=20); upper_bound=0.1)
@test PropertyT.check_property_T(sett) == true
sett = PropertyT.Settings("SL($N,Z)", G, S, with_SCS(1000, accel=20); upper_bound=0.1)
PropertyT.print_summary(sett)
λ = PropertyT.spectral_gap(sett)
@test λ > 0.0999
@test PropertyT.interpret_results(sett, λ) == true
@test PropertyT.check_property_T(sett) == true #second run should be fast
end
@testset "SAut(F₂)" begin
N = 2
G = SAut(FreeGroup(N))
S = Groups.gens(G)
S = [S; inv.(S)]
S = PropertyT.generating_set(G)
rm("SAut(F$N)", recursive=true, force=true)
sett = PropertyT.Settings("SAut(F$N)", G, S, solver(20000);
sett = PropertyT.Settings("SAut(F$N)", G, S, with_SCS(10000);
upper_bound=0.15, warmstart=false)
@test PropertyT.check_property_T(sett) == false
PropertyT.print_summary(sett)
λ = PropertyT.spectral_gap(sett)
@test λ < 0.0
@test PropertyT.interpret_results(sett, λ) == false
end
end

View File

@ -2,58 +2,85 @@
@testset "oSL(3,Z)" begin
N = 3
G = MatrixSpace(Nemo.ZZ, N,N)
S = Groups.gens(G)
S = [S; inv.(S)]
G = MatrixAlgebra(zz, N)
S = PropertyT.generating_set(G)
autS = WreathProduct(PermGroup(2), PermGroup(N))
rm("oSL($N,Z)", recursive=true, force=true)
sett = PropertyT.Settings("SL($N,Z)", G, S, autS, solver(2000, accel=20);
upper_bound=0.27, warmstart=false)
@test PropertyT.check_property_T(sett) == false
#second run just checks the solution
@test PropertyT.check_property_T(sett) == false
sett = PropertyT.Settings("SL($N,Z)", G, S, autS, solver(2000, accel=20);
rm("oSL($N,Z)", recursive=true, force=true)
sett = PropertyT.Settings("SL($N,Z)", G, S, autS, with_SCS(2000, accel=20);
upper_bound=0.27, warmstart=false)
PropertyT.print_summary(sett)
λ = PropertyT.spectral_gap(sett)
@test λ < 0.0
@test PropertyT.interpret_results(sett, λ) == false
# second run just checks the solution due to warmstart=false above
@test λ == PropertyT.spectral_gap(sett)
@test PropertyT.check_property_T(sett) == false
sett = PropertyT.Settings("SL($N,Z)", G, S, autS, with_SCS(2000, accel=20);
upper_bound=0.27, warmstart=true)
PropertyT.print_summary(sett)
λ = PropertyT.spectral_gap(sett)
@test λ > 0.269999
@test PropertyT.interpret_results(sett, λ) == true
# this should be very fast due to warmstarting:
@test λ PropertyT.spectral_gap(sett) atol=1e-5
@test PropertyT.check_property_T(sett) == true
end
@testset "oSL(4,Z)" begin
N = 4
G = MatrixSpace(Nemo.ZZ, N,N)
S = Groups.gens(G)
S = [S; inv.(S)]
G = MatrixAlgebra(zz, N)
S = PropertyT.generating_set(G)
autS = WreathProduct(PermGroup(2), PermGroup(N))
rm("oSL($N,Z)", recursive=true, force=true)
sett = PropertyT.Settings("SL($N,Z)", G, S, autS, solver(2000, accel=20);
upper_bound=1.3, warmstart=false)
@test PropertyT.check_property_T(sett) == false
#second run just checks the obtained solution
@test PropertyT.check_property_T(sett) == false
sett = PropertyT.Settings("SL($N,Z)", G, S, autS, solver(5000, accel=20);
rm("oSL($N,Z)", recursive=true, force=true)
sett = PropertyT.Settings("SL($N,Z)", G, S, autS, with_SCS(2000, accel=20);
upper_bound=1.3, warmstart=false)
PropertyT.print_summary(sett)
λ = PropertyT.spectral_gap(sett)
@test λ < 0.0
@test PropertyT.interpret_results(sett, λ) == false
# second run just checks the solution due to warmstart=false above
@test λ == PropertyT.spectral_gap(sett)
@test PropertyT.check_property_T(sett) == false
sett = PropertyT.Settings("SL($N,Z)", G, S, autS, with_SCS(5000, accel=20);
upper_bound=1.3, warmstart=true)
PropertyT.print_summary(sett)
λ = PropertyT.spectral_gap(sett)
@test λ > 1.2999
@test PropertyT.interpret_results(sett, λ) == true
# this should be very fast due to warmstarting:
@test λ PropertyT.spectral_gap(sett) atol=1e-5
@test PropertyT.check_property_T(sett) == true
end
@testset "SAut(F₃)" begin
N = 3
G = SAut(FreeGroup(N))
S = Groups.gens(G)
S = [S; inv.(S)]
S = PropertyT.generating_set(G)
autS = WreathProduct(PermGroup(2), PermGroup(N))
rm("oSAut(F$N)", recursive=true, force=true)
sett = PropertyT.Settings("SAut(F$N)", G, S, autS, solver(5000);
sett = PropertyT.Settings("SAut(F$N)", G, S, autS, with_SCS(1000);
upper_bound=0.15, warmstart=false)
PropertyT.print_summary(sett)
@test PropertyT.check_property_T(sett) == false
end
end

View File

@ -7,26 +7,25 @@
@testset "unit tests" begin
for N in [3,4]
M = MatrixSpace(Nemo.ZZ, N,N)
A = SAut(FreeGroup(N))
@test length(PropertyT.generating_set(M)) == 2N*(N-1)
M = MatrixAlgebra(zz, N)
@test PropertyT.E(M, 1, 2) isa MatAlgElem
e12 = PropertyT.E(M, 1, 2)
@test e12[1,2] == 1
@test inv(e12)[1,2] == -1
S = PropertyT.generating_set(M)
@test e12 S
@test length(PropertyT.generating_set(M)) == 2N*(N-1)
@test all(inv(s) S for s in S)
A = SAut(FreeGroup(N))
@test length(PropertyT.generating_set(A)) == 4N*(N-1)
S = PropertyT.generating_set(A)
@test all(inv(s) S for s in S)
end
N = 4
M = MatrixSpace(Nemo.ZZ, N,N)
S = PropertyT.generating_set(M)
@test PropertyT.E(M, 1, 2) isa MatElem
e12 = PropertyT.E(M, 1, 2)
@test e12[1,2] == 1
@test inv(e12)[1,2] == -1
@test e12 S
@test PropertyT.isopposite(perm"(1,2,3)(4)", perm"(1,4,2)")
@test PropertyT.isadjacent(perm"(1,2,3)", perm"(1,2)(3)")
@ -40,7 +39,7 @@
@testset "Sq, Adj, Op" begin
N = 4
M = MatrixSpace(Nemo.ZZ, N,N)
M = MatrixAlgebra(zz, N)
S = PropertyT.generating_set(M)
Δ = PropertyT.Laplacian(S, 2)
RG = parent(Δ)
@ -94,24 +93,17 @@ end
@testset "1812.03456 examples" begin
with_SCS = with_optimizer(SCS.Optimizer,
linear_solver=SCS.Direct,
eps=2e-10,
max_iters=20000,
alpha=1.5,
acceleration_lookback=10,
warm_start=true)
function SOS_residual(x::GroupRingElem, Q::Matrix)
function SOS_residual(x::GroupRingElem, Q::Matrix)
RG = parent(x)
@time sos = PropertyT.compute_SOS(RG, Q);
return x - sos
end
function check_positivity(elt, Δ, orbit_data, upper_bound, warm=nothing; with_solver=with_SCS)
function check_positivity(elt, Δ, orbit_data, upper_bound, warm=nothing; with_solver=with_SCS(20_000, accel=10))
SDP_problem, varP = PropertyT.SOS_problem(elt, Δ, orbit_data; upper_bound=upper_bound)
status, warm = PropertyT.solve(SDP_problem, with_solver, warm);
Base.Libc.flush_cstdio()
@info "Optimization status:" status
λ = value(SDP_problem[])
@ -127,7 +119,7 @@ end
@testset "SL(3,Z)" begin
N = 3
halfradius = 2
M = MatrixSpace(Nemo.ZZ, N,N)
M = MatrixAlgebra(zz, N)
S = PropertyT.generating_set(M)
Δ = PropertyT.Laplacian(S, halfradius)
RG = parent(Δ)
@ -139,6 +131,7 @@ end
UB = 0.05 # 0.105?
residual, λ, _ = check_positivity(elt, Δ, orbit_data, UB)
Base.Libc.flush_cstdio()
@info "obtained λ and residual" λ norm(residual, 1)
@test 2^2*norm(residual, 1) < λ # i.e. we can certify positivity
@ -151,6 +144,7 @@ end
UB = 0.1 # 0.157?
residual, λ, _ = check_positivity(elt, Δ, orbit_data, UB)
Base.Libc.flush_cstdio()
@info "obtained λ and residual" λ norm(residual, 1)
@test 2^2*norm(residual, 1) < λ
@ -162,6 +156,7 @@ end
UB = Inf
residual, λ, _ = check_positivity(elt, Δ, orbit_data, UB)
Base.Libc.flush_cstdio()
@info "obtained λ and residual" λ norm(residual, 1)
@test 2^2*norm(residual, 1) > λ
@ -171,7 +166,7 @@ end
@testset "SL(4,Z)" begin
N = 4
halfradius = 2
M = MatrixSpace(Nemo.ZZ, N,N)
M = MatrixAlgebra(zz, N)
S = PropertyT.generating_set(M)
Δ = PropertyT.Laplacian(S, halfradius)
RG = parent(Δ)
@ -183,6 +178,7 @@ end
UB = 0.2 # 0.3172
residual, λ, _ = check_positivity(elt, Δ, orbit_data, UB)
Base.Libc.flush_cstdio()
@info "obtained λ and residual" λ norm(residual, 1)
@test 2^2*norm(residual, 1) < λ # i.e. we can certify positivity
@ -204,7 +200,9 @@ end
elt = PropertyT.Op(RG)
UB = 2.0
residual, λ, _ = check_positivity(elt, Δ, orbit_data, UB)
residual, λ, _ = check_positivity(elt, Δ, orbit_data, UB,
with_solver=with_SCS(20_000, accel=10, eps=2e-10))
Base.Libc.flush_cstdio()
@info "obtained λ and residual" λ norm(residual, 1)
@test 2^2*norm(residual, 1) > λ # i.e. we can certify positivity
@ -215,6 +213,7 @@ end
UB = 0.6 # 0.82005
residual, λ, _ = check_positivity(elt, Δ, orbit_data, UB)
Base.Libc.flush_cstdio()
@info "obtained λ and residual" λ norm(residual, 1)
@test 2^2*norm(residual, 1) < λ # i.e. we can certify positivity

View File

@ -1,5 +1,3 @@
using PropertyT.GroupRings
@testset "Correctness of HPC SOS computation" begin
function prepare(G_name, λ, S_size)

View File

@ -1,24 +1,15 @@
using AbstractAlgebra, Nemo, Groups, SCS
using SparseArrays
using JLD
using PropertyT
using Test
using JuMP
using LinearAlgebra, SparseArrays
using AbstractAlgebra, Groups, GroupRings
using PropertyT
using JLD
indexing(n) = [(i,j) for i in 1:n for j in (i+1):n]
function Groups.gens(M::MatSpace)
@assert ncols(M) == nrows(M)
N = ncols(M)
E(i,j) = begin g = M(1); g[i,j] = 1; g end
S = [E(i,j) for (i,j) in indexing(N)]
S = [S; transpose.(S)]
return S
end
using JuMP, SCS
solver(iters; accel=1) =
with_SCS(iters; accel=1, eps=1e-10) =
with_optimizer(SCS.Optimizer,
linear_solver=SCS.Direct, max_iters=iters,
acceleration_lookback=accel, eps=1e-10, warm_start=true)
acceleration_lookback=accel, eps=eps, warm_start=true)
include("1703.09680.jl")
include("1712.07167.jl")