1
0
mirror of https://github.com/kalmarek/PropertyT.jl.git synced 2024-11-19 15:25:29 +01:00
PropertyT.jl/test/1703.09680.jl

224 lines
5.5 KiB
Julia
Raw Normal View History

2019-02-21 16:31:38 +01:00
@testset "1703.09680 Examples" begin
@testset "SL(2,Z)" begin
N = 2
2022-11-07 18:45:12 +01:00
G = MatrixGroups.SpecialLinearGroup{N}(Int8)
RG, S, sizes = PropertyT.group_algebra(G, halfradius=2, twisted=true)
2019-02-21 16:31:38 +01:00
2022-11-07 18:45:12 +01:00
Δ = let RG = RG, S = S
RG(length(S)) - sum(RG(s) for s in S)
end
2022-11-07 18:45:12 +01:00
elt = Δ^2
unit = Δ
ub = 0.1
2022-11-07 18:45:12 +01:00
status, certified, λ = check_positivity(
elt,
unit,
upper_bound=ub,
halfradius=2,
optimizer=scs_optimizer(
eps=1e-10,
max_iters=5_000,
accel=50,
alpha=1.9,
)
)
@test status == JuMP.ALMOST_OPTIMAL
@test !certified
@test λ < 0
2019-02-21 16:31:38 +01:00
end
2022-11-07 18:45:12 +01:00
@testset "SL(3,F₅)" begin
2019-02-21 16:31:38 +01:00
N = 3
2022-11-07 18:45:12 +01:00
G = MatrixGroups.SpecialLinearGroup{N}(SymbolicWedderburn.Characters.FiniteFields.GF{5})
RG, S, sizes = PropertyT.group_algebra(G, halfradius=2, twisted=true)
2022-11-07 18:45:12 +01:00
Δ = let RG = RG, S = S
RG(length(S)) - sum(RG(s) for s in S)
end
2022-11-07 18:45:12 +01:00
elt = Δ^2
unit = Δ
ub = 1.01 # 1.5
2022-11-07 18:45:12 +01:00
status, certified, λ = check_positivity(
elt,
unit,
upper_bound=ub,
halfradius=2,
optimizer=scs_optimizer(
eps=1e-10,
max_iters=5_000,
accel=50,
alpha=1.9,
)
)
2022-11-07 18:45:12 +01:00
@test status == JuMP.OPTIMAL
@test certified
@test λ > 1
2022-11-08 10:01:31 +01:00
m = PropertyT.sos_problem_dual(elt, unit)
2022-11-14 19:50:50 +01:00
PropertyT.solve(m, cosmo_optimizer(
eps=1e-6,
2022-11-08 10:01:31 +01:00
max_iters=5_000,
accel=50,
alpha=1.9,
))
@test JuMP.termination_status(m) in (JuMP.ALMOST_OPTIMAL, JuMP.OPTIMAL)
2022-11-14 19:50:50 +01:00
@test JuMP.objective_value(m) 1.5 atol = 1e-2
2019-02-21 16:31:38 +01:00
end
2019-02-21 16:31:38 +01:00
@testset "SAut(F₂)" begin
N = 2
2022-11-07 18:45:12 +01:00
G = SpecialAutomorphismGroup(FreeGroup(N))
RG, S, sizes = PropertyT.group_algebra(G, halfradius=2, twisted=true)
Δ = let RG = RG, S = S
RG(length(S)) - sum(RG(s) for s in S)
end
elt = Δ^2
unit = Δ
ub = 0.1
status, certified, λ = check_positivity(
elt,
unit,
2022-11-08 10:01:31 +01:00
upper_bound=ub,
2022-11-07 18:45:12 +01:00
halfradius=2,
optimizer=scs_optimizer(
eps=1e-10,
max_iters=5_000,
accel=50,
alpha=1.9,
)
)
@test status == JuMP.ALMOST_OPTIMAL
@test λ < 0
@test !certified
2022-11-08 10:01:31 +01:00
@time sos_problem =
PropertyT.sos_problem_primal(elt, upper_bound=ub)
status, _ = PropertyT.solve(
sos_problem,
cosmo_optimizer(
eps=1e-7,
max_iters=10_000,
accel=0,
alpha=1.9,
)
)
@test status == JuMP.OPTIMAL
P = JuMP.value.(sos_problem[:P])
Q = real.(sqrt(P))
certified, λ_cert = PropertyT.certify_solution(
elt,
zero(elt),
0.0,
Q,
halfradius=2,
)
@test !certified
@test λ_cert < 0
2022-11-07 18:45:12 +01:00
end
@testset "SL(3,Z) has (T)" begin
n = 3
SL = MatrixGroups.SpecialLinearGroup{n}(Int8)
RSL, S, sizes = PropertyT.group_algebra(SL, halfradius=2, twisted=true)
Δ = RSL(length(S)) - sum(RSL(s) for s in S)
@testset "basic formulation" begin
elt = Δ^2
unit = Δ
ub = 0.1
opt_problem = PropertyT.sos_problem_primal(
elt,
unit,
upper_bound=ub,
augmented=false,
)
status, _ = PropertyT.solve(
opt_problem,
cosmo_optimizer(
eps=1e-10,
max_iters=10_000,
accel=0,
alpha=1.5,
),
)
@test status == JuMP.OPTIMAL
λ = JuMP.value(opt_problem[])
@test λ > 0.09
Q = real.(sqrt(JuMP.value.(opt_problem[:P])))
certified, λ_cert = PropertyT.certify_solution(
elt,
unit,
λ,
Q,
halfradius=2,
augmented=false,
)
@test certified
@test isapprox(λ_cert, λ, rtol=1e-5)
end
@testset "augmented formulation" begin
elt = Δ^2
unit = Δ
ub = 0.20001 # Inf
opt_problem = PropertyT.sos_problem_primal(
elt,
unit,
upper_bound=ub,
augmented=true,
)
status, _ = PropertyT.solve(
opt_problem,
scs_optimizer(
eps=1e-10,
max_iters=10_000,
accel=-10,
alpha=1.5,
),
)
2022-11-07 18:45:12 +01:00
@test status == JuMP.OPTIMAL
2022-11-07 18:45:12 +01:00
λ = JuMP.value(opt_problem[])
Q = real.(sqrt(JuMP.value.(opt_problem[:P])))
2022-11-07 18:45:12 +01:00
certified, λ_cert = PropertyT.certify_solution(
elt,
unit,
λ,
Q,
halfradius=2,
augmented=true,
)
2022-11-07 18:45:12 +01:00
@test certified
@test isapprox(λ_cert, λ, rtol=1e-5)
@test λ_cert > 2 // 10
end
2019-02-21 16:31:38 +01:00
end
end