1
0
mirror of https://github.com/kalmarek/PropertyT.jl.git synced 2024-11-23 08:15:29 +01:00

len -> wlen is no longer a kwarg, and has no default value

This commit is contained in:
kalmar 2017-06-09 09:35:33 +02:00
parent aae4ee57c7
commit d98d68004b
2 changed files with 12 additions and 12 deletions

View File

@ -192,7 +192,7 @@ function check_property_T(name::String, S, Id, solver, upper_bound, tol, radius)
info(logger, "minimum(P) = $(minimum(P))") info(logger, "minimum(P) = $(minimum(P))")
if λ > 0 if λ > 0
sgap = check_distance_to_positive_cone(Δ, λ, P, tol=tol, rational=false, len=2*radius) sgap = check_distance_to_positive_cone(Δ, λ, P, 2*radius, tol=tol, rational=false)
if isa(sgap, Interval) if isa(sgap, Interval)
sgap = sgap.lo sgap = sgap.lo
end end

View File

@ -59,7 +59,7 @@ end
(x, tol::Real) = rationalize(BigInt, x, tol=tol) (x, tol::Real) = rationalize(BigInt, x, tol=tol)
function distance_to_cone{T<:Rational}(λ::T, sqrt_matrix::Array{T,2}, Δ::GroupRingElem{T}; len=4) function distance_to_cone{T<:Rational}(λ::T, sqrt_matrix::Array{T,2}, Δ::GroupRingElem{T}, wlen)
SOS = compute_SOS(sqrt_matrix, Δ) SOS = compute_SOS(sqrt_matrix, Δ)
SOS_diff = EOI(Δ, λ) - SOS SOS_diff = EOI(Δ, λ) - SOS
@ -73,11 +73,11 @@ function distance_to_cone{T<:Rational}(λ::T, sqrt_matrix::Array{T,2}, Δ::Group
info(logger, "ɛ(Δ² - λΔ - ∑ξᵢ*ξᵢ) = $ɛ_dist") info(logger, "ɛ(Δ² - λΔ - ∑ξᵢ*ξᵢ) = $ɛ_dist")
info(logger, "‖Δ² - λΔ - ∑ξᵢ*ξᵢ‖₁ = $(@sprintf("%.10f", float(eoi_SOS_L1_dist)))") info(logger, "‖Δ² - λΔ - ∑ξᵢ*ξᵢ‖₁ = $(@sprintf("%.10f", float(eoi_SOS_L1_dist)))")
distance_to_cone = λ - 2^(len-1)*eoi_SOS_L1_dist distance_to_cone = λ - 2^(wlen-1)*eoi_SOS_L1_dist
return distance_to_cone return distance_to_cone
end end
function distance_to_cone{T<:Rational, S<:Interval}(λ::T, sqrt_matrix::Array{S,2}, Δ::GroupRingElem{T}; len=4) function distance_to_cone{T<:Rational, S<:Interval}(λ::T, sqrt_matrix::Array{S,2}, Δ::GroupRingElem{T}, wlen)
SOS = compute_SOS(sqrt_matrix, Δ) SOS = compute_SOS(sqrt_matrix, Δ)
info(logger, "ɛ(∑ξᵢ*ξᵢ) ∈ $(GroupRings.augmentation(SOS))") info(logger, "ɛ(∑ξᵢ*ξᵢ) ∈ $(GroupRings.augmentation(SOS))")
λ_int = @interval(λ) λ_int = @interval(λ)
@ -91,11 +91,11 @@ function distance_to_cone{T<:Rational, S<:Interval}(λ::T, sqrt_matrix::Array{S,
info(logger, "ɛ(Δ² - λΔ - ∑ξᵢ*ξᵢ) ∈ $(ɛ_dist)") info(logger, "ɛ(Δ² - λΔ - ∑ξᵢ*ξᵢ) ∈ $(ɛ_dist)")
info(logger, "‖Δ² - λΔ - ∑ξᵢ*ξᵢ‖₁ ∈ $(eoi_SOS_L1_dist)") info(logger, "‖Δ² - λΔ - ∑ξᵢ*ξᵢ‖₁ ∈ $(eoi_SOS_L1_dist)")
distance_to_cone = λ - 2^(len-1)*eoi_SOS_L1_dist distance_to_cone = λ - 2^(wlen-1)*eoi_SOS_L1_dist
return distance_to_cone return distance_to_cone
end end
function distance_to_cone(λ, sqrt_matrix::Array, Δ::GroupRingElem; len=4) function distance_to_cone(λ, sqrt_matrix::Array, Δ::GroupRingElem, wlen)
SOS = compute_SOS(sqrt_matrix, Δ) SOS = compute_SOS(sqrt_matrix, Δ)
SOS_diff = EOI(Δ, λ) - SOS SOS_diff = EOI(Δ, λ) - SOS
@ -106,12 +106,12 @@ function distance_to_cone(λ, sqrt_matrix::Array, Δ::GroupRingElem; len=4)
info(logger, "ɛ(Δ² - λΔ - ∑ξᵢ*ξᵢ) ≈ $(@sprintf("%.10f", ɛ_dist))") info(logger, "ɛ(Δ² - λΔ - ∑ξᵢ*ξᵢ) ≈ $(@sprintf("%.10f", ɛ_dist))")
info(logger, "‖Δ² - λΔ - ∑ξᵢ*ξᵢ‖₁ ≈ $(@sprintf("%.10f", eoi_SOS_L1_dist))") info(logger, "‖Δ² - λΔ - ∑ξᵢ*ξᵢ‖₁ ≈ $(@sprintf("%.10f", eoi_SOS_L1_dist))")
distance_to_cone = λ - 2^(len-1)*eoi_SOS_L1_dist distance_to_cone = λ - 2^(wlen-1)*eoi_SOS_L1_dist
return distance_to_cone return distance_to_cone
end end
function check_distance_to_positive_cone(Δ::GroupRingElem, λ, P; function check_distance_to_positive_cone(Δ::GroupRingElem, λ, P, wlen;
tol=1e-7, rational=false, len=4) tol=1e-7, rational=false)
isapprox(eigvals(P), abs(eigvals(P)), atol=tol) || isapprox(eigvals(P), abs(eigvals(P)), atol=tol) ||
warn("The solution matrix doesn't seem to be positive definite!") warn("The solution matrix doesn't seem to be positive definite!")
@ -121,7 +121,7 @@ function check_distance_to_positive_cone(Δ::GroupRingElem, λ, P;
info(logger, "------------------------------------------------------------") info(logger, "------------------------------------------------------------")
info(logger, "") info(logger, "")
info(logger, "Checking in floating-point arithmetic...") info(logger, "Checking in floating-point arithmetic...")
t = @timed fp_distance = distance_to_cone(λ, Q, Δ, len=len) t = @timed fp_distance = distance_to_cone(λ, Q, Δ, wlen)
info(logger, timed_msg(t)) info(logger, timed_msg(t))
info(logger, "Floating point distance (to positive cone) ≈ $(@sprintf("%.10f", fp_distance))") info(logger, "Floating point distance (to positive cone) ≈ $(@sprintf("%.10f", fp_distance))")
info(logger, "------------------------------------------------------------") info(logger, "------------------------------------------------------------")
@ -141,7 +141,7 @@ function check_distance_to_positive_cone(Δ::GroupRingElem, λ, P;
info(logger, "Checking in interval arithmetic") info(logger, "Checking in interval arithmetic")
Q_ω_int = Float64.(Q_ω) ± δ Q_ω_int = Float64.(Q_ω) ± δ
t = @timed Interval_dist_to_ΣSq = distance_to_cone(λ_, Q_ω_int, Δ_, len=len) t = @timed Interval_dist_to_ΣSq = distance_to_cone(λ_, Q_ω_int, Δ_, wlen)
info(logger, timed_msg(t)) info(logger, timed_msg(t))
info(logger, "The Augmentation-projected actual distance (to positive cone) ∈ $(Interval_dist_to_ΣSq)") info(logger, "The Augmentation-projected actual distance (to positive cone) ∈ $(Interval_dist_to_ΣSq)")
info(logger, "------------------------------------------------------------") info(logger, "------------------------------------------------------------")
@ -150,7 +150,7 @@ function check_distance_to_positive_cone(Δ::GroupRingElem, λ, P;
return Interval_dist_to_ΣSq return Interval_dist_to_ΣSq
else else
info(logger, "Checking Projected SOS decomposition in exact rational arithmetic...") info(logger, "Checking Projected SOS decomposition in exact rational arithmetic...")
t = @timed _dist_to_ΣSq = distance_to_cone(λ_, Q_ω, Δ_, len=len) t = @timed _dist_to_ΣSq = distance_to_cone(λ_, Q_ω, Δ_, wlen)
info(logger, timed_msg(t)) info(logger, timed_msg(t))
@assert isa(_dist_to_ΣSq, Rational) @assert isa(_dist_to_ΣSq, Rational)
info(logger, "Augmentation-projected rational distance (to positive cone) ≥ $(Float64(trunc(_dist_to_ΣSq,8)))") info(logger, "Augmentation-projected rational distance (to positive cone) ≥ $(Float64(trunc(_dist_to_ΣSq,8)))")