diff --git a/.travis.yml b/.travis.yml index cfd35bf..a686713 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,7 @@ matrix: fast_finish: true allow_failures: - julia: nightly + - os: osx addons: apt: diff --git a/Manifest.toml b/Manifest.toml index 23908b2..84f504a 100644 --- a/Manifest.toml +++ b/Manifest.toml @@ -23,9 +23,9 @@ version = "0.8.10" [[BinaryProvider]] deps = ["Libdl", "SHA"] -git-tree-sha1 = "29995a7b317bbd06be147e1974a3541ce2502dca" +git-tree-sha1 = "5b08ed6036d9d3f0ee6369410b830f8873d4024c" uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232" -version = "0.5.7" +version = "0.5.8" [[Blosc]] deps = ["BinaryProvider", "CMakeWrapper", "Compat", "Libdl"] @@ -90,10 +90,10 @@ uuid = "163ba53b-c6d8-5494-b064-1a9d43ac40c5" version = "0.0.4" [[DiffRules]] -deps = ["Random", "Test"] -git-tree-sha1 = "dc0869fb2f5b23466b32ea799bd82c76480167f7" +deps = ["NaNMath", "Random", "SpecialFunctions"] +git-tree-sha1 = "f734b5f6bc9c909027ef99f6d91d5d9e4b111eed" uuid = "b552c78f-8df3-52c6-915a-8e097449b14b" -version = "0.0.10" +version = "0.1.0" [[Distributed]] deps = ["Random", "Serialization", "Sockets"] @@ -118,13 +118,13 @@ version = "1.0.7" [[ForwardDiff]] deps = ["CommonSubexpressions", "DiffResults", "DiffRules", "NaNMath", "Random", "SpecialFunctions", "StaticArrays"] -git-tree-sha1 = "e2c81741a8be50de143ecddee942396894f47750" +git-tree-sha1 = "4407e7b76999eca2646abdb68203bd4302476168" uuid = "f6369f11-7733-5829-9624-2563aa707210" -version = "0.10.4" +version = "0.10.6" [[GroupRings]] deps = ["AbstractAlgebra", "LinearAlgebra", "Markdown", "SparseArrays"] -git-tree-sha1 = "0953bbaa3ccd0b7e12585e705011f01ac8672c7c" +git-tree-sha1 = "8a9541783cff6911e35840770d0f004c0d2a13dd" repo-rev = "master" repo-url = "https://github.com/kalmarek/GroupRings.jl" uuid = "0befed6a-bd73-11e8-1e41-a1190947c2f5" @@ -132,17 +132,17 @@ version = "0.3.0" [[Groups]] deps = ["AbstractAlgebra", "LinearAlgebra", "Markdown"] -git-tree-sha1 = "852339602ab880eb0e2a78f072ad386f3266f8a2" +git-tree-sha1 = "2487fd5e6106dabcafb835b694df08b4d22dde0e" repo-rev = "master" repo-url = "https://github.com/kalmarek/Groups.jl" uuid = "5d8bd718-bd84-11e8-3b40-ad14f4a32557" -version = "0.2.3" +version = "0.3.0" [[HDF5]] deps = ["BinaryProvider", "Blosc", "CMakeWrapper", "Libdl", "Mmap"] -git-tree-sha1 = "c14a84878428b66222fccea6ed89cdafa7c22ae4" +git-tree-sha1 = "d3ea5532668bf9bdd5e8d5f16571e0b520cbbb9f" uuid = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" -version = "0.12.4" +version = "0.12.5" [[InteractiveUtils]] deps = ["Markdown"] @@ -197,9 +197,9 @@ uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" [[MathOptInterface]] deps = ["BenchmarkTools", "LinearAlgebra", "OrderedCollections", "SparseArrays", "Test", "Unicode"] -git-tree-sha1 = "0d0e9987440b0b5c03f8df9cd30694f1acec81bb" +git-tree-sha1 = "78427dcc212e0c0ad9658049bc56a50303ad9737" uuid = "b8f27783-ece8-5eb3-8dc8-9495eed66fee" -version = "0.9.6" +version = "0.9.7" [[MathProgBase]] deps = ["Compat"] @@ -230,9 +230,9 @@ version = "0.12.0" [[Parsers]] deps = ["Dates", "Test"] -git-tree-sha1 = "ef0af6c8601db18c282d092ccbd2f01f3f0cd70b" +git-tree-sha1 = "a23968e107c0544aca91bfab6f7dd34de1206a54" uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" -version = "0.3.7" +version = "0.3.9" [[Pkg]] deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"] @@ -290,9 +290,9 @@ version = "0.8.0" [[StaticArrays]] deps = ["LinearAlgebra", "Random", "Statistics"] -git-tree-sha1 = "1085ffbf5fd48fdba64ef8e902ca429c4e1212d3" +git-tree-sha1 = "5a3bcb6233adabde68ebc97be66e95dcb787424c" uuid = "90137ffa-7385-5640-81b9-e52037218182" -version = "0.11.1" +version = "0.12.1" [[Statistics]] deps = ["LinearAlgebra", "SparseArrays"] diff --git a/Project.toml b/Project.toml index 77441af..ad71915 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "PropertyT" uuid = "03b72c93-0167-51e2-8a1e-eb4ff1fb940d" authors = ["Marek Kaluba "] -version = "0.3.0" +version = "0.3.1" [deps] AbstractAlgebra = "c3fe647b-3220-5bb0-a1ea-a7954cac585d" @@ -18,8 +18,9 @@ Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" [compat] +AbstractAlgebra = "^0.7.0" GroupRings = "^0.3.0" -Groups = "^0.2.1" +Groups = "^0.3.0" julia = "≥ 1.1.0" [extras] diff --git a/README.md b/README.md index 6f370e7..09be816 100644 --- a/README.md +++ b/README.md @@ -1 +1,15 @@ # Property(T) + +[![Build Status](https://travis-ci.org/kalmarek/PropertyT.jl.svg?branch=master)](https://travis-ci.org/kalmarek/PropertyT.jl) +[![codecov](https://codecov.io/gh/kalmarek/PropertyT.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/kalmarek/PropertyT.jl) + +This package is concerned with sum of squares decompositions in group rings of finitely presented groups. +Please have a look into [test](https://github.com/kalmarek/GroupRings.jl/blob/master/test/runtests.jl) directory to see how to use this package. For an example applications have a look at our papers: +[1703.09680](https://arxiv.org/abs/1703.09680), [1712.07167](https://arxiv.org/abs/1712.07167) and [1812.03456](https://arxiv.org/abs/1812.03456). + +The package depends on + * [AbstractAlgebra](https://github.com/Nemocas/AbstractAlgebra.jl), + * [Groups](https://github.com/kalmarek/Groups.jl) + * [GroupRings](https://github.com/kalmarek/GroupRings.jl) + * [JuMP](https://github.com/JuliaOpt/JuMP.jl) + * [scs](https://github.com/JuliaOpt/SCS.jl) [solver](https://github.com/cvxgrp/scs) diff --git a/src/1712.07167.jl b/src/1712.07167.jl index 125d83d..ac9d707 100644 --- a/src/1712.07167.jl +++ b/src/1712.07167.jl @@ -33,43 +33,43 @@ end function Settings(name::String, G::Union{Group, NCRing}, S::AbstractVector{El}, solver::JuMP.OptimizerFactory; - halfradius::Integer=2, upper_bound::Float64=1.0, force_compute=false) where El <: Union{GroupElem, NCRingElem} + halfradius=2, upper_bound=1.0, force_compute=false) where El <: Union{GroupElem, NCRingElem} return Naive(name, G, S, halfradius, upper_bound, solver, force_compute) end function Settings(name::String, G::Union{Group, NCRing}, S::AbstractVector{El}, autS::Group, solver::JuMP.OptimizerFactory; - halfradius::Integer=2, upper_bound::Float64=1.0, force_compute=false) where El <: Union{GroupElem, NCRingElem} + halfradius=2, upper_bound=1.0, force_compute=false) where El <: Union{GroupElem, NCRingElem} return Symmetrized(name, G, S, autS, halfradius, upper_bound, solver, force_compute) end -prefix(s::Naive) = s.name -prefix(s::Symmetrized) = "o"*s.name suffix(s::Settings) = "$(s.upper_bound)" -prepath(s::Settings) = prefix(s) -fullpath(s::Settings) = joinpath(prefix(s), suffix(s)) +prepath(s::Settings) = s.name +fullpath(s::Settings) = joinpath(prepath(s), suffix(s)) filename(sett::Settings, s::Symbol; kwargs...) = filename(sett, Val{s}; kwargs...) -filename(sett::Settings, ::Type{Val{:fulllog}}) = - joinpath(fullpath(sett), "full_$(string(now())).log") -filename(sett::Settings, ::Type{Val{:solverlog}}) = - joinpath(fullpath(sett), "solver_$(string(now())).log") +filename(sett::Settings, ::Type{Val{:fulllog}}; kwargs...) = + filename(fullpath(sett), "full", "log", suffix=Dates.now(); kwargs...) +filename(sett::Settings, ::Type{Val{:solverlog}}; kwargs...) = + filename(fullpath(sett), "solver", "log", suffix=Dates.now(); kwargs...) -filename(sett::Settings, ::Type{Val{:Δ}}) = - joinpath(prepath(sett), "delta.jld") -filename(sett::Settings, ::Type{Val{:OrbitData}}) = - joinpath(prepath(sett), "OrbitData.jld") +filename(sett::Settings, ::Type{Val{:Δ}}; kwargs...) = + filename(prepath(sett), "delta", "jld"; kwargs...) +filename(sett::Settings, ::Type{Val{:OrbitData}}; kwargs...) = + filename(prepath(sett), "OrbitData", "jld"; kwargs...) -filename(sett::Settings, ::Type{Val{:solution}}) = - joinpath(fullpath(sett), "solution.jld") +filename(sett::Settings, ::Type{Val{:solution}}; kwargs...) = + filename(fullpath(sett), "solution", "jld"; kwargs...) -function filename(sett::Settings, ::Type{Val{:warmstart}}; date=false) - if date - return joinpath(fullpath(sett), "warmstart_$(Dates.now()).jld") - else - return joinpath(fullpath(sett), "warmstart.jld") - end +function filename(sett::Settings, ::Type{Val{:warmstart}}; kwargs...) + filename(fullpath(sett), "warmstart", "jld"; kwargs...) +end + +function filename(path::String, name, extension; prefix=nothing, suffix=nothing) + pre = isnothing(prefix) ? "" : "$(prefix)_" + suf = isnothing(suffix) ? "" : "_$(suffix)" + return joinpath(path, "$pre$name$suf.$extension") end ############################################################################### @@ -109,13 +109,13 @@ function approximate_by_SOS(sett::Naive, P = value.(SDP_problem[:P]) λ = value(SDP_problem[:λ]) - if any(isnan.(P)) + if any(isnan, P) @warn "The solution seems to contain NaNs. Not overriding warmstart.jld" else save(filename(sett, :warmstart), "warmstart", (ws.primal, ws.dual, ws.slack), "P", P, "λ", λ) end - save(filename(sett, :warmstart, date=true), + save(filename(sett, :warmstart, suffix=Dates.now()), "warmstart", (ws.primal, ws.dual, ws.slack), "P", P, "λ", λ) return λ, P @@ -155,13 +155,13 @@ function approximate_by_SOS(sett::Symmetrized, λ = value(SDP_problem[:λ]) Ps = [value.(P) for P in varP] - if any(any(isnan.(P)) for P in Ps) + if any(any(isnan, P) for P in Ps) @warn "The solution seems to contain NaNs. Not overriding warmstart.jld" else save(filename(sett, :warmstart), "warmstart", (ws.primal, ws.dual, ws.slack), "Ps", Ps, "λ", λ) end - save(filename(sett, :warmstart, date=true), + save(filename(sett, :warmstart, suffix=Dates.now()), "warmstart", (ws.primal, ws.dual, ws.slack), "Ps", Ps, "λ", λ) @info "Reconstructing P..." @@ -208,7 +208,7 @@ function certify_SOS_decomposition(elt::GroupRingElem, orderunit::GroupRingElem, @info("Projecting columns of Q to the augmentation ideal...") @time Q, check = augIdproj(Interval, Q) @info "Checking that sum of every column contains 0.0..." check_augmented=check - check || @warn("The following numbers are meaningless!") + check || @error("The following numbers are meaningless!") @info("Computing sum of squares decomposition...") @time residual = eoi - compute_SOS(parent(eoi), Q) @@ -222,7 +222,7 @@ function certify_SOS_decomposition(elt::GroupRingElem, orderunit::GroupRingElem, "Interval aritmetic (certified) λ ∈"] @info join(info_strs, "\n") certified_λ - return certified_λ.lo + return certified_λ end function spectral_gap(Δ::GroupRingElem, λ::Number, Q::AbstractMatrix; R::Int=2) @@ -236,7 +236,8 @@ end # ############################################################################### -Kazhdan(λ::Number, N::Integer) = sqrt(2*λ/N) +Kazhdan_constant(λ::Number, N::Integer) = sqrt(2*λ/N) +Kazhdan_constant(λ::Interval, N::Integer) = IntervalArithmetic.inf(sqrt(2*λ/N)) function check_property_T(sett::Settings) @info sett @@ -257,21 +258,24 @@ function Base.show(io::IO, sett::Settings) print(io, join(info_strs, "\n")) end -function interpret_results(sett::Settings, sgap::Number) +function interpret_results(name::String, sgap::Number, N::Integer) if sgap > 0 - Kazhdan_κ = Kazhdan(sgap, length(sett.S)) - if Kazhdan_κ > 0 - @info "κ($(sett.name), S) ≥ $Kazhdan_κ: Group HAS property (T)!" - return true - end + κ = Kazhdan_constant(sgap, N) + @info "κ($name, S) ≥ $κ: Group HAS property (T)!" + return true end - info_strs = ["The certified lower bound on the spectral gap is negative:", - "λ($(sett.name), S) ≥ 0.0 > $sgap", - "This tells us nothing about property (T)"] + info_strs = [ + "The certified lower bound on the spectral gap is negative:", + "λ($name, S) ≥ 0.0 > $sgap", + "This tells us nothing about property (T)", + ] @info join(info_strs, "\n") return false end +interpret_results(sett::Settings, sgap::Number) = + interpret_results(sett.name, sgap, length(sett.S)) + function spectral_gap(sett::Settings) fp = PropertyT.fullpath(sett) isdir(fp) || mkpath(fp) diff --git a/src/PropertyT.jl b/src/PropertyT.jl index 661b42d..f56a3a9 100644 --- a/src/PropertyT.jl +++ b/src/PropertyT.jl @@ -17,8 +17,6 @@ import AbstractAlgebra: Group, NCRing import MathProgBase.SolverInterface.AbstractMathProgSolver -AbstractAlgebra.one(G::Group) = G() - include("laplacians.jl") include("RGprojections.jl") include("orbitdata.jl") diff --git a/test/1712.07167.jl b/test/1712.07167.jl index d81663d..7c807f2 100644 --- a/test/1712.07167.jl +++ b/test/1712.07167.jl @@ -1,13 +1,15 @@ @testset "1712.07167 Examples" begin - @testset "oSL(3,Z)" begin + @testset "SL(3,Z)" begin N = 3 G = MatrixAlgebra(zz, N) S = PropertyT.generating_set(G) autS = WreathProduct(PermGroup(2), PermGroup(N)) - rm("oSL($N,Z)", recursive=true, force=true) - sett = PropertyT.Settings("SL($N,Z)", G, S, autS, with_SCS(2000, accel=20); + NAME = "SL($N,Z)_orbit" + + rm(NAME, recursive=true, force=true) + sett = PropertyT.Settings(NAME, G, S, autS, with_SCS(1000, accel=20); upper_bound=0.27, force_compute=false) @info sett @@ -20,7 +22,7 @@ @test λ == PropertyT.spectral_gap(sett) @test PropertyT.check_property_T(sett) == false - sett = PropertyT.Settings("SL($N,Z)", G, S, autS, with_SCS(4000, accel=20); + sett = PropertyT.Settings(NAME, G, S, autS, with_SCS(4000, accel=20); upper_bound=0.27, force_compute=true) @info sett @@ -36,7 +38,7 @@ ########## # Symmetrizing by PermGroup(3): - sett = PropertyT.Settings("SL($N,Z)", G, S, PermGroup(N), with_SCS(4000, accel=20, warm_start=false); + sett = PropertyT.Settings(NAME, G, S, PermGroup(N), with_SCS(4000, accel=20, warm_start=false); upper_bound=0.27, force_compute=true) @info sett @@ -46,14 +48,16 @@ @test PropertyT.interpret_results(sett, λ) == true end - @testset "oSL(4,Z)" begin + @testset "SL(4,Z)" begin N = 4 G = MatrixAlgebra(zz, N) S = PropertyT.generating_set(G) autS = WreathProduct(PermGroup(2), PermGroup(N)) - rm("oSL($N,Z)", recursive=true, force=true) - sett = PropertyT.Settings("SL($N,Z)", G, S, autS, with_SCS(2000, accel=20); + NAME = "SL($N,Z)_orbit" + + rm(NAME, recursive=true, force=true) + sett = PropertyT.Settings(NAME, G, S, autS, with_SCS(2000, accel=20); upper_bound=1.3, force_compute=false) @info sett @@ -66,7 +70,7 @@ @test λ == PropertyT.spectral_gap(sett) @test PropertyT.check_property_T(sett) == false - sett = PropertyT.Settings("SL($N,Z)", G, S, autS, with_SCS(15000, accel=20, warm_start=true); + sett = PropertyT.Settings(NAME, G, S, autS, with_SCS(15000, accel=20, warm_start=true); upper_bound=1.3, force_compute=true) @info sett @@ -86,9 +90,11 @@ S = PropertyT.generating_set(G) autS = WreathProduct(PermGroup(2), PermGroup(N)) - rm("oSAut(F$N)", recursive=true, force=true) + NAME = "SAut(F$N)_orbit" - sett = PropertyT.Settings("SAut(F$N)", G, S, autS, with_SCS(1000); + rm(NAME, recursive=true, force=true) + + sett = PropertyT.Settings(NAME, G, S, autS, with_SCS(1000); upper_bound=0.15) @info sett diff --git a/test/SOS_correctness.jl b/test/SOS_correctness.jl index f76f360..c13abe2 100644 --- a/test/SOS_correctness.jl +++ b/test/SOS_correctness.jl @@ -27,17 +27,17 @@ @info "$NAME:\nDifference in l₁-norm between square and hpc sos decompositions:" norm(eoi-sos_sqr,1) norm(eoi-sos_hpc,1) norm(sos_sqr - sos_hpc, 1) ######################################################### - NAME = "oSL(3,Z)" + NAME = "SL(3,Z)_orbit" eoi, pm, Q = prepare(NAME, 0.27, 3*2*2) @time sos_sqr = PropertyT.compute_SOS_square(pm, Q) @time sos_hpc = PropertyT.compute_SOS(pm, Q) - @test norm(sos_sqr - sos_hpc, 1) < 4e-12 + @test norm(sos_sqr - sos_hpc, 1) < 5e-12 @info "$NAME:\nDifference in l₁-norm between square and hpc sos decompositions:" norm(eoi-sos_sqr,1) norm(eoi-sos_hpc,1) norm(sos_sqr - sos_hpc, 1) ######################################################### - NAME = "oSL(4,Z)" + NAME = "SL(4,Z)_orbit" eoi, pm, Q = prepare(NAME, 1.3, 4*3*2) @time sos_sqr = PropertyT.compute_SOS_square(pm, Q) @@ -47,7 +47,7 @@ @info "$NAME:\nDifference in l₁-norm between square and hpc sos decompositions:" norm(eoi-sos_sqr,1) norm(eoi-sos_hpc,1) norm(sos_sqr - sos_hpc, 1) ######################################################### - NAME = "oSAut(F3)" + NAME = "SAut(F3)_orbit" eoi, pm, Q = prepare(NAME, 0.15, 4*3*2*2) @time sos_sqr = PropertyT.compute_SOS_square(pm, Q)