1
0
mirror of https://github.com/kalmarek/PropertyT.jl.git synced 2024-11-13 14:00:27 +01:00
PropertyT.jl/test/check_positivity.jl

49 lines
1.1 KiB
Julia
Raw Normal View History

2023-03-19 23:28:36 +01:00
function check_positivity(
elt,
unit;
upper_bound = Inf,
halfradius = 2,
optimizer,
)
@time sos_problem =
2023-03-19 23:28:36 +01:00
PropertyT.sos_problem_primal(elt, unit; upper_bound = upper_bound)
status, _ = PropertyT.solve(sos_problem, optimizer)
P = JuMP.value.(sos_problem[:P])
Q = real.(sqrt(P))
certified, λ_cert = PropertyT.certify_solution(
elt,
unit,
JuMP.objective_value(sos_problem),
2023-03-19 23:28:36 +01:00
Q;
halfradius = halfradius,
)
return status, certified, λ_cert
end
2023-03-19 23:28:36 +01:00
function check_positivity(
elt,
unit,
wd;
upper_bound = Inf,
halfradius = 2,
optimizer,
)
@assert SA.aug(elt) == SA.aug(unit) == 0
@time sos_problem, Ps =
2023-03-19 23:28:36 +01:00
PropertyT.sos_problem_primal(elt, unit, wd; upper_bound = upper_bound)
@time status, _ = PropertyT.solve(sos_problem, optimizer)
Q = let Ps = Ps
Qs = [real.(sqrt(JuMP.value.(P))) for P in Ps]
PropertyT.reconstruct(Qs, wd)
end
λ = JuMP.value(sos_problem[])
2023-03-19 23:28:36 +01:00
certified, λ_cert =
PropertyT.certify_solution(elt, unit, λ, Q; halfradius = halfradius)
return status, certified, λ_cert
end