1
0
mirror of https://github.com/kalmarek/PropertyT.jl.git synced 2024-11-19 07:20:28 +01:00
This commit is contained in:
kalmar 2017-03-15 17:56:01 +01:00
parent 120def0ef2
commit bdf97be22c

View File

@ -67,7 +67,7 @@ function distance_to_cone{T<:Rational}(κ::T, sqrt_matrix::Array{T,2}, Δ::Group
SOS_diff = EOI(Δ, κ) - SOS SOS_diff = EOI(Δ, κ) - SOS
eoi_SOS_L₁_dist = norm(SOS_diff,1) eoi_SOS_L₁_dist = norm(SOS_diff,1)
info(logger, "κ = ") info(logger, "κ = (≈$(float(κ)))")
ɛ_dist = GroupAlgebras.ɛ(SOS_diff) ɛ_dist = GroupAlgebras.ɛ(SOS_diff)
if ɛ_dist 0//1 if ɛ_dist 0//1
warn(logger, "The SOS is not in the augmentation ideal, number below are meaningless!") warn(logger, "The SOS is not in the augmentation ideal, number below are meaningless!")
@ -86,7 +86,7 @@ function distance_to_cone{T<:Rational, S<:Interval}(κ::T, sqrt_matrix::Array{S,
SOS_diff = EOI(Δ, κ) - SOS SOS_diff = EOI(Δ, κ) - SOS
eoi_SOS_L₁_dist = norm(SOS_diff,1) eoi_SOS_L₁_dist = norm(SOS_diff,1)
info(logger, "κ = ") info(logger, "κ = (≈$(float(κ)))")
ɛ_dist = GroupAlgebras.ɛ(SOS_diff) ɛ_dist = GroupAlgebras.ɛ(SOS_diff)
info(logger, "ɛ(Δ² - κΔ - ∑ξᵢ*ξᵢ) ∈ $(ɛ_dist)") info(logger, "ɛ(Δ² - κΔ - ∑ξᵢ*ξᵢ) ∈ $(ɛ_dist)")
@ -102,7 +102,7 @@ function distance_to_cone{T<:AbstractFloat}(κ::T, sqrt_matrix::Array{T,2}, Δ::
SOS_diff = EOI(Δ, κ) - SOS SOS_diff = EOI(Δ, κ) - SOS
eoi_SOS_L₁_dist = norm(SOS_diff,1) eoi_SOS_L₁_dist = norm(SOS_diff,1)
info(logger, "κ = (≈$(float(κ)))") info(logger, "κ = ")
ɛ_dist = GroupAlgebras.ɛ(SOS_diff) ɛ_dist = GroupAlgebras.ɛ(SOS_diff)
info(logger, "ɛ(Δ² - κΔ - ∑ξᵢ*ξᵢ) ≈ $(@sprintf("%.10f\n", ɛ_dist))") info(logger, "ɛ(Δ² - κΔ - ∑ξᵢ*ξᵢ) ≈ $(@sprintf("%.10f\n", ɛ_dist))")
info(logger, "‖Δ² - κΔ - ∑ξᵢ*ξᵢ‖₁ ≈ $(@sprintf("%.10f\n", eoi_SOS_L₁_dist))") info(logger, "‖Δ² - κΔ - ∑ξᵢ*ξᵢ‖₁ ≈ $(@sprintf("%.10f\n", eoi_SOS_L₁_dist))")
@ -119,13 +119,12 @@ function check_distance_to_positive_cone(Δ::GroupAlgebraElement, κ, A;
@assert A == Symmetric(A) @assert A == Symmetric(A)
A_sqrt = real(sqrtm(A)) A_sqrt = real(sqrtm(A))
info(logger, "-------------------------------------------------------------") info(logger, "------------------------------------------------------------")
info(logger, "") info(logger, "")
info(logger, "Checking in floating-point arithmetic...") info(logger, "Checking in floating-point arithmetic...")
@time fp_distance = distance_to_cone(κ, A_sqrt, Δ) @time fp_distance = distance_to_cone(κ, A_sqrt, Δ)
info(logger, "Floating point distance (to positive cone)\n$(Float64(trunc(fp_distance,10)))") info(logger, "Floating point distance (to positive cone) ≈ $(Float64(trunc(fp_distance,10)))")
info(logger, "-------------------------------------------------------------") info(logger, "------------------------------------------------------------")
info(logger, "")
info(logger, "Projecting columns of rationalized A_sqrt to the augmentation ideal...") info(logger, "Projecting columns of rationalized A_sqrt to the augmentation ideal...")
δ = eps(κ) δ = eps(κ)
@ -137,9 +136,8 @@ function check_distance_to_positive_cone(Δ::GroupAlgebraElement, κ, A;
info(logger, "Checking in interval arithmetic") info(logger, "Checking in interval arithmetic")
A_sqrt__augᴵ = A_sqrt__aug ± δ A_sqrt__augᴵ = A_sqrt__aug ± δ
@time Interval_dist_to_Σ² = distance_to_cone(κ_, A_sqrt__augᴵ, Δ_) @time Interval_dist_to_Σ² = distance_to_cone(κ_, A_sqrt__augᴵ, Δ_)
info(logger, "The Augmentation-projected actual distance (to positive cone) belongs to \n$Interval_dist_to_Σ²") info(logger, "The Augmentation-projected actual distance (to positive cone) belongs to $Interval_dist_to_Σ²")
info(logger, "-------------------------------------------------------------") info(logger, "------------------------------------------------------------")
info(logger, "")
if Interval_dist_to_Σ².lo 0 if Interval_dist_to_Σ².lo 0
return Interval_dist_to_Σ².lo return Interval_dist_to_Σ².lo
@ -147,8 +145,8 @@ function check_distance_to_positive_cone(Δ::GroupAlgebraElement, κ, A;
info(logger, "Checking Projected SOS decomposition in exact rational arithmetic...") info(logger, "Checking Projected SOS decomposition in exact rational arithmetic...")
@time _dist_to_Σ² = distance_to_cone(κ_, A_sqrt__aug, Δ_) @time _dist_to_Σ² = distance_to_cone(κ_, A_sqrt__aug, Δ_)
@assert isa(_dist_to_Σ², Rational) @assert isa(_dist_to_Σ², Rational)
info(logger, "Augmentation-projected rational distance (to positive cone)\n$(Float64(trunc(_dist_to_Σ²,8)))") info(logger, "Augmentation-projected rational distance (to positive cone)$(Float64(trunc(_dist_to_Σ²,8)))")
info(logger, "-------------------------------------------------------------") info(logger, "------------------------------------------------------------")
return _dist_to_Σ² return _dist_to_Σ²
end end
end end