1
0
mirror of https://github.com/kalmarek/PropertyT.jl.git synced 2024-12-26 10:35:29 +01:00

update and reformat tests

This commit is contained in:
Marek Kaluba 2023-03-19 23:28:36 +01:00
parent fb3b51fd6e
commit 914b068070
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
9 changed files with 424 additions and 235 deletions

View File

@ -1,9 +1,8 @@
@testset "1703.09680 Examples" begin @testset "1703.09680 Examples" begin
@testset "SL(2,Z)" begin @testset "SL(2,Z)" begin
N = 2 N = 2
G = MatrixGroups.SpecialLinearGroup{N}(Int8) G = MatrixGroups.SpecialLinearGroup{N}(Int8)
RG, S, sizes = PropertyT.group_algebra(G, halfradius=2, twisted=true) RG, S, sizes = PropertyT.group_algebra(G; halfradius = 2)
Δ = let RG = RG, S = S Δ = let RG = RG, S = S
RG(length(S)) - sum(RG(s) for s in S) RG(length(S)) - sum(RG(s) for s in S)
@ -15,15 +14,15 @@
status, certified, λ = check_positivity( status, certified, λ = check_positivity(
elt, elt,
unit, unit;
upper_bound=ub, upper_bound = ub,
halfradius=2, halfradius = 2,
optimizer=scs_optimizer( optimizer = scs_optimizer(;
eps=1e-10, eps = 1e-10,
max_iters=5_000, max_iters = 5_000,
accel=50, accel = 50,
alpha=1.9, alpha = 1.9,
) ),
) )
@test status == JuMP.ALMOST_OPTIMAL @test status == JuMP.ALMOST_OPTIMAL
@ -33,8 +32,10 @@
@testset "SL(3,F₅)" begin @testset "SL(3,F₅)" begin
N = 3 N = 3
G = MatrixGroups.SpecialLinearGroup{N}(SymbolicWedderburn.Characters.FiniteFields.GF{5}) G = MatrixGroups.SpecialLinearGroup{N}(
RG, S, sizes = PropertyT.group_algebra(G, halfradius=2, twisted=true) SymbolicWedderburn.Characters.FiniteFields.GF{5},
)
RG, S, sizes = PropertyT.group_algebra(G; halfradius = 2)
Δ = let RG = RG, S = S Δ = let RG = RG, S = S
RG(length(S)) - sum(RG(s) for s in S) RG(length(S)) - sum(RG(s) for s in S)
@ -46,15 +47,15 @@
status, certified, λ = check_positivity( status, certified, λ = check_positivity(
elt, elt,
unit, unit;
upper_bound=ub, upper_bound = ub,
halfradius=2, halfradius = 2,
optimizer=scs_optimizer( optimizer = scs_optimizer(;
eps=1e-10, eps = 1e-10,
max_iters=5_000, max_iters = 5_000,
accel=50, accel = 50,
alpha=1.9, alpha = 1.9,
) ),
) )
@test status == JuMP.OPTIMAL @test status == JuMP.OPTIMAL
@ -62,12 +63,15 @@
@test λ > 1 @test λ > 1
m = PropertyT.sos_problem_dual(elt, unit) m = PropertyT.sos_problem_dual(elt, unit)
PropertyT.solve(m, cosmo_optimizer( PropertyT.solve(
eps=1e-6, m,
max_iters=5_000, cosmo_optimizer(;
accel=50, eps = 1e-6,
alpha=1.9, max_iters = 5_000,
)) accel = 50,
alpha = 1.9,
),
)
@test JuMP.termination_status(m) in (JuMP.ALMOST_OPTIMAL, JuMP.OPTIMAL) @test JuMP.termination_status(m) in (JuMP.ALMOST_OPTIMAL, JuMP.OPTIMAL)
@test JuMP.objective_value(m) 1.5 atol = 1e-2 @test JuMP.objective_value(m) 1.5 atol = 1e-2
@ -76,7 +80,7 @@
@testset "SAut(F₂)" begin @testset "SAut(F₂)" begin
N = 2 N = 2
G = SpecialAutomorphismGroup(FreeGroup(N)) G = SpecialAutomorphismGroup(FreeGroup(N))
RG, S, sizes = PropertyT.group_algebra(G, halfradius=2, twisted=true) RG, S, sizes = PropertyT.group_algebra(G; halfradius = 2)
Δ = let RG = RG, S = S Δ = let RG = RG, S = S
RG(length(S)) - sum(RG(s) for s in S) RG(length(S)) - sum(RG(s) for s in S)
@ -88,53 +92,46 @@
status, certified, λ = check_positivity( status, certified, λ = check_positivity(
elt, elt,
unit, unit;
upper_bound=ub, upper_bound = ub,
halfradius=2, halfradius = 2,
optimizer=scs_optimizer( optimizer = scs_optimizer(;
eps=1e-10, eps = 1e-10,
max_iters=5_000, max_iters = 5_000,
accel=50, accel = 50,
alpha=1.9, alpha = 1.9,
) ),
) )
@test status == JuMP.ALMOST_OPTIMAL @test status == JuMP.ALMOST_OPTIMAL
@test λ < 0 @test λ < 0
@test !certified @test !certified
@time sos_problem = @time sos_problem = PropertyT.sos_problem_primal(elt; upper_bound = ub)
PropertyT.sos_problem_primal(elt, upper_bound=ub)
status, _ = PropertyT.solve( status, _ = PropertyT.solve(
sos_problem, sos_problem,
cosmo_optimizer( cosmo_optimizer(;
eps=1e-7, eps = 1e-7,
max_iters=10_000, max_iters = 10_000,
accel=0, accel = 0,
alpha=1.9, alpha = 1.9,
) ),
) )
@test status == JuMP.OPTIMAL @test status == JuMP.OPTIMAL
P = JuMP.value.(sos_problem[:P]) P = JuMP.value.(sos_problem[:P])
Q = real.(sqrt(P)) Q = real.(sqrt(P))
certified, λ_cert = PropertyT.certify_solution( certified, λ_cert =
elt, PropertyT.certify_solution(elt, zero(elt), 0.0, Q; halfradius = 2)
zero(elt),
0.0,
Q,
halfradius=2,
)
@test !certified @test !certified
@test λ_cert < 0 @test λ_cert < 0
end end
@testset "SL(3,Z) has (T)" begin @testset "SL(3,Z) has (T)" begin
n = 3 n = 3
SL = MatrixGroups.SpecialLinearGroup{n}(Int8) SL = MatrixGroups.SpecialLinearGroup{n}(Int8)
RSL, S, sizes = PropertyT.group_algebra(SL, halfradius=2, twisted=true) RSL, S, sizes = PropertyT.group_algebra(SL; halfradius = 2)
Δ = RSL(length(S)) - sum(RSL(s) for s in S) Δ = RSL(length(S)) - sum(RSL(s) for s in S)
@ -145,18 +142,18 @@
opt_problem = PropertyT.sos_problem_primal( opt_problem = PropertyT.sos_problem_primal(
elt, elt,
unit, unit;
upper_bound=ub, upper_bound = ub,
augmented=false, augmented = false,
) )
status, _ = PropertyT.solve( status, _ = PropertyT.solve(
opt_problem, opt_problem,
cosmo_optimizer( cosmo_optimizer(;
eps=1e-10, eps = 1e-10,
max_iters=10_000, max_iters = 10_000,
accel=0, accel = 0,
alpha=1.5, alpha = 1.5,
), ),
) )
@ -170,13 +167,13 @@
elt, elt,
unit, unit,
λ, λ,
Q, Q;
halfradius=2, halfradius = 2,
augmented=false, augmented = false,
) )
@test certified @test certified
@test isapprox(λ_cert, λ, rtol=1e-5) @test isapprox(λ_cert, λ, rtol = 1e-5)
end end
@testset "augmented formulation" begin @testset "augmented formulation" begin
@ -186,18 +183,18 @@
opt_problem = PropertyT.sos_problem_primal( opt_problem = PropertyT.sos_problem_primal(
elt, elt,
unit, unit;
upper_bound=ub, upper_bound = ub,
augmented=true, augmented = true,
) )
status, _ = PropertyT.solve( status, _ = PropertyT.solve(
opt_problem, opt_problem,
scs_optimizer( scs_optimizer(;
eps=1e-10, eps = 1e-10,
max_iters=10_000, max_iters = 10_000,
accel=-10, accel = -10,
alpha=1.5, alpha = 1.5,
), ),
) )
@ -210,13 +207,13 @@
elt, elt,
unit, unit,
λ, λ,
Q, Q;
halfradius=2, halfradius = 2,
augmented=true, augmented = true,
) )
@test certified @test certified
@test isapprox(λ_cert, λ, rtol=1e-5) @test isapprox(λ_cert, λ, rtol = 1e-5)
@test λ_cert > 2 // 10 @test λ_cert > 2 // 10
end end
end end

