From b23975a627746a9337941dac982f8f77efb10de8 Mon Sep 17 00:00:00 2001 From: Marek Kaluba Date: Wed, 14 Feb 2024 10:53:10 +0100 Subject: [PATCH 1/9] update and fix versions for dependencies i.e. PermutationGroups, GroupsCore, SymbolicWedderburn --- Project.toml | 14 ++++++++++---- src/PropertyT.jl | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Project.toml b/Project.toml index a10b399..b6ebac0 100644 --- a/Project.toml +++ b/Project.toml @@ -5,25 +5,31 @@ version = "0.5.0" [deps] Groups = "5d8bd718-bd84-11e8-3b40-ad14f4a32557" +GroupsCore = "d5909c97-4eac-4ecc-a3dc-fdd0858a4120" IntervalArithmetic = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253" IntervalMatrices = "5c1f47dc-42dd-5697-8aaa-4d102d140ba9" JuMP = "4076af6c-e467-56ae-b986-b466b2749572" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +PermutationGroups = "8bc5a954-2dfc-11e9-10e6-cd969bffa420" ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" +StarAlgebras = "0c0c59c1-dc5f-42e9-9a8b-b5dc384a6cd1" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" SymbolicWedderburn = "858aa9a9-4c7c-4c62-b466-2421203962a2" [compat] COSMO = "0.8" -Groups = "0.7" +Groups = "0.8" IntervalArithmetic = "0.20" IntervalMatrices = "0.8" -JuMP = "1.3" +GroupsCore = "0.5" +JuMP = ">=1.3" +PermutationGroups = "0.6.2" ProgressMeter = "1.7" -SCS = "1.1" +SCS = "2" +StarAlgebras = "0.2" StaticArrays = "1" -SymbolicWedderburn = "0.3.4" +SymbolicWedderburn = "0.4" julia = "1.6" [extras] diff --git a/src/PropertyT.jl b/src/PropertyT.jl index 60b0aef..756cbdc 100644 --- a/src/PropertyT.jl +++ b/src/PropertyT.jl @@ -6,7 +6,7 @@ using SparseArrays using JuMP using Groups -import Groups.GroupsCore +import GroupsCore using SymbolicWedderburn import SymbolicWedderburn.StarAlgebras import SymbolicWedderburn.PermutationGroups From 27ce603872fdcbdd0dc8b2759d27538472ef16f4 Mon Sep 17 00:00:00 2001 From: Marek Kaluba Date: Thu, 15 Feb 2024 22:42:17 +0100 Subject: [PATCH 2/9] import packages as ... instead of using This includes: * PermutationGroups as PG * SymbolicWedderburn as SW * StarAlgebras as SA --- src/PropertyT.jl | 10 ++-- src/actions/actions.jl | 21 +++---- src/actions/alphabet_permutation.jl | 22 +++---- src/actions/autfn_conjugation.jl | 10 +++- src/actions/sln_conjugation.jl | 10 +++- src/actions/spn_conjugation.jl | 12 ++-- src/certify.jl | 31 +++++----- src/constraint_matrix.jl | 10 ++-- src/gradings.jl | 2 +- src/reconstruct.jl | 22 +++---- src/sos_sdps.jl | 56 +++++++++--------- src/sqadjop.jl | 50 +++++++++------- test/1703.09680.jl | 2 +- test/1712.07167.jl | 42 ++++++++------ test/1812.03456.jl | 40 ++++++------- test/Chevalley.jl | 10 ++-- test/actions.jl | 89 ++++++++++++++--------------- test/check_positivity.jl | 2 +- test/quick_tests.jl | 17 +++--- test/runtests.jl | 6 +- 20 files changed, 241 insertions(+), 223 deletions(-) diff --git a/src/PropertyT.jl b/src/PropertyT.jl index 756cbdc..35b5933 100644 --- a/src/PropertyT.jl +++ b/src/PropertyT.jl @@ -7,9 +7,9 @@ using JuMP using Groups import GroupsCore -using SymbolicWedderburn -import SymbolicWedderburn.StarAlgebras -import SymbolicWedderburn.PermutationGroups +import PermutationGroups as PG +import SymbolicWedderburn as SW +import StarAlgebras as SA include("constraint_matrix.jl") include("sos_sdps.jl") @@ -31,9 +31,9 @@ function group_algebra(G::Groups.Group, S = gens(G); halfradius::Integer) @time E, sizes = Groups.wlmetric_ball(S; radius = 2halfradius) @info "sizes = $(sizes)" @info "computing the *-algebra structure for G" - @time RG = StarAlgebras.StarAlgebra( + @time RG = SA.StarAlgebra( G, - StarAlgebras.Basis{UInt32}(E), + SA.Basis{UInt32}(E), (sizes[halfradius], sizes[halfradius]); precompute = false, ) diff --git a/src/actions/actions.jl b/src/actions/actions.jl index 8205e8b..8c6bac0 100644 --- a/src/actions/actions.jl +++ b/src/actions/actions.jl @@ -1,29 +1,24 @@ -import SymbolicWedderburn.action - include("alphabet_permutation.jl") include("sln_conjugation.jl") include("spn_conjugation.jl") include("autfn_conjugation.jl") -function SymbolicWedderburn.action( - act::SymbolicWedderburn.ByPermutations, +function SW.action( + act::SW.ByPermutations, g::Groups.GroupElement, - α::StarAlgebras.AlgebraElement, + α::SA.AlgebraElement, ) - res = StarAlgebras.zero!(similar(α)) - B = basis(parent(α)) - for (idx, val) in StarAlgebras._nzpairs(StarAlgebras.coeffs(α)) + res = SA.zero!(similar(α)) + B = SA.basis(parent(α)) + for (idx, val) in SA._nzpairs(SA.coeffs(α)) a = B[idx] - a_g = SymbolicWedderburn.action(act, g, a) + a_g = SW.action(act, g, a) res[a_g] += val end return res end -function Base.:^( - w::W, - p::PermutationGroups.AbstractPerm, -) where {W<:Groups.AbstractWord} +function Base.:^(w::W, p::PG.AbstractPermutation) where {W<:Groups.AbstractWord} return W([l^p for l in w]) end diff --git a/src/actions/alphabet_permutation.jl b/src/actions/alphabet_permutation.jl index 8dfe89d..018b18e 100644 --- a/src/actions/alphabet_permutation.jl +++ b/src/actions/alphabet_permutation.jl @@ -2,43 +2,37 @@ import Groups: Constructions -struct AlphabetPermutation{GEl,I} <: SymbolicWedderburn.ByPermutations - perms::Dict{GEl,PermutationGroups.Perm{I}} +struct AlphabetPermutation{GEl,I} <: SW.ByPermutations + perms::Dict{GEl,PG.Perm{I}} end function AlphabetPermutation( A::Alphabet, - Γ::PermutationGroups.AbstractPermutationGroup, + Γ::PG.AbstractPermutationGroup, op, ) return AlphabetPermutation( - Dict(γ => inv(PermutationGroups.Perm([A[op(l, γ)] for l in A])) for γ in Γ), + Dict(γ => inv(PG.Perm([A[op(l, γ)] for l in A])) for γ in Γ), ) end function AlphabetPermutation(A::Alphabet, W::Constructions.WreathProduct, op) return AlphabetPermutation( Dict( - w => inv(PermutationGroups.Perm([A[op(op(l, w.p), w.n)] for l in A])) for + w => inv(PG.Perm([A[op(op(l, w.p), w.n)] for l in A])) for w in W ), ) end -function SymbolicWedderburn.action( +function SW.action( act::AlphabetPermutation, γ::Groups.GroupElement, g::Groups.AbstractFPGroupElement, ) G = parent(g) - w = SymbolicWedderburn.action(act, γ, word(g)) + # w = SW.action(act, γ, word(g)) + w = word(g)^(act.perms[γ]) return G(w) end -function SymbolicWedderburn.action( - act::AlphabetPermutation, - γ::Groups.GroupElement, - w::Groups.AbstractWord, -) - return w^(act.perms[γ]) -end diff --git a/src/actions/autfn_conjugation.jl b/src/actions/autfn_conjugation.jl index 99559d5..17af669 100644 --- a/src/actions/autfn_conjugation.jl +++ b/src/actions/autfn_conjugation.jl @@ -2,7 +2,7 @@ function _conj( t::Groups.Transvection, - σ::PermutationGroups.AbstractPerm, + σ::PG.AbstractPermutation, ) return Groups.Transvection(t.id, t.i^inv(σ), t.j^inv(σ), t.inv) end @@ -22,5 +22,9 @@ function _conj( return _flip(t, x.elts[i]) end -action_by_conjugation(sautfn::Groups.AutomorphismGroup{<:Groups.FreeGroup}, Σ::Groups.Group) = - AlphabetPermutation(alphabet(sautfn), Σ, _conj) +function action_by_conjugation( + sautfn::Groups.AutomorphismGroup{<:Groups.FreeGroup}, + Σ::Groups.Group, +) + return AlphabetPermutation(alphabet(sautfn), Σ, _conj) +end diff --git a/src/actions/sln_conjugation.jl b/src/actions/sln_conjugation.jl index bdb016f..bfe5f1a 100644 --- a/src/actions/sln_conjugation.jl +++ b/src/actions/sln_conjugation.jl @@ -2,7 +2,7 @@ function _conj( t::MatrixGroups.ElementaryMatrix{N}, - σ::PermutationGroups.AbstractPerm, + σ::PG.AbstractPermutation, ) where {N} return MatrixGroups.ElementaryMatrix{N}(t.i^inv(σ), t.j^inv(σ), t.val) end @@ -16,5 +16,9 @@ function _conj( return ifelse(just_one_flips, inv(t), t) end -action_by_conjugation(sln::Groups.MatrixGroups.SpecialLinearGroup, Σ::Groups.Group) = - AlphabetPermutation(alphabet(sln), Σ, _conj) +function action_by_conjugation( + sln::Groups.MatrixGroups.SpecialLinearGroup, + Σ::Groups.Group, +) + return AlphabetPermutation(alphabet(sln), Σ, _conj) +end diff --git a/src/actions/spn_conjugation.jl b/src/actions/spn_conjugation.jl index ec760e9..96112b1 100644 --- a/src/actions/spn_conjugation.jl +++ b/src/actions/spn_conjugation.jl @@ -2,10 +2,10 @@ function _conj( s::MatrixGroups.ElementarySymplectic{N,T}, - σ::PermutationGroups.AbstractPerm, + σ::PG.AbstractPermutation, ) where {N,T} @assert iseven(N) - @assert PermutationGroups.degree(σ) == N ÷ 2 "Got degree = $(PermutationGroups.degree(σ)); N = $N" + @assert PG.degree(σ) ≤ N ÷ 2 "Got degree = $(PG.degree(σ)); N = $N" n = N ÷ 2 @assert 1 ≤ s.i ≤ N @assert 1 ≤ s.j ≤ N @@ -40,5 +40,9 @@ function _conj( return ifelse(just_one_flips, inv(s), s) end -action_by_conjugation(sln::Groups.MatrixGroups.SymplecticGroup, Σ::Groups.Group) = - AlphabetPermutation(alphabet(sln), Σ, _conj) +function action_by_conjugation( + sln::Groups.MatrixGroups.SymplecticGroup, + Σ::Groups.Group, +) + return AlphabetPermutation(alphabet(sln), Σ, _conj) +end diff --git a/src/certify.jl b/src/certify.jl index b93c843..e39f056 100644 --- a/src/certify.jl +++ b/src/certify.jl @@ -9,16 +9,16 @@ function augment_columns!(Q::AbstractMatrix) end function __sos_via_sqr!( - res::StarAlgebras.AlgebraElement, + res::SA.AlgebraElement, P::AbstractMatrix; augmented::Bool, - id = (b = basis(parent(res)); b[one(first(b))]), + id = (b = SA.basis(parent(res)); b[one(first(b))]), ) A = parent(res) mstr = A.mstructure @assert size(mstr) == size(P) - StarAlgebras.zero!(res) + SA.zero!(res) for j in axes(mstr, 2) for i in axes(mstr, 1) p = P[i, j] @@ -39,11 +39,11 @@ function __sos_via_sqr!( end function __sos_via_cnstr!( - res::StarAlgebras.AlgebraElement, + res::SA.AlgebraElement, Q²::AbstractMatrix, cnstrs, ) - StarAlgebras.zero!(res) + SA.zero!(res) for (g, A_g) in cnstrs res[g] = dot(A_g, Q²) end @@ -51,17 +51,17 @@ function __sos_via_cnstr!( end function compute_sos( - A::StarAlgebras.StarAlgebra, + A::SA.StarAlgebra, Q::AbstractMatrix; augmented::Bool, ) Q² = Q' * Q - res = StarAlgebras.AlgebraElement(zeros(eltype(Q²), length(basis(A))), A) + res = SA.AlgebraElement(zeros(eltype(Q²), length(SA.basis(A))), A) res = __sos_via_sqr!(res, Q²; augmented = augmented) return res end -function sufficient_λ(residual::StarAlgebras.AlgebraElement, λ; halfradius) +function sufficient_λ(residual::SA.AlgebraElement, λ; halfradius) L1_norm = norm(residual, 1) suff_λ = λ - 2.0^(2ceil(log2(halfradius))) * L1_norm @@ -87,10 +87,10 @@ function sufficient_λ(residual::StarAlgebras.AlgebraElement, λ; halfradius) end function sufficient_λ( - elt::StarAlgebras.AlgebraElement, - order_unit::StarAlgebras.AlgebraElement, + elt::SA.AlgebraElement, + order_unit::SA.AlgebraElement, λ, - sos::StarAlgebras.AlgebraElement; + sos::SA.AlgebraElement; halfradius, ) @assert parent(elt) === parent(order_unit) == parent(sos) @@ -100,16 +100,15 @@ function sufficient_λ( end function certify_solution( - elt::StarAlgebras.AlgebraElement, - orderunit::StarAlgebras.AlgebraElement, + elt::SA.AlgebraElement, + orderunit::SA.AlgebraElement, λ, Q::AbstractMatrix{<:AbstractFloat}; halfradius, - augmented = iszero(StarAlgebras.aug(elt)) && - iszero(StarAlgebras.aug(orderunit)), + augmented = iszero(SA.aug(elt)) && iszero(SA.aug(orderunit)), ) should_we_augment = - !augmented && StarAlgebras.aug(elt) == StarAlgebras.aug(orderunit) == 0 + !augmented && SA.aug(elt) == SA.aug(orderunit) == 0 Q = should_we_augment ? augment_columns!(Q) : Q @time sos = compute_sos(parent(elt), Q; augmented = augmented) diff --git a/src/constraint_matrix.jl b/src/constraint_matrix.jl index 997a037..9c5d0a8 100644 --- a/src/constraint_matrix.jl +++ b/src/constraint_matrix.jl @@ -147,13 +147,13 @@ function LinearAlgebra.dot(cm::ConstraintMatrix, m::AbstractMatrix{T}) where {T} return convert(eltype(cm), cm.val) * (pos - neg) end -function constraints(A::StarAlgebras.StarAlgebra; augmented::Bool) - return constraints(basis(A), A.mstructure; augmented = augmented) +function constraints(A::SA.StarAlgebra; augmented::Bool) + return constraints(SA.basis(A), A.mstructure; augmented = augmented) end function constraints( - basis::StarAlgebras.AbstractBasis, - mstr::StarAlgebras.MultiplicativeStructure; + basis::SA.AbstractBasis, + mstr::SA.MultiplicativeStructure; augmented = false, ) cnstrs = _constraints( @@ -170,7 +170,7 @@ function constraints( end function _constraints( - mstr::StarAlgebras.MultiplicativeStructure; + mstr::SA.MultiplicativeStructure; augmented::Bool = false, num_constraints = maximum(mstr), id, diff --git a/src/gradings.jl b/src/gradings.jl index b51de1a..c681a22 100644 --- a/src/gradings.jl +++ b/src/gradings.jl @@ -37,7 +37,7 @@ function _groupby(keys::AbstractVector{K}, vals::AbstractVector{V}) where {K,V} return d end -function laplacians(RG::StarAlgebras.StarAlgebra, S, grading) +function laplacians(RG::SA.StarAlgebra, S, grading) d = _groupby(grading, S) Δs = Dict(α => RG(length(Sα)) - sum(RG(s) for s in Sα) for (α, Sα) in d) return Δs diff --git a/src/reconstruct.jl b/src/reconstruct.jl index ce55619..777f54e 100644 --- a/src/reconstruct.jl +++ b/src/reconstruct.jl @@ -1,16 +1,18 @@ -__outer_dim(wd::WedderburnDecomposition) = size(first(direct_summands(wd)), 2) +function __outer_dim(wd::SW.WedderburnDecomposition) + return size(first(SW.direct_summands(wd)), 2) +end -function __group_of(wd::WedderburnDecomposition) +function __group_of(wd::SW.WedderburnDecomposition) # this is veeeery hacky... ;) return parent(first(keys(wd.hom.cache))) end function reconstruct( Ms::AbstractVector{<:AbstractMatrix}, - wbdec::WedderburnDecomposition, + wbdec::SW.WedderburnDecomposition, ) n = __outer_dim(wbdec) - res = sum(zip(Ms, SymbolicWedderburn.direct_summands(wbdec))) do (M, ds) + res = sum(zip(Ms, SW.direct_summands(wbdec))) do (M, ds) res = similar(M, n, n) res = _reconstruct!(res, M, ds) return res @@ -22,12 +24,12 @@ end function _reconstruct!( res::AbstractMatrix, M::AbstractMatrix, - ds::SymbolicWedderburn.DirectSummand, + ds::SW.DirectSummand, ) res .= zero(eltype(res)) if !iszero(M) - U = SymbolicWedderburn.image_basis(ds) - d = SymbolicWedderburn.degree(ds) + U = SW.image_basis(ds) + d = SW.degree(ds) res = (U' * M * U) .* d end return res @@ -47,15 +49,15 @@ function average!( res::AbstractMatrix, M::AbstractMatrix, G::Groups.Group, - hom::SymbolicWedderburn.InducedActionHomomorphism{ - <:SymbolicWedderburn.ByPermutations, + hom::SW.InducedActionHomomorphism{ + <:SW.ByPermutations, }, ) res .= zero(eltype(res)) @assert size(M) == size(res) o = Groups.order(Int, G) for g in G - p = SymbolicWedderburn.induce(hom, g) + p = SW.induce(hom, g) Threads.@threads for c in axes(res, 2) for r in axes(res, 1) if !iszero(M[r, c]) diff --git a/src/sos_sdps.jl b/src/sos_sdps.jl index 7dfb306..eb7be6e 100644 --- a/src/sos_sdps.jl +++ b/src/sos_sdps.jl @@ -5,8 +5,8 @@ Formulate the dual to the sum of squares decomposition problem for `X - λ·u`. See also [sos_problem_primal](@ref). """ function sos_problem_dual( - elt::StarAlgebras.AlgebraElement, - order_unit::StarAlgebras.AlgebraElement = zero(elt); + elt::SA.AlgebraElement, + order_unit::SA.AlgebraElement = zero(elt); lower_bound = -Inf, ) @assert parent(elt) == parent(order_unit) @@ -20,7 +20,7 @@ function sos_problem_dual( # Symmetrized: # 1 dual variable for every orbit of G acting on basis model = Model() - JuMP.@variable(model, y[1:length(basis(algebra))]) + JuMP.@variable(model, y[1:length(SA.basis(algebra))]) JuMP.@constraint(model, λ_dual, dot(order_unit, y) == 1) JuMP.@constraint(model, psd, y[moment_matrix] in PSDCone()) @@ -54,11 +54,10 @@ be added to the model. This may improve the accuracy of the solution if The default `u = zero(X)` formulates a simple feasibility problem. """ function sos_problem_primal( - elt::StarAlgebras.AlgebraElement, - order_unit::StarAlgebras.AlgebraElement = zero(elt); + elt::SA.AlgebraElement, + order_unit::SA.AlgebraElement = zero(elt); upper_bound = Inf, - augmented::Bool = iszero(StarAlgebras.aug(elt)) && - iszero(StarAlgebras.aug(order_unit)), + augmented::Bool = iszero(SA.aug(elt)) && iszero(SA.aug(order_unit)), ) @assert parent(elt) === parent(order_unit) @@ -80,11 +79,11 @@ function sos_problem_primal( end JuMP.@objective(model, Max, λ) - for b in basis(parent(elt)) + for b in SA.basis(parent(elt)) JuMP.@constraint(model, elt(b) - λ * order_unit(b) == dot(A[b], P)) end else - for b in basis(parent(elt)) + for b in SA.basis(parent(elt)) JuMP.@constraint(model, elt(b) == dot(A[b], P)) end end @@ -94,7 +93,7 @@ end function invariant_constraint!( result::AbstractMatrix, - basis::StarAlgebras.AbstractBasis, + basis::SA.AbstractBasis, cnstrs::AbstractDict{K,<:ConstraintMatrix}, invariant_vec::SparseVector, ) where {K} @@ -128,14 +127,14 @@ function invariant_constraint(basis, cnstrs, invariant_vec) return sparse(I, J, V, size(_M)...) end -function isorth_projection(ds::SymbolicWedderburn.DirectSummand) - U = SymbolicWedderburn.image_basis(ds) +function isorth_projection(ds::SW.DirectSummand) + U = SW.image_basis(ds) return isapprox(U * U', I) end function sos_problem_primal( - elt::StarAlgebras.AlgebraElement, - wedderburn::WedderburnDecomposition; + elt::SA.AlgebraElement, + wedderburn::SW.WedderburnDecomposition; kwargs..., ) return sos_problem_primal(elt, zero(elt), wedderburn; kwargs...) @@ -176,31 +175,30 @@ import ProgressMeter __show_itrs(n, total) = () -> [(Symbol("constraint"), "$n/$total")] function sos_problem_primal( - elt::StarAlgebras.AlgebraElement, - orderunit::StarAlgebras.AlgebraElement, - wedderburn::WedderburnDecomposition; + elt::SA.AlgebraElement, + orderunit::SA.AlgebraElement, + wedderburn::SW.WedderburnDecomposition; upper_bound = Inf, - augmented = iszero(StarAlgebras.aug(elt)) && - iszero(StarAlgebras.aug(orderunit)), + augmented = iszero(SA.aug(elt)) && iszero(SA.aug(orderunit)), check_orthogonality = true, show_progress = false, ) @assert parent(elt) === parent(orderunit) if check_orthogonality - if any(!isorth_projection, direct_summands(wedderburn)) + if any(!isorth_projection, SW.direct_summands(wedderburn)) error( "Wedderburn decomposition contains a non-orthogonal projection", ) end end - id_one = findfirst(invariant_vectors(wedderburn)) do v - b = basis(parent(elt)) + id_one = findfirst(SW.invariant_vectors(wedderburn)) do v + b = SA.basis(parent(elt)) return sparsevec([b[one(first(b))]], [1 // 1], length(v)) == v end prog = ProgressMeter.Progress( - length(invariant_vectors(wedderburn)); + length(SW.invariant_vectors(wedderburn)); dt = 1, desc = "Adding constraints: ", enabled = show_progress, @@ -225,7 +223,7 @@ function sos_problem_primal( end # semidefinite constraints as described by wedderburn - Ps = map(direct_summands(wedderburn)) do ds + Ps = map(SW.direct_summands(wedderburn)) do ds dim = size(ds, 1) P = JuMP.@variable(model, [1:dim, 1:dim], Symmetric) JuMP.@constraint(model, P in PSDCone()) @@ -238,14 +236,14 @@ function sos_problem_primal( _eps = 10 * eps(T) * max(size(parent(elt).mstructure)...) end - X = StarAlgebras.coeffs(elt) - U = StarAlgebras.coeffs(orderunit) + X = SA.coeffs(elt) + U = SA.coeffs(orderunit) # defining constraints based on the multiplicative structure cnstrs = constraints(parent(elt); augmented = augmented) # adding linear constraints: one per orbit - for (i, iv) in enumerate(invariant_vectors(wedderburn)) + for (i, iv) in enumerate(SW.invariant_vectors(wedderburn)) ProgressMeter.next!(prog; showvalues = __show_itrs(i, prog.n)) augmented && i == id_one && continue # i == 500 && break @@ -253,9 +251,9 @@ function sos_problem_primal( x = dot(X, iv) u = dot(U, iv) - spM_orb = invariant_constraint(basis(parent(elt)), cnstrs, iv) + spM_orb = invariant_constraint(SA.basis(parent(elt)), cnstrs, iv) - Ms = SymbolicWedderburn.diagonalize!( + Ms = SW.diagonalize!( Ms, spM_orb, wedderburn; diff --git a/src/sqadjop.jl b/src/sqadjop.jl index 9df0a06..4872635 100644 --- a/src/sqadjop.jl +++ b/src/sqadjop.jl @@ -1,30 +1,40 @@ -import SymbolicWedderburn.PermutationGroups.AbstractPerm - # move to Groups Base.keys(a::Alphabet) = keys(1:length(a)) ## the old 1812.03456 definitions -isopposite(σ::AbstractPerm, τ::AbstractPerm, i=1, j=2) = - i^σ ≠ i^τ && i^σ ≠ j^τ && j^σ ≠ i^τ && j^σ ≠ j^τ +function isopposite( + σ::PG.AbstractPermutation, + τ::PG.AbstractPermutation, + i = 1, + j = 2, +) + return i^σ ≠ i^τ && i^σ ≠ j^τ && j^σ ≠ i^τ && j^σ ≠ j^τ +end -isadjacent(σ::AbstractPerm, τ::AbstractPerm, i=1, j=2) = - (i^σ == i^τ && j^σ ≠ j^τ) || # first equal, second differ - (j^σ == j^τ && i^σ ≠ i^τ) || # second equal, first differ - (i^σ == j^τ && j^σ ≠ i^τ) || # first σ equal to second τ - (j^σ == i^τ && i^σ ≠ j^τ) # second σ equal to first τ +function isadjacent( + σ::PG.AbstractPermutation, + τ::PG.AbstractPermutation, + i = 1, + j = 2, +) + return (i^σ == i^τ && j^σ ≠ j^τ) || # first equal, second differ + (j^σ == j^τ && i^σ ≠ i^τ) || # second equal, first differ + (i^σ == j^τ && j^σ ≠ i^τ) || # first σ equal to second τ + (j^σ == i^τ && i^σ ≠ j^τ) # second σ equal to first τ +end function _ncycle(start, length, n=start + length - 1) - p = PermutationGroups.Perm(Int8(n)) + p = Vector{UInt8}(1:n) @assert n ≥ start + length - 1 for k in start:start+length-2 p[k] = k + 1 end p[start+length-1] = start - return p + return PG.Perm(p) end -alternating_group(n::Integer) = PermutationGroups.PermGroup([_ncycle(i, 3) for i in 1:n-2]) +alternating_group(n::Integer) = PG.PermGroup([_ncycle(i, 3) for i in 1:n-2]) function small_gens(G::MatrixGroups.SpecialLinearGroup) A = alphabet(G) @@ -46,31 +56,31 @@ function small_gens(G::Groups.AutomorphismGroup{<:FreeGroup}) return union!(S, inv.(S)) end -function small_laplacian(RG::StarAlgebras.StarAlgebra) - G = StarAlgebras.object(RG) +function small_laplacian(RG::SA.StarAlgebra) + G = SA.object(RG) S₂ = small_gens(G) return length(S₂) * one(RG) - sum(RG(s) for s in S₂) end -function SqAdjOp(A::StarAlgebras.StarAlgebra, n::Integer, Δ₂=small_laplacian(A)) +function SqAdjOp(A::SA.StarAlgebra, n::Integer, Δ₂ = small_laplacian(A)) @assert parent(Δ₂) === A alt_n = alternating_group(n) - G = StarAlgebras.object(A) + G = SA.object(A) act = action_by_conjugation(G, alt_n) - Δ₂s = Dict(σ => SymbolicWedderburn.action(act, σ, Δ₂) for σ in alt_n) + Δ₂s = Dict(σ => SW.action(act, σ, Δ₂) for σ in alt_n) sq, adj, op = zero(A), zero(A), zero(A) tmp = zero(A) for σ in alt_n - StarAlgebras.add!(sq, sq, StarAlgebras.mul!(tmp, Δ₂s[σ], Δ₂s[σ])) + SA.add!(sq, sq, SA.mul!(tmp, Δ₂s[σ], Δ₂s[σ])) for τ in alt_n if isopposite(σ, τ) - StarAlgebras.add!(op, op, StarAlgebras.mul!(tmp, Δ₂s[σ], Δ₂s[τ])) + SA.add!(op, op, SA.mul!(tmp, Δ₂s[σ], Δ₂s[τ])) elseif isadjacent(σ, τ) - StarAlgebras.add!(adj, adj, StarAlgebras.mul!(tmp, Δ₂s[σ], Δ₂s[τ])) + SA.add!(adj, adj, SA.mul!(tmp, Δ₂s[σ], Δ₂s[τ])) end end end diff --git a/test/1703.09680.jl b/test/1703.09680.jl index e801ab9..c901c8f 100644 --- a/test/1703.09680.jl +++ b/test/1703.09680.jl @@ -33,7 +33,7 @@ @testset "SL(3,F₅)" begin N = 3 G = MatrixGroups.SpecialLinearGroup{N}( - SymbolicWedderburn.Characters.FiniteFields.GF{5}, + SW.Characters.FiniteFields.GF{5}, ) RG, S, sizes = PropertyT.group_algebra(G; halfradius = 2) diff --git a/test/1712.07167.jl b/test/1712.07167.jl index abc19b8..2e854dd 100644 --- a/test/1712.07167.jl +++ b/test/1712.07167.jl @@ -5,15 +5,15 @@ @info "running tests for" G RG, S, sizes = PropertyT.group_algebra(G; halfradius = 2) - P = PermGroup(perm"(1,2)", Perm(circshift(1:N, -1))) - Σ = PropertyT.Constructions.WreathProduct(PermGroup(perm"(1,2)"), P) + P = PG.PermGroup(PG.perm"(1,2)", PG.Perm(circshift(1:N, -1))) + Σ = Groups.Constructions.WreathProduct(PG.PermGroup(PG.perm"(1,2)"), P) act = PropertyT.action_by_conjugation(G, Σ) - wd = WedderburnDecomposition( + wd = SW.WedderburnDecomposition( Float64, Σ, act, - basis(RG), - StarAlgebras.Basis{UInt16}(@view basis(RG)[1:sizes[2]]), + SA.basis(RG), + SA.Basis{UInt16}(@view SA.basis(RG)[1:sizes[2]]), ) @info wd @@ -54,15 +54,18 @@ Δ = RSL(length(S)) - sum(RSL(s) for s in S) @testset "Wedderburn formulation" begin - P = PermGroup(perm"(1,2)", Perm(circshift(1:n, -1))) - Σ = PropertyT.Constructions.WreathProduct(PermGroup(perm"(1,2)"), P) + P = PG.PermGroup(PG.perm"(1,2)", PG.Perm(circshift(1:n, -1))) + Σ = Groups.Constructions.WreathProduct( + PG.PermGroup(PG.perm"(1,2)"), + P, + ) act = PropertyT.action_by_conjugation(SL, Σ) - wd = WedderburnDecomposition( + wd = SW.WedderburnDecomposition( Rational{Int}, Σ, act, - basis(RSL), - StarAlgebras.Basis{UInt16}(@view basis(RSL)[1:sizes[2]]), + SA.basis(RSL), + SA.Basis{UInt16}(@view SA.basis(RSL)[1:sizes[2]]), ) @info wd @@ -78,12 +81,12 @@ augmented = false, ) - wdfl = SymbolicWedderburn.WedderburnDecomposition( + wdfl = SW.WedderburnDecomposition( Float64, Σ, act, - basis(RSL), - StarAlgebras.Basis{UInt16}(@view basis(RSL)[1:sizes[2]]), + SA.basis(RSL), + SA.Basis{UInt16}(@view SA.basis(RSL)[1:sizes[2]]), ) model, varP = PropertyT.sos_problem_primal( @@ -147,16 +150,19 @@ unit = Δ ub = Inf - P = PermGroup(perm"(1,2)", Perm(circshift(1:n, -1))) - Σ = PropertyT.Constructions.WreathProduct(PermGroup(perm"(1,2)"), P) + P = PG.PermGroup(PG.perm"(1,2)", PG.Perm(circshift(1:n, -1))) + Σ = Groups.Constructions.WreathProduct( + PG.PermGroup(PG.perm"(1,2)"), + P, + ) act = PropertyT.action_by_conjugation(SL, Σ) - wdfl = SymbolicWedderburn.WedderburnDecomposition( + wdfl = SW.WedderburnDecomposition( Float64, Σ, act, - basis(RSL), - StarAlgebras.Basis{UInt16}(@view basis(RSL)[1:sizes[2]]), + SA.basis(RSL), + SA.Basis{UInt16}(@view SA.basis(RSL)[1:sizes[2]]), ) @info wdfl diff --git a/test/1812.03456.jl b/test/1812.03456.jl index 383e01e..64eaf57 100644 --- a/test/1812.03456.jl +++ b/test/1812.03456.jl @@ -8,11 +8,11 @@ using SparseArrays end @testset "unit tests" begin - @test PropertyT.isopposite(perm"(1,2,3)(4)", perm"(1,4,2)") - @test PropertyT.isadjacent(perm"(1,2,3)", perm"(1,2)(3)") + @test PropertyT.isopposite(PG.perm"(1,2,3)(4)", PG.perm"(1,4,2)") + @test PropertyT.isadjacent(PG.perm"(1,2,3)", PG.perm"(1,2)(3)") - @test !PropertyT.isopposite(perm"(1,2,3)", perm"(1,2)(3)") - @test !PropertyT.isadjacent(perm"(1,4)", perm"(2,3)(4)") + @test !PropertyT.isopposite(PG.perm"(1,2,3)", PG.perm"(1,2)(3)") + @test !PropertyT.isadjacent(PG.perm"(1,4)", PG.perm"(2,3)(4)") @test isconstant_on_orbit([1, 1, 1, 2, 2], [2, 3]) @test !isconstant_on_orbit([1, 1, 1, 2, 2], [2, 3, 4]) @@ -29,19 +29,19 @@ using SparseArrays RG(length(S)) - sum(RG(s) for s in S) end - P = PermGroup(perm"(1,2)", Perm(circshift(1:N, -1))) - Σ = PropertyT.Constructions.WreathProduct(PermGroup(perm"(1,2)"), P) + P = PG.PermGroup(PG.perm"(1,2)", PG.Perm(circshift(1:N, -1))) + Σ = Groups.Constructions.WreathProduct(PG.PermGroup(PG.perm"(1,2)"), P) act = PropertyT.action_by_conjugation(G, Σ) - wd = WedderburnDecomposition( + wd = SW.WedderburnDecomposition( Float64, Σ, act, - basis(RG), - StarAlgebras.Basis{UInt16}(@view basis(RG)[1:sizes[2]]), + SA.basis(RG), + SA.Basis{UInt16}(@view SA.basis(RG)[1:sizes[2]]), ) @info wd - ivs = SymbolicWedderburn.invariant_vectors(wd) + ivs = SW.invariant_vectors(wd) sq, adj, op = PropertyT.SqAdjOp(RG, N) @@ -105,16 +105,16 @@ end Δ = RG(length(S)) - sum(RG(s) for s in S) - P = PermGroup(perm"(1,2)", Perm(circshift(1:n, -1))) - Σ = PropertyT.Constructions.WreathProduct(PermGroup(perm"(1,2)"), P) + P = PG.PermGroup(PG.perm"(1,2)", PG.Perm(circshift(1:n, -1))) + Σ = Groups.Constructions.WreathProduct(PG.PermGroup(PG.perm"(1,2)"), P) act = PropertyT.action_by_conjugation(G, Σ) - wd = SymbolicWedderburn.WedderburnDecomposition( + wd = SW.WedderburnDecomposition( Float64, Σ, act, - basis(RG), - StarAlgebras.Basis{UInt16}(@view basis(RG)[1:sizes[2]]), + SA.basis(RG), + SA.Basis{UInt16}(@view SA.basis(RG)[1:sizes[2]]), ) @info wd @@ -193,16 +193,16 @@ end Δ = RG(length(S)) - sum(RG(s) for s in S) - P = PermGroup(perm"(1,2)", Perm(circshift(1:n, -1))) - Σ = PropertyT.Constructions.WreathProduct(PermGroup(perm"(1,2)"), P) + P = PG.PermGroup(PG.perm"(1,2)", PG.Perm(circshift(1:n, -1))) + Σ = Groups.Constructions.WreathProduct(PG.PermGroup(PG.perm"(1,2)"), P) act = PropertyT.action_by_conjugation(G, Σ) - wd = SymbolicWedderburn.WedderburnDecomposition( + wd = SW.WedderburnDecomposition( Float64, Σ, act, - basis(RG), - StarAlgebras.Basis{UInt16}(@view basis(RG)[1:sizes[2]]), + SA.basis(RG), + SA.Basis{UInt16}(@view SA.basis(RG)[1:sizes[2]]), ) @info wd diff --git a/test/Chevalley.jl b/test/Chevalley.jl index e4fa863..fbf0836 100644 --- a/test/Chevalley.jl +++ b/test/Chevalley.jl @@ -20,8 +20,10 @@ end end @testset "Exceptional root systems" begin + Base.:^(t::NTuple{N}, p::PG.AbstractPermutation) where {N} = + ntuple(i -> t[i^p], N) @testset "F4" begin - F4 = let Σ = PermutationGroups.PermGroup(perm"(1,2,3,4)", perm"(1,2)") + F4 = let Σ = PG.PermGroup(PG.perm"(1,2,3,4)", PG.perm"(1,2)") long = let x = (1, 1, 0, 0) .// 1 PropertyT.Roots.Root.( union( @@ -90,9 +92,9 @@ end @testset "E6-7-8 exceptional root systems" begin E8 = - let Σ = PermutationGroups.PermGroup( - perm"(1,2,3,4,5,6,7,8)", - perm"(1,2)", + let Σ = PG.PermGroup( + PG.perm"(1,2,3,4,5,6,7,8)", + PG.perm"(1,2)", ) long = let x = (1, 1, 0, 0, 0, 0, 0, 0) .// 1 PropertyT.Roots.Root.( diff --git a/test/actions.jl b/test/actions.jl index 08e6a03..1e2e3b4 100644 --- a/test/actions.jl +++ b/test/actions.jl @@ -1,5 +1,5 @@ function test_action(basis, group, act) - action = SymbolicWedderburn.action + action = SW.action return @testset "action definition" begin @test all(basis) do b e = one(group) @@ -22,7 +22,7 @@ function test_action(basis, group, act) g_h end - action = SymbolicWedderburn.action + action = SW.action @test action(act, g, a) in basis @test action(act, h, a) in basis @test action(act, h, action(act, g, a)) == action(act, g * h, a) @@ -33,7 +33,7 @@ function test_action(basis, group, act) return x == y end - if act isa SymbolicWedderburn.ByPermutations + if act isa SW.ByPermutations @test all(basis) do b return action(act, g, b) ∈ basis && action(act, h, b) ∈ basis end @@ -50,69 +50,68 @@ end RSL, S, sizes = PropertyT.group_algebra(SL; halfradius = 2) @testset "Permutation action" begin - Γ = PermGroup(perm"(1,2)", Perm(circshift(1:n, -1))) + Γ = PG.PermGroup(PG.perm"(1,2)", PG.Perm(circshift(1:n, -1))) ΓpA = PropertyT.action_by_conjugation(SL, Γ) - test_action(basis(RSL), Γ, ΓpA) + test_action(SA.basis(RSL), Γ, ΓpA) @testset "mps is successful" begin charsΓ = - SymbolicWedderburn.Character{ + SW.Character{ Rational{Int}, - }.(SymbolicWedderburn.irreducible_characters(Γ)) + }.(SW.irreducible_characters(Γ)) - RΓ = SymbolicWedderburn._group_algebra(Γ) + RΓ = SW._group_algebra(Γ) @time mps, ranks = - SymbolicWedderburn.minimal_projection_system(charsΓ, RΓ) + SW.minimal_projection_system(charsΓ, RΓ) @test all(isone, ranks) end @testset "Wedderburn decomposition" begin - wd = SymbolicWedderburn.WedderburnDecomposition( + wd = SW.WedderburnDecomposition( Rational{Int}, Γ, ΓpA, - basis(RSL), - StarAlgebras.Basis{UInt16}(@view basis(RSL)[1:sizes[2]]), + SA.basis(RSL), + SA.Basis{UInt16}(@view SA.basis(RSL)[1:sizes[2]]), ) - @test length(invariant_vectors(wd)) == 918 - @test SymbolicWedderburn.size.(direct_summands(wd), 1) == - [40, 23, 18] - @test all(issimple, direct_summands(wd)) + @test length(SW.invariant_vectors(wd)) == 918 + @test size.(SW.direct_summands(wd), 1) == [23, 18, 40] + @test all(SW.issimple, SW.direct_summands(wd)) end end @testset "Wreath action" begin - Γ = let P = PermGroup(perm"(1,2)", Perm(circshift(1:n, -1))) - PropertyT.Constructions.WreathProduct(PermGroup(perm"(1,2)"), P) + Γ = let P = PG.PermGroup(PG.perm"(1,2)", PG.Perm(circshift(1:n, -1))) + Groups.Constructions.WreathProduct(PG.PermGroup(PG.perm"(1,2)"), P) end ΓpA = PropertyT.action_by_conjugation(SL, Γ) - test_action(basis(RSL), Γ, ΓpA) + test_action(SA.basis(RSL), Γ, ΓpA) @testset "mps is successful" begin charsΓ = - SymbolicWedderburn.Character{ + SW.Character{ Rational{Int}, - }.(SymbolicWedderburn.irreducible_characters(Γ)) + }.(SW.irreducible_characters(Γ)) - RΓ = SymbolicWedderburn._group_algebra(Γ) + RΓ = SW._group_algebra(Γ) @time mps, ranks = - SymbolicWedderburn.minimal_projection_system(charsΓ, RΓ) + SW.minimal_projection_system(charsΓ, RΓ) @test all(isone, ranks) end @testset "Wedderburn decomposition" begin - wd = SymbolicWedderburn.WedderburnDecomposition( + wd = SW.WedderburnDecomposition( Rational{Int}, Γ, ΓpA, - basis(RSL), - StarAlgebras.Basis{UInt16}(@view basis(RSL)[1:sizes[2]]), + SA.basis(RSL), + SA.Basis{UInt16}(@view SA.basis(RSL)[1:sizes[2]]), ) @test length(invariant_vectors(wd)) == 247 @@ -130,31 +129,31 @@ end RSAutFn, S, sizes = PropertyT.group_algebra(SAutFn; halfradius = 1) @testset "Permutation action" begin - Γ = PermGroup(perm"(1,2)", Perm(circshift(1:n, -1))) + Γ = PG.PermGroup(PG.perm"(1,2)", PG.Perm(circshift(1:n, -1))) ΓpA = PropertyT.action_by_conjugation(SAutFn, Γ) - test_action(basis(RSAutFn), Γ, ΓpA) + test_action(SA.basis(RSAutFn), Γ, ΓpA) @testset "mps is successful" begin charsΓ = - SymbolicWedderburn.Character{ + SW.Character{ Rational{Int}, - }.(SymbolicWedderburn.irreducible_characters(Γ)) + }.(SW.irreducible_characters(Γ)) - RΓ = SymbolicWedderburn._group_algebra(Γ) + RΓ = SW._group_algebra(Γ) @time mps, ranks = - SymbolicWedderburn.minimal_projection_system(charsΓ, RΓ) + SW.minimal_projection_system(charsΓ, RΓ) @test all(isone, ranks) end @testset "Wedderburn decomposition" begin - wd = SymbolicWedderburn.WedderburnDecomposition( + wd = SW.WedderburnDecomposition( Rational{Int}, Γ, ΓpA, - basis(RSAutFn), - StarAlgebras.Basis{UInt16}(@view basis(RSAutFn)[1:sizes[1]]), + SA.basis(RSAutFn), + SA.Basis{UInt16}(@view SA.basis(RSAutFn)[1:sizes[1]]), ) @test length(invariant_vectors(wd)) == 93 @@ -165,34 +164,34 @@ end end @testset "Wreath action" begin - Γ = let P = PermGroup(perm"(1,2)", Perm(circshift(1:n, -1))) - PropertyT.Constructions.WreathProduct(PermGroup(perm"(1,2)"), P) + Γ = let P = PG.PermGroup(PG.perm"(1,2)", PG.Perm(circshift(1:n, -1))) + Groups.Constructions.WreathProduct(PG.PermGroup(PG.perm"(1,2)"), P) end ΓpA = PropertyT.action_by_conjugation(SAutFn, Γ) - test_action(basis(RSAutFn), Γ, ΓpA) + test_action(SA.basis(RSAutFn), Γ, ΓpA) @testset "mps is successful" begin charsΓ = - SymbolicWedderburn.Character{ + SW.Character{ Rational{Int}, - }.(SymbolicWedderburn.irreducible_characters(Γ)) + }.(SW.irreducible_characters(Γ)) - RΓ = SymbolicWedderburn._group_algebra(Γ) + RΓ = SW._group_algebra(Γ) @time mps, ranks = - SymbolicWedderburn.minimal_projection_system(charsΓ, RΓ) + SW.minimal_projection_system(charsΓ, RΓ) @test all(isone, ranks) end @testset "Wedderburn decomposition" begin - wd = SymbolicWedderburn.WedderburnDecomposition( + wd = SW.WedderburnDecomposition( Rational{Int}, Γ, ΓpA, - basis(RSAutFn), - StarAlgebras.Basis{UInt16}(@view basis(RSAutFn)[1:sizes[1]]), + SA.basis(RSAutFn), + SA.Basis{UInt16}(@view SA.basis(RSAutFn)[1:sizes[1]]), ) @test length(invariant_vectors(wd)) == 18 diff --git a/test/check_positivity.jl b/test/check_positivity.jl index d57e80f..bb3b28c 100644 --- a/test/check_positivity.jl +++ b/test/check_positivity.jl @@ -29,7 +29,7 @@ function check_positivity( halfradius = 2, optimizer, ) - @assert aug(elt) == aug(unit) == 0 + @assert SA.aug(elt) == SA.aug(unit) == 0 @time sos_problem, Ps = PropertyT.sos_problem_primal(elt, unit, wd; upper_bound = upper_bound) diff --git a/test/quick_tests.jl b/test/quick_tests.jl index 9478286..908b9c6 100644 --- a/test/quick_tests.jl +++ b/test/quick_tests.jl @@ -4,7 +4,7 @@ p = 7 halfradius = 3 G = MatrixGroups.SpecialLinearGroup{N}( - SymbolicWedderburn.Characters.FiniteFields.GF{p}, + SW.Characters.FiniteFields.GF{p}, ) RG, S, sizes = PropertyT.group_algebra(G; halfradius = 3) @@ -51,18 +51,19 @@ end @testset "Wedderburn decomposition" begin - P = PermGroup(perm"(1,2)", Perm(circshift(1:N, -1))) - Σ = PropertyT.Constructions.WreathProduct(PermGroup(perm"(1,2)"), P) + P = PG.PermGroup(PG.perm"(1,2)", PG.Perm(circshift(1:N, -1))) + Σ = Groups.Constructions.WreathProduct( + PG.PermGroup(PG.perm"(1,2)"), + P, + ) act = PropertyT.action_by_conjugation(G, Σ) - wd = WedderburnDecomposition( + wd = SW.WedderburnDecomposition( Float64, Σ, act, - basis(RG), - StarAlgebras.Basis{UInt16}( - @view basis(RG)[1:sizes[halfradius]] - ), + SA.basis(RG), + SA.Basis{UInt16}(@view SA.basis(RG)[1:sizes[halfradius]]), ) status, certified, λ_cert = check_positivity( diff --git a/test/runtests.jl b/test/runtests.jl index a306e55..d4598e2 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -7,9 +7,9 @@ using Groups.GroupsCore import Groups.MatrixGroups using PropertyT -using SymbolicWedderburn -using SymbolicWedderburn.StarAlgebras -using SymbolicWedderburn.PermutationGroups +import SymbolicWedderburn as SW +import StarAlgebras as SA +import PermutationGroups as PG include("optimizers.jl") include("check_positivity.jl") From c9f68eee8f764f86efec3ef5e05b07398eb7b82c Mon Sep 17 00:00:00 2001 From: Marek Kaluba Date: Thu, 15 Feb 2024 22:44:23 +0100 Subject: [PATCH 3/9] update IntervalArithmetic to 0.21 --- Project.toml | 6 +++--- src/certify.jl | 10 ++++++---- test/1703.09680.jl | 12 ++++++++++-- test/quick_tests.jl | 3 ++- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Project.toml b/Project.toml index b6ebac0..dd078fe 100644 --- a/Project.toml +++ b/Project.toml @@ -20,14 +20,14 @@ SymbolicWedderburn = "858aa9a9-4c7c-4c62-b466-2421203962a2" [compat] COSMO = "0.8" Groups = "0.8" -IntervalArithmetic = "0.20" -IntervalMatrices = "0.8" GroupsCore = "0.5" +IntervalArithmetic = "0.21" +IntervalMatrices = "0.10" JuMP = ">=1.3" PermutationGroups = "0.6.2" ProgressMeter = "1.7" SCS = "2" -StarAlgebras = "0.2" +StarAlgebras = "0.2.1" StaticArrays = "1" SymbolicWedderburn = "0.4" julia = "1.6" diff --git a/src/certify.jl b/src/certify.jl index e39f056..35a3695 100644 --- a/src/certify.jl +++ b/src/certify.jl @@ -77,8 +77,10 @@ function sufficient_λ(residual::SA.AlgebraElement, λ; halfradius) info_strs = [ "Numerical metrics of the obtained SOS:", - "ɛ(elt - λu - ∑ξᵢ*ξᵢ) $eq_sign $(StarAlgebras.aug(residual))", - "‖elt - λu - ∑ξᵢ*ξᵢ‖₁ $eq_sign $(L1_norm)", + "ɛ(elt - λu - ∑ξᵢ*ξᵢ) $eq_sign " * + sprint(show, SA.aug(residual); context = :compact => true), + "‖elt - λu - ∑ξᵢ*ξᵢ‖₁ $eq_sign " * + sprint(show, L1_norm; context = :compact => true), " λ $eq_sign $suff_λ", ] @info join(info_strs, "\n") @@ -121,9 +123,9 @@ function certify_solution( return false, λ_flpoint end - λ_int = IntervalArithmetic.@interval(λ) + λ_int = IntervalArithmetic.interval(Float64, λ) Q_int = IntervalMatrices.IntervalMatrix([ - IntervalArithmetic.@interval(q) for q in Q + IntervalArithmetic.interval(Float64, q) for q in Q ]) check, sos_int = @time if should_we_augment diff --git a/test/1703.09680.jl b/test/1703.09680.jl index c901c8f..61175eb 100644 --- a/test/1703.09680.jl +++ b/test/1703.09680.jl @@ -173,7 +173,11 @@ ) @test certified - @test isapprox(λ_cert, λ, rtol = 1e-5) + @test isapprox( + PropertyT.IntervalArithmetic.inf(λ_cert), + λ, + rtol = 1e-5, + ) end @testset "augmented formulation" begin @@ -213,7 +217,11 @@ ) @test certified - @test isapprox(λ_cert, λ, rtol = 1e-5) + @test isapprox( + PropertyT.IntervalArithmetic.inf(λ_cert), + λ, + rtol = 1e-5, + ) @test λ_cert > 2 // 10 end end diff --git a/test/quick_tests.jl b/test/quick_tests.jl index 908b9c6..a9b4c49 100644 --- a/test/quick_tests.jl +++ b/test/quick_tests.jl @@ -47,7 +47,8 @@ @test JuMP.termination_status(m) in (JuMP.ALMOST_OPTIMAL, JuMP.OPTIMAL) - @test JuMP.objective_value(m) ≈ λ_cert atol = 1e-2 + @test JuMP.objective_value(m) ≈ + PropertyT.IntervalArithmetic.mid(λ_cert) atol = 1e-2 end @testset "Wedderburn decomposition" begin From d3975790f2a1890aa5add2c1ce3529df180b835b Mon Sep 17 00:00:00 2001 From: Marek Kaluba Date: Thu, 15 Feb 2024 22:45:21 +0100 Subject: [PATCH 4/9] tweaking solvers parameters in tests --- test/1703.09680.jl | 33 +++++++++++++++++---------------- test/1712.07167.jl | 4 ++-- test/1812.03456.jl | 4 ++-- test/quick_tests.jl | 24 ++++++++++++------------ 4 files changed, 33 insertions(+), 32 deletions(-) diff --git a/test/1703.09680.jl b/test/1703.09680.jl index 61175eb..ba43ddd 100644 --- a/test/1703.09680.jl +++ b/test/1703.09680.jl @@ -20,12 +20,12 @@ optimizer = scs_optimizer(; eps = 1e-10, max_iters = 5_000, - accel = 50, + accel = -50, alpha = 1.9, ), ) - @test status == JuMP.ALMOST_OPTIMAL + @test status == JuMP.OPTIMAL @test !certified @test λ < 0 end @@ -53,7 +53,7 @@ optimizer = scs_optimizer(; eps = 1e-10, max_iters = 5_000, - accel = 50, + accel = -50, alpha = 1.9, ), ) @@ -65,15 +65,16 @@ m = PropertyT.sos_problem_dual(elt, unit) PropertyT.solve( m, - cosmo_optimizer(; - eps = 1e-6, + scs_optimizer(; + eps = 1e-3, max_iters = 5_000, - accel = 50, + accel = -50, alpha = 1.9, ), ) - @test JuMP.termination_status(m) in (JuMP.ALMOST_OPTIMAL, JuMP.OPTIMAL) + @test JuMP.termination_status(m) in + (JuMP.ITERATION_LIMIT, JuMP.ALMOST_OPTIMAL, JuMP.OPTIMAL) @test JuMP.objective_value(m) ≈ 1.5 atol = 1e-2 end @@ -98,12 +99,12 @@ optimizer = scs_optimizer(; eps = 1e-10, max_iters = 5_000, - accel = 50, + accel = -50, alpha = 1.9, ), ) - @test status == JuMP.ALMOST_OPTIMAL + @test status in (JuMP.ALMOST_OPTIMAL, JuMP.ITERATION_LIMIT) @test λ < 0 @test !certified @@ -111,14 +112,14 @@ status, _ = PropertyT.solve( sos_problem, - cosmo_optimizer(; + scs_optimizer(; eps = 1e-7, - max_iters = 10_000, - accel = 0, + max_iters = 5_000, + accel = -50, alpha = 1.9, ), ) - @test status == JuMP.OPTIMAL + @test status in (JuMP.OPTIMAL, JuMP.ITERATION_LIMIT) P = JuMP.value.(sos_problem[:P]) Q = real.(sqrt(P)) certified, λ_cert = @@ -149,11 +150,11 @@ status, _ = PropertyT.solve( opt_problem, - cosmo_optimizer(; + scs_optimizer(; eps = 1e-10, max_iters = 10_000, - accel = 0, - alpha = 1.5, + accel = 50, + alpha = 1.9, ), ) diff --git a/test/1712.07167.jl b/test/1712.07167.jl index 2e854dd..d807b03 100644 --- a/test/1712.07167.jl +++ b/test/1712.07167.jl @@ -176,10 +176,10 @@ status, _ = PropertyT.solve( opt_problem, - scs_optimizer(; + cosmo_optimizer(; eps = 1e-8, max_iters = 20_000, - accel = 0, + accel = 50, alpha = 1.9, ), ) diff --git a/test/1812.03456.jl b/test/1812.03456.jl index 64eaf57..c80017f 100644 --- a/test/1812.03456.jl +++ b/test/1812.03456.jl @@ -130,7 +130,7 @@ end wd; upper_bound = UB, halfradius = 2, - optimizer = cosmo_optimizer(; accel = 50, alpha = 1.9), + optimizer = scs_optimizer(; accel = -50, alpha = 1.9), ) @test status == JuMP.OPTIMAL @test certified @@ -156,7 +156,7 @@ end m, _ = PropertyT.sos_problem_primal(elt, wd) PropertyT.solve( m, - scs_optimizer(; max_iters = 5000, accel = 50, alpha = 1.9), + scs_optimizer(; max_iters = 1000, accel = 50, alpha = 1.9), ) @test JuMP.termination_status(m) in diff --git a/test/quick_tests.jl b/test/quick_tests.jl index a9b4c49..2d32667 100644 --- a/test/quick_tests.jl +++ b/test/quick_tests.jl @@ -22,11 +22,11 @@ unit; upper_bound = ub, halfradius = 2, - optimizer = cosmo_optimizer(; - eps = 1e-7, - max_iters = 5_000, - accel = 50, - alpha = 1.95, + optimizer = scs_optimizer(; + eps = 1e-8, + max_iters = 20_000, + accel = -50, + alpha = 1.9, ), ) @@ -37,11 +37,11 @@ m = PropertyT.sos_problem_dual(elt, unit) PropertyT.solve( m, - cosmo_optimizer(; - eps = 1e-7, + scs_optimizer(; + eps = 1e-8, max_iters = 10_000, - accel = 50, - alpha = 1.95, + accel = -50, + alpha = 1.9, ), ) @@ -73,10 +73,10 @@ wd; upper_bound = ub, halfradius = 2, - optimizer = cosmo_optimizer(; - eps = 1e-7, + optimizer = scs_optimizer(; + eps = 1e-8, max_iters = 10_000, - accel = 50, + accel = -50, alpha = 1.9, ), ) From 3a954cdfbd885f71122a96a83a8a2860c656edf3 Mon Sep 17 00:00:00 2001 From: Marek Kaluba Date: Thu, 15 Feb 2024 22:45:55 +0100 Subject: [PATCH 5/9] the order of roots has changed --- test/Chevalley.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/Chevalley.jl b/test/Chevalley.jl index fbf0836..cbd77df 100644 --- a/test/Chevalley.jl +++ b/test/Chevalley.jl @@ -52,7 +52,7 @@ end a = F4[1] @test isapprox(PropertyT.Roots.ℓ₂length(a), sqrt(2)) - b = F4[6] + b = F4[4] @test isapprox(PropertyT.Roots.ℓ₂length(b), sqrt(2)) c = a + b @test isapprox(PropertyT.Roots.ℓ₂length(c), 2.0) @@ -162,7 +162,6 @@ end ]) @test Set(keys(counts)) == subtypes d, r = divrem(counts[:A₂], 4) - @info d, r @test r == 0 && d == 10 end end From 681d93ce58d14dabf06d83fcf838bdca33ebcb49 Mon Sep 17 00:00:00 2001 From: Marek Kaluba Date: Thu, 15 Feb 2024 22:46:52 +0100 Subject: [PATCH 6/9] the order of characters has changed --- test/actions.jl | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/test/actions.jl b/test/actions.jl index 1e2e3b4..1aaa3d5 100644 --- a/test/actions.jl +++ b/test/actions.jl @@ -114,10 +114,9 @@ end SA.Basis{UInt16}(@view SA.basis(RSL)[1:sizes[2]]), ) - @test length(invariant_vectors(wd)) == 247 - @test SymbolicWedderburn.size.(direct_summands(wd), 1) == - [14, 9, 6, 14, 12] - @test all(issimple, direct_summands(wd)) + @test length(SW.invariant_vectors(wd)) == 247 + @test size.(SW.direct_summands(wd), 1) == [9, 6, 14, 14, 12] + @test all(SW.issimple, SW.direct_summands(wd)) end end end @@ -156,10 +155,9 @@ end SA.Basis{UInt16}(@view SA.basis(RSAutFn)[1:sizes[1]]), ) - @test length(invariant_vectors(wd)) == 93 - @test SymbolicWedderburn.size.(direct_summands(wd), 1) == - [4, 8, 5, 4] - @test all(issimple, direct_summands(wd)) + @test length(SW.invariant_vectors(wd)) == 93 + @test size.(SW.direct_summands(wd), 1) == [5, 4, 8, 4] + @test all(SW.issimple, SW.direct_summands(wd)) end end @@ -194,10 +192,9 @@ end SA.Basis{UInt16}(@view SA.basis(RSAutFn)[1:sizes[1]]), ) - @test length(invariant_vectors(wd)) == 18 - @test SymbolicWedderburn.size.(direct_summands(wd), 1) == - [1, 1, 2, 2, 1, 2, 2, 1] - @test all(issimple, direct_summands(wd)) + @test length(SW.invariant_vectors(wd)) == 18 + @test size.(SW.direct_summands(wd), 1) == [2, 1, 2, 1, 2, 1, 1, 2] + @test all(SW.issimple, SW.direct_summands(wd)) end end end From 92a19f856665393c77229ab973c513b475b999da Mon Sep 17 00:00:00 2001 From: Marek Kaluba Date: Thu, 15 Feb 2024 22:47:55 +0100 Subject: [PATCH 7/9] no longer use "FULL_TEST" ENV variable --- test/runtests.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index d4598e2..8a03fa9 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -3,7 +3,6 @@ using LinearAlgebra using SparseArrays using Groups -using Groups.GroupsCore import Groups.MatrixGroups using PropertyT @@ -15,7 +14,7 @@ include("optimizers.jl") include("check_positivity.jl") include("quick_tests.jl") -if haskey(ENV, "FULL_TEST") || haskey(ENV, "CI") +if haskey(ENV, "CI") @testset "PropertyT" begin include("constratint_matrices.jl") include("actions.jl") From 83fdd313c6a9e7b81c0dbe57a49c0f7443e30144 Mon Sep 17 00:00:00 2001 From: Marek Kaluba Date: Thu, 15 Feb 2024 22:48:14 +0100 Subject: [PATCH 8/9] bump to PropertyT to 0.6 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index dd078fe..45569d9 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "PropertyT" uuid = "03b72c93-0167-51e2-8a1e-eb4ff1fb940d" authors = ["Marek Kaluba "] -version = "0.5.0" +version = "0.6.0" [deps] Groups = "5d8bd718-bd84-11e8-3b40-ad14f4a32557" From cd90e072c49ba318fa7af540f57fbbb67cb28fff Mon Sep 17 00:00:00 2001 From: Marek Kaluba Date: Fri, 16 Feb 2024 12:09:11 +0100 Subject: [PATCH 9/9] back to IntervalArithmetic-0.20 to keep julia-1.6 --- Project.toml | 2 +- src/certify.jl | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Project.toml b/Project.toml index 45569d9..ea541ac 100644 --- a/Project.toml +++ b/Project.toml @@ -21,7 +21,7 @@ SymbolicWedderburn = "858aa9a9-4c7c-4c62-b466-2421203962a2" COSMO = "0.8" Groups = "0.8" GroupsCore = "0.5" -IntervalArithmetic = "0.21" +IntervalArithmetic = "0.20" IntervalMatrices = "0.10" JuMP = ">=1.3" PermutationGroups = "0.6.2" diff --git a/src/certify.jl b/src/certify.jl index 35a3695..004cadf 100644 --- a/src/certify.jl +++ b/src/certify.jl @@ -123,10 +123,8 @@ function certify_solution( return false, λ_flpoint end - λ_int = IntervalArithmetic.interval(Float64, λ) - Q_int = IntervalMatrices.IntervalMatrix([ - IntervalArithmetic.interval(Float64, q) for q in Q - ]) + λ_int = IntervalArithmetic.interval(λ) + Q_int = IntervalMatrices.IntervalMatrix(IntervalArithmetic.interval.(Q)) check, sos_int = @time if should_we_augment @info("Projecting columns of Q to the augmentation ideal...")