1
0
mirror of https://github.com/kalmarek/PropertyT.jl.git synced 2024-11-27 01:10:28 +01:00

adaptation to changes in GroupRings (not tested, not working)

This commit is contained in:
kalmar 2017-05-16 18:53:25 +02:00
parent e93ec0c422
commit 70b98ece5f
3 changed files with 21 additions and 24 deletions

View File

@ -42,7 +42,7 @@ function pmΔfilenames(name::String)
end end
prefix = name prefix = name
pm_filename = joinpath(prefix, "product_matrix.jld") pm_filename = joinpath(prefix, "product_matrix.jld")
Δ_coeff_filename = joinpath(prefix, "delta.coefficients.jld") Δ_coeff_filename = joinpath(prefix, "delta.coeffs.jld")
return pm_filename, Δ_coeff_filename return pm_filename, Δ_coeff_filename
end end
@ -64,7 +64,7 @@ function ΔandSDPconstraints(name::String)
info(logger, "Loading precomputed pm, Δ, sdp_constraints...") info(logger, "Loading precomputed pm, Δ, sdp_constraints...")
product_matrix = load(pm_fname, "pm") product_matrix = load(pm_fname, "pm")
L = load(Δ_fname, "Δ")[:, 1] L = load(Δ_fname, "Δ")[:, 1]
Δ = GroupAlgebraElement(L, Array{Int,2}(product_matrix)) Δ = GroupRingElem(L, Array{Int,2}(product_matrix))
sdp_constraints = constraints_from_pm(product_matrix) sdp_constraints = constraints_from_pm(product_matrix)
else else
throw(ArgumentError("You need to precompute pm and Δ to load it!")) throw(ArgumentError("You need to precompute pm and Δ to load it!"))
@ -84,7 +84,7 @@ function ΔandSDPconstraints(name::String, generating_set::Function, radius::Int
info(logger, timed_msg(t)) info(logger, timed_msg(t))
save(pm_fname, "pm", Δ.product_matrix) save(pm_fname, "pm", Δ.product_matrix)
save(Δ_fname, "Δ", Δ.coefficients) save(Δ_fname, "Δ", Δ.coeffs)
return Δ, sdp_constraints return Δ, sdp_constraints
else else
error(logger, err) error(logger, err)
@ -151,7 +151,7 @@ function λandP(name::String, opts...)
end end
end end
function compute_λandP(sdp_constraints, Δ::GroupAlgebraElement, solver::AbstractMathProgSolver, upper_bound=Inf) function compute_λandP(sdp_constraints, Δ::GroupRingElem, solver::AbstractMathProgSolver, upper_bound=Inf)
t = @timed SDP_problem = create_SDP_problem(sdp_constraints, Δ; upper_bound=upper_bound) t = @timed SDP_problem = create_SDP_problem(sdp_constraints, Δ; upper_bound=upper_bound)
info(logger, timed_msg(t)) info(logger, timed_msg(t))
@ -185,7 +185,7 @@ function check_property_T(name::String, generating_set::Function,
Δ, sdp_constraints = ΔandSDPconstraints(name, generating_set, radius) Δ, sdp_constraints = ΔandSDPconstraints(name, generating_set, radius)
S = countnz(Δ.coefficients) - 1 S = countnz(Δ.coeffs) - 1
info(logger, "|S| = $S") info(logger, "|S| = $S")
info(logger, "length(Δ) = $(length(Δ))") info(logger, "length(Δ) = $(length(Δ))")
info(logger, "size(Δ.product_matrix) = $(size(Δ.product_matrix))") info(logger, "size(Δ.product_matrix) = $(size(Δ.product_matrix))")

View File

@ -6,23 +6,21 @@ ValidatedNumerics.setrounding(Interval, :correct)
ValidatedNumerics.setformat(:standard) ValidatedNumerics.setformat(:standard)
# setprecision(Interval, 53) # slightly faster than 256 # setprecision(Interval, 53) # slightly faster than 256
function EOI{T<:Number}(Δ::GroupAlgebraElement{T}, λ::T) function EOI{T<:Number}(Δ::GroupRingElem{T}, λ::T)
return Δ*Δ - λ*Δ return Δ*Δ - λ*Δ
end end
function algebra_square(vector, elt) function algebra_square(vect, elt)
zzz = zeros(eltype(vector), elt.coefficients) zzz = zeros(eltype(vect), elt.coeffs)
zzz[1:length(vector)] = vector zzz[1:length(vect)] = vect
# new_base_elt = GroupAlgebraElement(zzz, elt.product_matrix) return GroupAlgebras.algebra_multiplication(zzz, zzz, parent(elt).pm)
# return (new_base_elt*new_base_elt).coefficients
return GroupAlgebras.algebra_multiplication(zzz, zzz, elt.product_matrix)
end end
function compute_SOS(sqrt_matrix, elt) function compute_SOS(sqrt_matrix, elt)
n = size(sqrt_matrix,2) n = size(sqrt_matrix,2)
T = eltype(sqrt_matrix) T = eltype(sqrt_matrix)
# result = zeros(T, length(elt.coefficients)) # result = zeros(T, length(elt.coeffs))
# for i in 1:n # for i in 1:n
# result += algebra_square(sqrt_matrix[:,i], elt) # result += algebra_square(sqrt_matrix[:,i], elt)
# end # end
@ -30,8 +28,7 @@ function compute_SOS(sqrt_matrix, elt)
result = @parallel (+) for i in 1:n result = @parallel (+) for i in 1:n
PropertyT.algebra_square(sqrt_matrix[:,i], elt) PropertyT.algebra_square(sqrt_matrix[:,i], elt)
end end
return GroupRingElem(result, parent(elt))
return GroupAlgebraElement(result, elt.product_matrix)
end end
function correct_to_augmentation_ideal{T<:Rational}(sqrt_matrix::Array{T,2}) function correct_to_augmentation_ideal{T<:Rational}(sqrt_matrix::Array{T,2})
@ -52,7 +49,7 @@ function (±){T<:Number}(X::AbstractArray{T}, tol::Real)
return r.(X) return r.(X)
end end
(±)(X::GroupAlgebraElement, tol::Real) = GroupAlgebraElement(X.coefficients ± tol, X.product_matrix) (±)(X::GroupRingElem, tol::Real) = GroupRingElem(X.coeffs ± tol, parent(X))
function Base.rationalize{T<:Integer, S<:Real}(::Type{T}, function Base.rationalize{T<:Integer, S<:Real}(::Type{T},
X::AbstractArray{S}; tol::Real=eps(eltype(X))) X::AbstractArray{S}; tol::Real=eps(eltype(X)))
@ -62,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}, Δ::GroupAlgebraElement{T}) function distance_to_cone{T<:Rational}(λ::T, sqrt_matrix::Array{T,2}, Δ::GroupRingElem{T})
SOS = compute_SOS(sqrt_matrix, Δ) SOS = compute_SOS(sqrt_matrix, Δ)
SOS_diff = EOI(Δ, λ) - SOS SOS_diff = EOI(Δ, λ) - SOS
@ -80,11 +77,11 @@ function distance_to_cone{T<:Rational}(λ::T, sqrt_matrix::Array{T,2}, Δ::Group
return distance_to_cone return distance_to_cone
end end
function distance_to_cone{T<:Rational, S<:Interval}(λ::T, sqrt_matrix::Array{S,2}, Δ::GroupAlgebraElement{T}) function distance_to_cone{T<:Rational, S<:Interval}(λ::T, sqrt_matrix::Array{S,2}, Δ::GroupRingElem{T})
SOS = compute_SOS(sqrt_matrix, Δ) SOS = compute_SOS(sqrt_matrix, Δ)
info(logger, "ɛ(∑ξᵢ*ξᵢ) ∈ $(GroupAlgebras.ɛ(SOS))") info(logger, "ɛ(∑ξᵢ*ξᵢ) ∈ $(GroupAlgebras.ɛ(SOS))")
λⁱⁿᵗ = @interval(λ) λⁱⁿᵗ = @interval(λ)
Δⁱⁿᵗ = GroupAlgebraElement([@interval(c) for c in Δ.coefficients], Δ.product_matrix) Δⁱⁿᵗ = GroupRingElem([@interval(c) for c in Δ.coeffs], parent(Δ).pm)
SOS_diff = EOI(Δⁱⁿᵗ, λⁱⁿᵗ) - SOS SOS_diff = EOI(Δⁱⁿᵗ, λⁱⁿᵗ) - SOS
eoi_SOS_L₁_dist = norm(SOS_diff,1) eoi_SOS_L₁_dist = norm(SOS_diff,1)
@ -98,7 +95,7 @@ function distance_to_cone{T<:Rational, S<:Interval}(λ::T, sqrt_matrix::Array{S,
return distance_to_cone return distance_to_cone
end end
function distance_to_cone{T<:AbstractFloat}(λ::T, sqrt_matrix::Array{T,2}, Δ::GroupAlgebraElement{T}) function distance_to_cone{T<:AbstractFloat}(λ::T, sqrt_matrix::Array{T,2}, Δ::GroupRingElem{T})
SOS = compute_SOS(sqrt_matrix, Δ) SOS = compute_SOS(sqrt_matrix, Δ)
SOS_diff = EOI(Δ, λ) - SOS SOS_diff = EOI(Δ, λ) - SOS
@ -113,7 +110,7 @@ function distance_to_cone{T<:AbstractFloat}(λ::T, sqrt_matrix::Array{T,2}, Δ::
return distance_to_cone return distance_to_cone
end end
function check_distance_to_positive_cone(Δ::GroupAlgebraElement, λ, P; function check_distance_to_positive_cone(Δ::GroupRingElem, λ, P;
tol=1e-7, rational=false) tol=1e-7, rational=false)
isapprox(eigvals(P), abs(eigvals(P)), atol=tol) || isapprox(eigvals(P), abs(eigvals(P)), atol=tol) ||

View File

@ -53,8 +53,8 @@ function laplacian_coeff(S, basis)
end end
function create_SDP_problem(matrix_constraints, Δ::GroupAlgebraElement; upper_bound=Inf) function create_SDP_problem(matrix_constraints, Δ::GroupRingElem; upper_bound=Inf)
N = size(Δ.product_matrix,1) N = size(parent(Δ).pm, 1)
Δ² = Δ*Δ Δ² = Δ*Δ
@assert length(Δ) == length(matrix_constraints) @assert length(Δ) == length(matrix_constraints)
m = JuMP.Model(); m = JuMP.Model();
@ -68,7 +68,7 @@ function create_SDP_problem(matrix_constraints, Δ::GroupAlgebraElement; upper_b
JuMP.@variable(m, λ >= 0) JuMP.@variable(m, λ >= 0)
end end
for (pairs, δ², δ) in zip(matrix_constraints, Δ².coefficients, Δ.coefficients) for (pairs, δ², δ) in zip(matrix_constraints, Δ².coeffs, Δ.coeffs)
JuMP.@constraint(m, sum(P[i,j] for (i,j) in pairs) == δ² - λ*δ) JuMP.@constraint(m, sum(P[i,j] for (i,j) in pairs) == δ² - λ*δ)
end end