View File

@ -1,9 +1,9 @@
@testset "1712.07167 Examples" begin @testset "1712.07167 Examples" begin
@testset "SAut(F₃)" begin @testset "SAut(F₃)" begin
N = 3 N = 3
G = SpecialAutomorphismGroup(FreeGroup(N)) G = SpecialAutomorphismGroup(FreeGroup(N))
RG, S, sizes = PropertyT.group_algebra(G, halfradius=2, twisted=true) @info "running tests for" G
RG, S, sizes = PropertyT.group_algebra(G; halfradius = 2)
P = PermGroup(perm"(1,2)", Perm(circshift(1:N, -1))) P = PermGroup(perm"(1,2)", Perm(circshift(1:N, -1)))
Σ = PropertyT.Constructions.WreathProduct(PermGroup(perm"(1,2)"), P) Σ = PropertyT.Constructions.WreathProduct(PermGroup(perm"(1,2)"), P)
@ -15,6 +15,7 @@
basis(RG), basis(RG),
StarAlgebras.Basis{UInt16}(@view basis(RG)[1:sizes[2]]), StarAlgebras.Basis{UInt16}(@view basis(RG)[1:sizes[2]]),
) )
@info wd
Δ = let RG = RG, S = S Δ = let RG = RG, S = S
RG(length(S)) - sum(RG(s) for s in S) RG(length(S)) - sum(RG(s) for s in S)
@ -27,14 +28,14 @@
status, certified, λ_cert = check_positivity( status, certified, λ_cert = check_positivity(
elt, elt,
unit, unit,
wd, wd;
upper_bound=ub, upper_bound = ub,
halfradius=2, halfradius = 2,
optimizer=cosmo_optimizer( optimizer = cosmo_optimizer(;
eps=1e-7, eps = 1e-7,
max_iters=10_000, max_iters = 10_000,
accel=50, accel = 50,
alpha=1.9, alpha = 1.9,
), ),
) )
@ -47,7 +48,8 @@
n = 3 n = 3
SL = MatrixGroups.SpecialLinearGroup{n}(Int8) SL = MatrixGroups.SpecialLinearGroup{n}(Int8)
RSL, S, sizes = PropertyT.group_algebra(SL, halfradius=2, twisted=true) @info "running tests for" SL
RSL, S, sizes = PropertyT.group_algebra(SL; halfradius = 2)
Δ = RSL(length(S)) - sum(RSL(s) for s in S) Δ = RSL(length(S)) - sum(RSL(s) for s in S)
@ -62,6 +64,7 @@
basis(RSL), basis(RSL),
StarAlgebras.Basis{UInt16}(@view basis(RSL)[1:sizes[2]]), StarAlgebras.Basis{UInt16}(@view basis(RSL)[1:sizes[2]]),
) )
@info wd
elt = Δ^2 elt = Δ^2
unit = Δ unit = Δ
@ -71,8 +74,8 @@
elt, elt,
unit, unit,
wd, wd,
upper_bound=ub, upper_bound = ub,
augmented=false, augmented = false,
) )
wdfl = SymbolicWedderburn.WedderburnDecomposition( wdfl = SymbolicWedderburn.WedderburnDecomposition(
@ -86,18 +89,18 @@
model, varP = PropertyT.sos_problem_primal( model, varP = PropertyT.sos_problem_primal(
elt, elt,
unit, unit,
wdfl, wdfl;
upper_bound=ub, upper_bound = ub,
augmented=false, augmented = false,
) )
status, warm = PropertyT.solve( status, warm = PropertyT.solve(
model, model,
cosmo_optimizer( cosmo_optimizer(;
eps=1e-10, eps = 1e-10,
max_iters=20_000, max_iters = 20_000,
accel=50, accel = 50,
alpha=1.9, alpha = 1.9,
), ),
) )
@ -105,34 +108,34 @@
status, _ = PropertyT.solve( status, _ = PropertyT.solve(
model, model,
scs_optimizer( scs_optimizer(;
eps=1e-10, eps = 1e-10,
max_iters=100, max_iters = 100,
accel=-20, accel = -20,
alpha=1.2, alpha = 1.2,
), ),
warm warm,
) )
@test status == JuMP.OPTIMAL @test status == JuMP.OPTIMAL
Q = @time let varP = varP Q = @time let varP = varP
Qs = map(varP) do P Qs = map(varP) do P
real.(sqrt(JuMP.value.(P))) return real.(sqrt(JuMP.value.(P)))
end end
PropertyT.reconstruct(Qs, wdfl) PropertyT.reconstruct(Qs, wdfl)
end end
λ = JuMP.value(model[]) λ = JuMP.value(model[])
sos = PropertyT.compute_sos(parent(elt), Q; augmented=false) sos = PropertyT.compute_sos(parent(elt), Q; augmented = false)
certified, λ_cert = PropertyT.certify_solution( certified, λ_cert = PropertyT.certify_solution(
elt, elt,
unit, unit,
λ, λ,
Q, Q;
halfradius=2, halfradius = 2,
augmented=false, augmented = false,
) )
@test certified @test certified
@ -155,22 +158,23 @@
basis(RSL), basis(RSL),
StarAlgebras.Basis{UInt16}(@view basis(RSL)[1:sizes[2]]), StarAlgebras.Basis{UInt16}(@view basis(RSL)[1:sizes[2]]),
) )
@info wdfl
opt_problem, varP = PropertyT.sos_problem_primal( opt_problem, varP = PropertyT.sos_problem_primal(
elt, elt,
unit, unit,
wdfl, wdfl;
upper_bound=ub, upper_bound = ub,
# augmented = true # since both elt and unit are augmented # augmented = true # since both elt and unit are augmented
) )
status, _ = PropertyT.solve( status, _ = PropertyT.solve(
opt_problem, opt_problem,
scs_optimizer( scs_optimizer(;
eps=1e-8, eps = 1e-8,
max_iters=20_000, max_iters = 20_000,
accel=0, accel = 0,
alpha=1.9, alpha = 1.9,
), ),
) )
@ -178,7 +182,7 @@
Q = @time let varP = varP Q = @time let varP = varP
Qs = map(varP) do P Qs = map(varP) do P
real.(sqrt(JuMP.value.(P))) return real.(sqrt(JuMP.value.(P)))
end end
PropertyT.reconstruct(Qs, wdfl) PropertyT.reconstruct(Qs, wdfl)
end end
@ -187,8 +191,8 @@
elt, elt,
unit, unit,
JuMP.objective_value(opt_problem), JuMP.objective_value(opt_problem),
Q, Q;
halfradius=2, halfradius = 2,
# augmented = true # since both elt and unit are augmented # augmented = true # since both elt and unit are augmented
) )

