PropertyT.jl/test/1703.09680.jl

221 lines
5.6 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)
2023-03-19 23:28:36 +01:00
RG, S, sizes = PropertyT.group_algebra(G; halfradius = 2)
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,
2023-03-19 23:28:36 +01:00
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.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
2023-03-19 23:28:36 +01:00
G = MatrixGroups.SpecialLinearGroup{N}(
SW.Characters.FiniteFields.GF{5},
2023-03-19 23:28:36 +01:00
)
RG, S, sizes = PropertyT.group_algebra(G; halfradius = 2)
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,
2023-03-19 23:28:36 +01:00
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
)
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)
2023-03-19 23:28:36 +01:00
PropertyT.solve(
m,
cosmo_optimizer(;
eps = 1e-6,
max_iters = 5_000,
accel = 50,
alpha = 1.9,
),
)
2022-11-08 10:01:31 +01:00
@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))
2023-03-19 23:28:36 +01:00
RG, S, sizes = PropertyT.group_algebra(G; halfradius = 2)
2022-11-07 18:45:12 +01:00
Δ = 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,
2023-03-19 23:28:36 +01:00
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.ALMOST_OPTIMAL
@test λ < 0
@test !certified
2022-11-08 10:01:31 +01:00
2023-03-19 23:28:36 +01:00
@time sos_problem = PropertyT.sos_problem_primal(elt; upper_bound = ub)
2022-11-08 10:01:31 +01:00
status, _ = PropertyT.solve(
sos_problem,
2023-03-19 23:28:36 +01:00
cosmo_optimizer(;
eps = 1e-7,
max_iters = 10_000,
accel = 0,
alpha = 1.9,
),
2022-11-08 10:01:31 +01:00
)
@test status == JuMP.OPTIMAL
P = JuMP.value.(sos_problem[:P])
Q = real.(sqrt(P))
2023-03-19 23:28:36 +01:00
certified, λ_cert =
PropertyT.certify_solution(elt, zero(elt), 0.0, Q; halfradius = 2)
2022-11-08 10:01:31 +01:00
@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)
2023-03-19 23:28:36 +01:00
RSL, S, sizes = PropertyT.group_algebra(SL; halfradius = 2)
2022-11-07 18:45:12 +01:00
Δ = 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,
2023-03-19 23:28:36 +01:00
unit;
upper_bound = ub,
augmented = false,
2022-11-07 18:45:12 +01:00
)
status, _ = PropertyT.solve(
opt_problem,
2023-03-19 23:28:36 +01:00
cosmo_optimizer(;
eps = 1e-10,
max_iters = 10_000,
accel = 0,
alpha = 1.5,
2022-11-07 18:45:12 +01:00
),
)
@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,
λ,
2023-03-19 23:28:36 +01:00
Q;
halfradius = 2,
augmented = false,
2022-11-07 18:45:12 +01:00
)
@test certified
2023-03-19 23:28:36 +01:00
@test isapprox(λ_cert, λ, rtol = 1e-5)
2022-11-07 18:45:12 +01:00
end
@testset "augmented formulation" begin
elt = Δ^2
unit = Δ
ub = 0.20001 # Inf
opt_problem = PropertyT.sos_problem_primal(
elt,
2023-03-19 23:28:36 +01:00
unit;
upper_bound = ub,
augmented = true,
2022-11-07 18:45:12 +01:00
)
status, _ = PropertyT.solve(
opt_problem,
2023-03-19 23:28:36 +01:00
scs_optimizer(;
eps = 1e-10,
max_iters = 10_000,
accel = -10,
alpha = 1.5,
2022-11-07 18:45:12 +01:00
),
)
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,
λ,
2023-03-19 23:28:36 +01:00
Q;
halfradius = 2,
augmented = true,
2022-11-07 18:45:12 +01:00
)
2022-11-07 18:45:12 +01:00
@test certified
2023-03-19 23:28:36 +01:00
@test isapprox(λ_cert, λ, rtol = 1e-5)
2022-11-07 18:45:12 +01:00
@test λ_cert > 2 // 10
end
2019-02-21 16:31:38 +01:00
end
end