View File

@ -21,8 +21,9 @@ using SparseArrays
@testset "Sq, Adj, Op in SL(4,Z)" begin @testset "Sq, Adj, Op in SL(4,Z)" begin
N = 4 N = 4
G = MatrixGroups.SpecialLinearGroup{N}(Int8) G = MatrixGroups.SpecialLinearGroup{N}(Int8)
@info "running tests for" G
RG, S, sizes = PropertyT.group_algebra(G, halfradius=2, twisted=true) RG, S, sizes = PropertyT.group_algebra(G; halfradius = 2)
Δ = let RG = RG, S = S Δ = let RG = RG, S = S
RG(length(S)) - sum(RG(s) for s in S) RG(length(S)) - sum(RG(s) for s in S)
@ -39,6 +40,7 @@ using SparseArrays
basis(RG), basis(RG),
StarAlgebras.Basis{UInt16}(@view basis(RG)[1:sizes[2]]), StarAlgebras.Basis{UInt16}(@view basis(RG)[1:sizes[2]]),
) )
@info wd
ivs = SymbolicWedderburn.invariant_vectors(wd) ivs = SymbolicWedderburn.invariant_vectors(wd)
sq, adj, op = PropertyT.SqAdjOp(RG, N) sq, adj, op = PropertyT.SqAdjOp(RG, N)
@ -82,7 +84,7 @@ using SparseArrays
@testset "SAut(F₃)" begin @testset "SAut(F₃)" begin
n = 3 n = 3
G = SpecialAutomorphismGroup(FreeGroup(n)) G = SpecialAutomorphismGroup(FreeGroup(n))
RG, S, sizes = PropertyT.group_algebra(G, halfradius=2, twisted=true) RG, S, sizes = PropertyT.group_algebra(G; halfradius = 2)
sq, adj, op = PropertyT.SqAdjOp(RG, n) sq, adj, op = PropertyT.SqAdjOp(RG, n)
@test sq(one(G)) == 216 @test sq(one(G)) == 216
@ -98,7 +100,8 @@ end
n = 3 n = 3
G = MatrixGroups.SpecialLinearGroup{n}(Int8) G = MatrixGroups.SpecialLinearGroup{n}(Int8)
RG, S, sizes = PropertyT.group_algebra(G, halfradius=2, twisted=true) @info "running tests for" G
RG, S, sizes = PropertyT.group_algebra(G; halfradius = 2)
Δ = RG(length(S)) - sum(RG(s) for s in S) Δ = RG(length(S)) - sum(RG(s) for s in S)
@ -113,6 +116,7 @@ end
basis(RG), basis(RG),
StarAlgebras.Basis{UInt16}(@view basis(RG)[1:sizes[2]]), StarAlgebras.Basis{UInt16}(@view basis(RG)[1:sizes[2]]),
) )
@info wd
sq, adj, op = PropertyT.SqAdjOp(RG, n) sq, adj, op = PropertyT.SqAdjOp(RG, n)
@ -123,10 +127,10 @@ end
status, certified, λ_cert = check_positivity( status, certified, λ_cert = check_positivity(
elt, elt,
Δ, Δ,
wd, wd;
upper_bound=UB, upper_bound = UB,
halfradius=2, halfradius = 2,
optimizer=cosmo_optimizer(accel=50, alpha=1.9) optimizer = cosmo_optimizer(; accel = 50, alpha = 1.9),
) )
@test status == JuMP.OPTIMAL @test status == JuMP.OPTIMAL
@test certified @test certified
@ -140,10 +144,10 @@ end
status, certified, λ_cert = check_positivity( status, certified, λ_cert = check_positivity(
elt, elt,
Δ, Δ,
wd, wd;
upper_bound=UB, upper_bound = UB,
halfradius=2, halfradius = 2,
optimizer=cosmo_optimizer(accel=50, alpha=1.9) optimizer = cosmo_optimizer(; accel = 50, alpha = 1.9),
) )
@test status == JuMP.OPTIMAL @test status == JuMP.OPTIMAL
@test certified @test certified
@ -152,10 +156,11 @@ end
m, _ = PropertyT.sos_problem_primal(elt, wd) m, _ = PropertyT.sos_problem_primal(elt, wd)
PropertyT.solve( PropertyT.solve(
m, m,
scs_optimizer(max_iters=5000, accel=50, alpha=1.9) scs_optimizer(; max_iters = 5000, accel = 50, alpha = 1.9),
) )
@test JuMP.termination_status(m) in (JuMP.ALMOST_OPTIMAL, JuMP.OPTIMAL, JuMP.ITERATION_LIMIT) @test JuMP.termination_status(m) in
(JuMP.ALMOST_OPTIMAL, JuMP.OPTIMAL, JuMP.ITERATION_LIMIT)
@test abs(JuMP.objective_value(m)) < 1e-3 @test abs(JuMP.objective_value(m)) < 1e-3
end end
@ -168,10 +173,10 @@ end
status, certified, λ_cert = check_positivity( status, certified, λ_cert = check_positivity(
elt, elt,
Δ, Δ,
wd, wd;
upper_bound=UB, upper_bound = UB,
halfradius=2, halfradius = 2,
optimizer=cosmo_optimizer(accel=50, alpha=1.9) optimizer = cosmo_optimizer(; accel = 50, alpha = 1.9),
) )
@test status == JuMP.OPTIMAL @test status == JuMP.OPTIMAL
@test !certified @test !certified
@ -183,7 +188,8 @@ end
n = 4 n = 4
G = MatrixGroups.SpecialLinearGroup{n}(Int8) G = MatrixGroups.SpecialLinearGroup{n}(Int8)
RG, S, sizes = PropertyT.group_algebra(G, halfradius=2, twisted=true) @info "running tests for" G
RG, S, sizes = PropertyT.group_algebra(G; halfradius = 2)
Δ = RG(length(S)) - sum(RG(s) for s in S) Δ = RG(length(S)) - sum(RG(s) for s in S)
@ -198,6 +204,7 @@ end
basis(RG), basis(RG),
StarAlgebras.Basis{UInt16}(@view basis(RG)[1:sizes[2]]), StarAlgebras.Basis{UInt16}(@view basis(RG)[1:sizes[2]]),
) )
@info wd
sq, adj, op = PropertyT.SqAdjOp(RG, n) sq, adj, op = PropertyT.SqAdjOp(RG, n)
@ -208,10 +215,10 @@ end
status, certified, λ_cert = check_positivity( status, certified, λ_cert = check_positivity(
elt, elt,
Δ, Δ,
wd, wd;
upper_bound=UB, upper_bound = UB,
halfradius=2, halfradius = 2,
optimizer=cosmo_optimizer(accel=50, alpha=1.9) optimizer = cosmo_optimizer(; accel = 50, alpha = 1.9),
) )
@test status == JuMP.OPTIMAL @test status == JuMP.OPTIMAL
@test certified @test certified
@ -225,10 +232,10 @@ end
status, certified, λ_cert = check_positivity( status, certified, λ_cert = check_positivity(
elt, elt,
Δ, Δ,
wd, wd;
upper_bound=UB, upper_bound = UB,
halfradius=2, halfradius = 2,
optimizer=cosmo_optimizer(accel=50, alpha=1.9) optimizer = cosmo_optimizer(; accel = 50, alpha = 1.9),
) )
@test status == JuMP.OPTIMAL @test status == JuMP.OPTIMAL
@test certified @test certified
@ -242,10 +249,10 @@ end
status, certified, λ_cert = check_positivity( status, certified, λ_cert = check_positivity(
elt, elt,
Δ, Δ,
wd, wd;
upper_bound=UB, upper_bound = UB,
halfradius=2, halfradius = 2,
optimizer=cosmo_optimizer(accel=50, alpha=1.9) optimizer = cosmo_optimizer(; accel = 50, alpha = 1.9),
) )
@test status == JuMP.OPTIMAL @test status == JuMP.OPTIMAL
@test !certified @test !certified

168
test/Chevalley.jl Normal file
View File

@ -0,0 +1,168 @@
countmap(v) = countmap(identity, v)
function countmap(f, v)
counts = Dict{eltype(f(first(v))),Int}()
for x in v
fx = f(x)
counts[fx] = get!(counts, fx, 0) + 1
end
return counts
end
@testset "classify_root_system" begin
α = PropertyT.Roots.Root([1, -1, 0])
β = PropertyT.Roots.Root([0, 1, -1])
γ = PropertyT.Roots.Root([2, 0, 0])
@test PropertyT.Roots.classify_root_system(α, β, (false, false)) == :A₂
@test PropertyT.Roots.classify_root_system(α, γ, (false, true)) == :C₂
@test PropertyT.Roots.classify_root_system(β, γ, (false, true)) ==
Symbol("A₁×C₁")
end
@testset "Exceptional root systems" begin
@testset "F4" begin
F4 = let Σ = PermutationGroups.PermGroup(perm"(1,2,3,4)", perm"(1,2)")
long = let x = (1.0, 1.0, 0.0, 0.0)
PropertyT.Roots.Root.(
union(
(x^g for g in Σ),
((x .* (-1, 1, 1, 1))^g for g in Σ),
((-1 .* x)^g for g in Σ),
),
)
end
short = let x = (1.0, 0.0, 0.0, 0.0)
PropertyT.Roots.Root.(
union((x^g for g in Σ), ((-1 .* x)^g for g in Σ))
)
end
signs = collect(Iterators.product(fill([-1, +1], 4)...))
halfs = let x = 1 / 2 .* (1.0, 1.0, 1.0, 1.0)
PropertyT.Roots.Root.(union(x .* sgn for sgn in signs))
end
union(long, short, halfs)
end
@test length(F4) == 48
a = F4[1]
@test isapprox(length(a), sqrt(2))
b = F4[6]
@test isapprox(length(b), sqrt(2))
c = a + b
@test isapprox(length(c), 2.0)
@test PropertyT.Roots.classify_root_system(b, c, (false, true)) == :C₂
long = F4[findfirst(r -> length(r) == sqrt(2), F4)]
short = F4[findfirst(r -> length(r) == 1.0, F4)]
subtypes = Set([:C₂, :A₂, Symbol("A₁×C₁")])
let Ω = F4, α = long
counts = countmap([
PropertyT.Roots.classify_sub_root_system(Ω, α, γ) for
γ in Ω if !PropertyT.Roots.isproportional(α, γ)
])
@test Set(keys(counts)) == subtypes
d, r = divrem(counts[:C₂], 6)
@test r == 0 && d == 3
d, r = divrem(counts[:A₂], 4)
@test r == 0 && d == 4
end
let Ω = F4, α = short
counts = countmap([
PropertyT.Roots.classify_sub_root_system(Ω, α, γ) for
γ in Ω if !PropertyT.Roots.isproportional(α, γ)
])
@test Set(keys(counts)) == subtypes
d, r = divrem(counts[:C₂], 6)
@test r == 0 && d == 3
d, r = divrem(counts[:A₂], 4)
@test r == 0 && d == 4
end
end
@testset "E6-7-8 exceptional root systems" begin
E8 =
let Σ = PermutationGroups.PermGroup(
perm"(1,2,3,4,5,6,7,8)",
perm"(1,2)",
)
long = let x = (1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
PropertyT.Roots.Root.(
union(
(x^g for g in Σ),
((x .* (-1, 1, 1, 1, 1, 1, 1, 1))^g for g in Σ),
((-1 .* x)^g for g in Σ),
),
)
end
signs = collect(
p for p in Iterators.product(fill([-1, +1], 8)...) if
iseven(count(==(-1), p))
)
halfs = let x = 1 / 2 .* ntuple(i -> 1.0, 8)
rts = unique(PropertyT.Roots.Root(x .* sgn) for sgn in signs)
end
union(long, halfs)
end
subtypes = Set([:A₂, Symbol("A₁×A₁")])
@testset "E8" begin
@test length(E8) == 240
@test all(r -> length(r) sqrt(2), E8)
let Ω = E8, α = first(Ω)
counts = countmap([
PropertyT.Roots.classify_sub_root_system(Ω, α, γ) for
γ in Ω if !PropertyT.Roots.isproportional(α, γ)
])
@test Set(keys(counts)) == subtypes
d, r = divrem(counts[:A₂], 4)
@test r == 0 && d == 28
end
end
@testset "E7" begin
E7 = filter(r -> iszero(sum(r.coord)), E8)
@test length(E7) == 126
let Ω = E7, α = first(Ω)
counts = countmap([
PropertyT.Roots.classify_sub_root_system(Ω, α, γ) for
γ in Ω if !PropertyT.Roots.isproportional(α, γ)
])
@test Set(keys(counts)) == subtypes
d, r = divrem(counts[:A₂], 4)
@test r == 0 && d == 16
end
end
@testset "E6" begin
E6 = filter(
r -> r.coord[end] == r.coord[end-1] == r.coord[end-2],
E8,
)
@test length(E6) == 72
let Ω = E6, α = first(Ω)
counts = countmap([
PropertyT.Roots.classify_sub_root_system(Ω, α, γ) for
γ in Ω if !PropertyT.Roots.isproportional(α, γ)
])
@test Set(keys(counts)) == subtypes
d, r = divrem(counts[:A₂], 4)
@info d, r
@test r == 0 && d == 10
end
end
end
end

View File

@ -3,7 +3,7 @@ function test_action(basis, group, act)
return @testset "action definition" begin return @testset "action definition" begin
@test all(basis) do b @test all(basis) do b
e = one(group) e = one(group)
action(act, e, b) == b return action(act, e, b) == b
end end
a = let a = rand(basis) a = let a = rand(basis)
@ -30,12 +30,12 @@ function test_action(basis, group, act)
@test all([(g, h) for g in group for h in group]) do (g, h) @test all([(g, h) for g in group for h in group]) do (g, h)
x = action(act, h, action(act, g, a)) x = action(act, h, action(act, g, a))
y = action(act, g * h, a) y = action(act, g * h, a)
x == y return x == y
end end
if act isa SymbolicWedderburn.ByPermutations if act isa SymbolicWedderburn.ByPermutations
@test all(basis) do b @test all(basis) do b
action(act, g, b) basis && action(act, h, b) basis return action(act, g, b) basis && action(act, h, b) basis
end end
end end
end end
@ -44,21 +44,18 @@ end
## Testing ## Testing
@testset "Actions on SL(3,)" begin @testset "Actions on SL(3,)" begin
n = 3 n = 3
SL = MatrixGroups.SpecialLinearGroup{n}(Int8) SL = MatrixGroups.SpecialLinearGroup{n}(Int8)
RSL, S, sizes = PropertyT.group_algebra(SL, halfradius=2, twisted=true) RSL, S, sizes = PropertyT.group_algebra(SL; halfradius = 2)
@testset "Permutation action" begin @testset "Permutation action" begin
Γ = PermGroup(perm"(1,2)", Perm(circshift(1:n, -1))) Γ = PermGroup(perm"(1,2)", Perm(circshift(1:n, -1)))
ΓpA = PropertyT.action_by_conjugation(SL, Γ) ΓpA = PropertyT.action_by_conjugation(SL, Γ)
test_action(basis(RSL), Γ, ΓpA) test_action(basis(RSL), Γ, ΓpA)
@testset "mps is successful" begin @testset "mps is successful" begin
charsΓ = charsΓ =
SymbolicWedderburn.Character{ SymbolicWedderburn.Character{
Rational{Int}, Rational{Int},
@ -66,9 +63,9 @@ end
= SymbolicWedderburn._group_algebra(Γ) = SymbolicWedderburn._group_algebra(Γ)
@time mps, simple = @time mps, ranks =
SymbolicWedderburn.minimal_projection_system(charsΓ, ) SymbolicWedderburn.minimal_projection_system(charsΓ, )
@test all(simple) @test all(isone, ranks)
end end
@testset "Wedderburn decomposition" begin @testset "Wedderburn decomposition" begin
@ -77,17 +74,17 @@ end
Γ, Γ,
ΓpA, ΓpA,
basis(RSL), basis(RSL),
StarAlgebras.Basis{UInt16}(@view basis(RSL)[1:sizes[2]]) StarAlgebras.Basis{UInt16}(@view basis(RSL)[1:sizes[2]]),
) )
@test length(invariant_vectors(wd)) == 918 @test length(invariant_vectors(wd)) == 918
@test SymbolicWedderburn.size.(direct_summands(wd), 1) == [40, 23, 18] @test SymbolicWedderburn.size.(direct_summands(wd), 1) ==
[40, 23, 18]
@test all(issimple, direct_summands(wd)) @test all(issimple, direct_summands(wd))
end end
end end
@testset "Wreath action" begin @testset "Wreath action" begin
Γ = let P = PermGroup(perm"(1,2)", Perm(circshift(1:n, -1))) Γ = let P = PermGroup(perm"(1,2)", Perm(circshift(1:n, -1)))
PropertyT.Constructions.WreathProduct(PermGroup(perm"(1,2)"), P) PropertyT.Constructions.WreathProduct(PermGroup(perm"(1,2)"), P)
end end
@ -97,7 +94,6 @@ end
test_action(basis(RSL), Γ, ΓpA) test_action(basis(RSL), Γ, ΓpA)
@testset "mps is successful" begin @testset "mps is successful" begin
charsΓ = charsΓ =
SymbolicWedderburn.Character{ SymbolicWedderburn.Character{
Rational{Int}, Rational{Int},
@ -105,9 +101,9 @@ end
= SymbolicWedderburn._group_algebra(Γ) = SymbolicWedderburn._group_algebra(Γ)
@time mps, simple = @time mps, ranks =
SymbolicWedderburn.minimal_projection_system(charsΓ, ) SymbolicWedderburn.minimal_projection_system(charsΓ, )
@test all(simple) @test all(isone, ranks)
end end
@testset "Wedderburn decomposition" begin @testset "Wedderburn decomposition" begin
@ -116,32 +112,30 @@ end
Γ, Γ,
ΓpA, ΓpA,
basis(RSL), basis(RSL),
StarAlgebras.Basis{UInt16}(@view basis(RSL)[1:sizes[2]]) StarAlgebras.Basis{UInt16}(@view basis(RSL)[1:sizes[2]]),
) )
@test length(invariant_vectors(wd)) == 247 @test length(invariant_vectors(wd)) == 247
@test SymbolicWedderburn.size.(direct_summands(wd), 1) == [14, 9, 6, 14, 12] @test SymbolicWedderburn.size.(direct_summands(wd), 1) ==
[14, 9, 6, 14, 12]
@test all(issimple, direct_summands(wd)) @test all(issimple, direct_summands(wd))
end end
end end
end end
@testset "Actions on SAut(F4)" begin @testset "Actions on SAut(F4)" begin
n = 4 n = 4
SAutFn = SpecialAutomorphismGroup(FreeGroup(n)) SAutFn = SpecialAutomorphismGroup(FreeGroup(n))
RSAutFn, S, sizes = PropertyT.group_algebra(SAutFn, halfradius=1, twisted=true) RSAutFn, S, sizes = PropertyT.group_algebra(SAutFn; halfradius = 1)
@testset "Permutation action" begin @testset "Permutation action" begin
Γ = PermGroup(perm"(1,2)", Perm(circshift(1:n, -1))) Γ = PermGroup(perm"(1,2)", Perm(circshift(1:n, -1)))
ΓpA = PropertyT.action_by_conjugation(SAutFn, Γ) ΓpA = PropertyT.action_by_conjugation(SAutFn, Γ)
test_action(basis(RSAutFn), Γ, ΓpA) test_action(basis(RSAutFn), Γ, ΓpA)
@testset "mps is successful" begin @testset "mps is successful" begin
charsΓ = charsΓ =
SymbolicWedderburn.Character{ SymbolicWedderburn.Character{
Rational{Int}, Rational{Int},
@ -149,9 +143,9 @@ end
= SymbolicWedderburn._group_algebra(Γ) = SymbolicWedderburn._group_algebra(Γ)
@time mps, simple = @time mps, ranks =
SymbolicWedderburn.minimal_projection_system(charsΓ, ) SymbolicWedderburn.minimal_projection_system(charsΓ, )
@test all(simple) @test all(isone, ranks)
end end
@testset "Wedderburn decomposition" begin @testset "Wedderburn decomposition" begin
@ -160,17 +154,17 @@ end
Γ, Γ,
ΓpA, ΓpA,
basis(RSAutFn), basis(RSAutFn),
StarAlgebras.Basis{UInt16}(@view basis(RSAutFn)[1:sizes[1]]) StarAlgebras.Basis{UInt16}(@view basis(RSAutFn)[1:sizes[1]]),
) )
@test length(invariant_vectors(wd)) == 93 @test length(invariant_vectors(wd)) == 93
@test SymbolicWedderburn.size.(direct_summands(wd), 1) == [4, 8, 5, 4] @test SymbolicWedderburn.size.(direct_summands(wd), 1) ==
[4, 8, 5, 4]
@test all(issimple, direct_summands(wd)) @test all(issimple, direct_summands(wd))
end end
end end
@testset "Wreath action" begin @testset "Wreath action" begin
Γ = let P = PermGroup(perm"(1,2)", Perm(circshift(1:n, -1))) Γ = let P = PermGroup(perm"(1,2)", Perm(circshift(1:n, -1)))
PropertyT.Constructions.WreathProduct(PermGroup(perm"(1,2)"), P) PropertyT.Constructions.WreathProduct(PermGroup(perm"(1,2)"), P)
end end
@ -180,7 +174,6 @@ end
test_action(basis(RSAutFn), Γ, ΓpA) test_action(basis(RSAutFn), Γ, ΓpA)
@testset "mps is successful" begin @testset "mps is successful" begin
charsΓ = charsΓ =
SymbolicWedderburn.Character{ SymbolicWedderburn.Character{
Rational{Int}, Rational{Int},
@ -188,9 +181,9 @@ end
= SymbolicWedderburn._group_algebra(Γ) = SymbolicWedderburn._group_algebra(Γ)
@time mps, simple = @time mps, ranks =
SymbolicWedderburn.minimal_projection_system(charsΓ, ) SymbolicWedderburn.minimal_projection_system(charsΓ, )
@test all(simple) @test all(isone, ranks)
end end
@testset "Wedderburn decomposition" begin @testset "Wedderburn decomposition" begin
@ -199,11 +192,12 @@ end
Γ, Γ,
ΓpA, ΓpA,
basis(RSAutFn), basis(RSAutFn),
StarAlgebras.Basis{UInt16}(@view basis(RSAutFn)[1:sizes[1]]) StarAlgebras.Basis{UInt16}(@view basis(RSAutFn)[1:sizes[1]]),
) )
@test length(invariant_vectors(wd)) == 18 @test length(invariant_vectors(wd)) == 18
@test SymbolicWedderburn.size.(direct_summands(wd), 1) == [1, 1, 2, 2, 1, 2, 2, 1] @test SymbolicWedderburn.size.(direct_summands(wd), 1) ==
[1, 1, 2, 2, 1, 2, 2, 1]
@test all(issimple, direct_summands(wd)) @test all(issimple, direct_summands(wd))
end end
end end

View File

@ -1,6 +1,12 @@
function check_positivity(elt, unit; upper_bound=Inf, halfradius=2, optimizer) function check_positivity(
elt,
unit;
upper_bound = Inf,
halfradius = 2,
optimizer,
)
@time sos_problem = @time sos_problem =
PropertyT.sos_problem_primal(elt, unit, upper_bound=upper_bound) PropertyT.sos_problem_primal(elt, unit; upper_bound = upper_bound)
status, _ = PropertyT.solve(sos_problem, optimizer) status, _ = PropertyT.solve(sos_problem, optimizer)
P = JuMP.value.(sos_problem[:P]) P = JuMP.value.(sos_problem[:P])
@ -9,16 +15,23 @@ function check_positivity(elt, unit; upper_bound=Inf, halfradius=2, optimizer)
elt, elt,
unit, unit,
JuMP.objective_value(sos_problem), JuMP.objective_value(sos_problem),
Q, Q;
halfradius=halfradius, halfradius = halfradius,
) )
return status, certified, λ_cert return status, certified, λ_cert
end end
function check_positivity(elt, unit, wd; upper_bound=Inf, halfradius=2, optimizer) function check_positivity(
elt,
unit,
wd;
upper_bound = Inf,
halfradius = 2,
optimizer,
)
@assert aug(elt) == aug(unit) == 0 @assert aug(elt) == aug(unit) == 0
@time sos_problem, Ps = @time sos_problem, Ps =
PropertyT.sos_problem_primal(elt, unit, wd, upper_bound=upper_bound) PropertyT.sos_problem_primal(elt, unit, wd; upper_bound = upper_bound)
@time status, _ = PropertyT.solve(sos_problem, optimizer) @time status, _ = PropertyT.solve(sos_problem, optimizer)
@ -29,13 +42,7 @@ function check_positivity(elt, unit, wd; upper_bound=Inf, halfradius=2, optimize
λ = JuMP.value(sos_problem[]) λ = JuMP.value(sos_problem[])
certified, λ_cert = PropertyT.certify_solution( certified, λ_cert =
elt, PropertyT.certify_solution(elt, unit, λ, Q; halfradius = halfradius)
unit,
λ,
Q,
halfradius=halfradius
)
return status, certified, λ_cert return status, certified, λ_cert
end end

View File

@ -1,10 +1,9 @@
@testset "Adj via grading" begin @testset "Adj via grading" begin
@testset "SL(n,Z) & Aut(F₄)" begin @testset "SL(n,Z) & Aut(F₄)" begin
n = 4 n = 4
halfradius = 1 halfradius = 1
SL = MatrixGroups.SpecialLinearGroup{n}(Int8) SL = MatrixGroups.SpecialLinearGroup{n}(Int8)
RSL, S, sizes = PropertyT.group_algebra(SL, halfradius=halfradius, twisted=true) RSL, S, sizes = PropertyT.group_algebra(SL; halfradius = halfradius)
Δ = RSL(length(S)) - sum(RSL(s) for s in S) Δ = RSL(length(S)) - sum(RSL(s) for s in S)
@ -22,10 +21,9 @@
@test PropertyT.Adj(Δs, :A₂) == adj @test PropertyT.Adj(Δs, :A₂) == adj
@test PropertyT.Adj(Δs, Symbol("A₁×A₁")) == op @test PropertyT.Adj(Δs, Symbol("A₁×A₁")) == op
halfradius = 1 halfradius = 1
G = SpecialAutomorphismGroup(FreeGroup(n)) G = SpecialAutomorphismGroup(FreeGroup(n))
RG, S, sizes = PropertyT.group_algebra(G, halfradius=halfradius, twisted=true) RG, S, sizes = PropertyT.group_algebra(G; halfradius = halfradius)
Δ = RG(length(S)) - sum(RG(s) for s in S) Δ = RG(length(S)) - sum(RG(s) for s in S)
@ -44,7 +42,6 @@
@test PropertyT.Adj(Δs, Symbol("A₁×A₁")) == op @test PropertyT.Adj(Δs, Symbol("A₁×A₁")) == op
end end
@testset "Symplectic group" begin @testset "Symplectic group" begin
@testset "Sp2()" begin @testset "Sp2()" begin
genus = 2 genus = 2
@ -52,7 +49,8 @@
SpN = MatrixGroups.SymplecticGroup{2genus}(Int8) SpN = MatrixGroups.SymplecticGroup{2genus}(Int8)
RSpN, S_sp, sizes_sp = PropertyT.group_algebra(SpN, halfradius=halfradius, twisted=true) RSpN, S_sp, sizes_sp =
PropertyT.group_algebra(SpN; halfradius = halfradius)
Δ, Δs = let RG = RSpN, S = S_sp, ψ = identity Δ, Δs = let RG = RSpN, S = S_sp, ψ = identity
Δ = RG(length(S)) - sum(RG(s) for s in S) Δ = RG(length(S)) - sum(RG(s) for s in S)
@ -73,7 +71,8 @@
SpN = MatrixGroups.SymplecticGroup{2genus}(Int8) SpN = MatrixGroups.SymplecticGroup{2genus}(Int8)
RSpN, S_sp, sizes_sp = PropertyT.group_algebra(SpN, halfradius=halfradius, twisted=true) RSpN, S_sp, sizes_sp =
PropertyT.group_algebra(SpN; halfradius = halfradius)
Δ, Δs = let RG = RSpN, S = S_sp, ψ = identity Δ, Δs = let RG = RSpN, S = S_sp, ψ = identity
Δ = RG(length(S)) - sum(RG(s) for s in S) Δ = RG(length(S)) - sum(RG(s) for s in S)
@ -86,9 +85,14 @@
end end
@testset "Adj numerics for genus=$genus" begin @testset "Adj numerics for genus=$genus" begin
all_subtypes = ( all_subtypes = (
:A₁, :C₁, Symbol("A₁×A₁"), Symbol("C₁×C₁"), Symbol("A₁×C₁"), :A₂, :C₂ :A₁,
:C₁,
Symbol("A₁×A₁"),
Symbol("C₁×C₁"),
Symbol("A₁×C₁"),
:A₂,
:C₂,
) )
@test PropertyT.Adj(Δs, :A₂)[one(SpN)] == 384 @test PropertyT.Adj(Δs, :A₂)[one(SpN)] == 384
@ -101,8 +105,8 @@
@test isinteger(PropertyT.Adj(Δs, subtype)[one(SpN)] / 16) @test isinteger(PropertyT.Adj(Δs, subtype)[one(SpN)] / 16)
end end
end end
@test sum(PropertyT.Adj(Δs, subtype) for subtype in all_subtypes) == Δ^2 @test sum(PropertyT.Adj(Δs, subtype) for subtype in all_subtypes) ==
Δ^2
end end
end end
end end

View File

@ -1,11 +1,12 @@
@testset "Quick tests" begin @testset "Quick tests" begin
@testset "SL(2,F₇)" begin @testset "SL(2,F₇)" begin
N = 2 N = 2
p = 7 p = 7
halfradius = 3 halfradius = 3
G = MatrixGroups.SpecialLinearGroup{N}(SymbolicWedderburn.Characters.FiniteFields.GF{p}) G = MatrixGroups.SpecialLinearGroup{N}(
RG, S, sizes = PropertyT.group_algebra(G, halfradius=3, twisted=true) SymbolicWedderburn.Characters.FiniteFields.GF{p},
)
RG, S, sizes = PropertyT.group_algebra(G; halfradius = 3)
Δ = let RG = RG, S = S Δ = let RG = RG, S = S
RG(length(S)) - sum(RG(s) for s in S) RG(length(S)) - sum(RG(s) for s in S)
@ -18,15 +19,15 @@
@testset "standard formulation" begin @testset "standard formulation" begin
status, certified, λ_cert = check_positivity( status, certified, λ_cert = check_positivity(
elt, elt,
unit, unit;
upper_bound=ub, upper_bound = ub,
halfradius=2, halfradius = 2,
optimizer=cosmo_optimizer( optimizer = cosmo_optimizer(;
eps=1e-7, eps = 1e-7,
max_iters=5_000, max_iters = 5_000,
accel=50, accel = 50,
alpha=1.95, alpha = 1.95,
) ),
) )
@test status == JuMP.OPTIMAL @test status == JuMP.OPTIMAL
@ -34,14 +35,18 @@
@test λ_cert > 5857 // 10000 @test λ_cert > 5857 // 10000
m = PropertyT.sos_problem_dual(elt, unit) m = PropertyT.sos_problem_dual(elt, unit)
PropertyT.solve(m, cosmo_optimizer( PropertyT.solve(
eps=1e-7, m,
max_iters=10_000, cosmo_optimizer(;
accel=50, eps = 1e-7,
alpha=1.95, max_iters = 10_000,
)) accel = 50,
alpha = 1.95,
),
)
@test JuMP.termination_status(m) in (JuMP.ALMOST_OPTIMAL, JuMP.OPTIMAL) @test JuMP.termination_status(m) in
(JuMP.ALMOST_OPTIMAL, JuMP.OPTIMAL)
@test JuMP.objective_value(m) λ_cert atol = 1e-2 @test JuMP.objective_value(m) λ_cert atol = 1e-2
end end
@ -55,20 +60,22 @@
Σ, Σ,
act, act,
basis(RG), basis(RG),
StarAlgebras.Basis{UInt16}(@view basis(RG)[1:sizes[halfradius]]), StarAlgebras.Basis{UInt16}(
@view basis(RG)[1:sizes[halfradius]]
),
) )
status, certified, λ_cert = check_positivity( status, certified, λ_cert = check_positivity(
elt, elt,
unit, unit,
wd, wd;
upper_bound=ub, upper_bound = ub,
halfradius=2, halfradius = 2,
optimizer=cosmo_optimizer( optimizer = cosmo_optimizer(;
eps=1e-7, eps = 1e-7,
max_iters=10_000, max_iters = 10_000,
accel=50, accel = 50,
alpha=1.9, alpha = 1.9,
), ),
) )

View File

@ -25,5 +25,6 @@ if haskey(ENV, "FULL_TEST") || haskey(ENV, "CI")
include("1812.03456.jl") include("1812.03456.jl")
include("graded_adj.jl") include("graded_adj.jl")
include("Chevalley.jl")
end end
end end