diff --git a/Project.toml b/Project.toml index f71f33c..14fb66b 100644 --- a/Project.toml +++ b/Project.toml @@ -10,7 +10,7 @@ Polyhedra = "67491407-f73d-577b-9b50-8179a7c68029" lrslib_jll = "3873f7d0-7b7c-52c3-bdf4-8ab39b8f337a" [compat] -Polyhedra = "0.7" +Polyhedra = "0.7, 0.8" julia = "1.6" lrslib_jll = "= 0.3.3" diff --git a/src/polyhedron.jl b/src/polyhedron.jl index effd529..9cc56ae 100644 --- a/src/polyhedron.jl +++ b/src/polyhedron.jl @@ -56,7 +56,6 @@ function getine(p::Polyhedron) p.ine = LiftedHRepresentation(getextm(p, :Fresh)) p.inem = nothing p.hlinearitydetected = true - p.noredundantinequality = true end end return p.ine @@ -75,7 +74,6 @@ function getext(p::Polyhedron) p.ext = LiftedVRepresentation(getinem(p, :Fresh)) p.extm = nothing p.vlinearitydetected = true - p.noredundantgenerator = true end end return p.ext @@ -154,7 +152,7 @@ function Polyhedra.detecthlinearity!(p::Polyhedron) p.inem = nothing p.ine = nothing getine(p) - # getine sets hlinearity as detected and no redundant ineq. + # getine sets hlinearity as detected end end function Polyhedra.detectvlinearity!(p::Polyhedron) @@ -163,7 +161,7 @@ function Polyhedra.detectvlinearity!(p::Polyhedron) p.extm = nothing p.ext = nothing getext(p) - # getext sets vlinearity as detected and no redundant gen. + # getext sets vlinearity as detected end end function Polyhedra.removehredundancy!(p::Polyhedron) @@ -185,7 +183,7 @@ function Polyhedra.removevredundancy!(p::Polyhedron) detectvlinearity!(p) ext = getext(p) extm = getextm(p, :AlmostFresh) # FIXME does it need to be fresh ? - redset = redund(extm) + redset = BitSet(redund(extm) .+ 1) nonred = setdiff(BitSet(1:size(ext.R, 1)), redset) nonred = collect(setdiff(nonred, ext.linset)) lin = collect(ext.linset) diff --git a/test/redund.jl b/test/redund.jl new file mode 100644 index 0000000..3349f73 --- /dev/null +++ b/test/redund.jl @@ -0,0 +1,28 @@ +@testset "Tests for redundancy removal" begin + + @testset "Test for issue #52" begin + A = [0 1 0; -1 0 0; 0 -1 0; 0 0 -1; 1 0 0] + b = [2, -1, -1, -1, 2] + linset = BitSet(5) + hr = hrep(A, b, linset) + + V = [2 1 1; + 2 2 1] + R = [0 0 1] + exp = vrep(V, R) + + @testset "removevredundancy!" begin + p = polyhedron(hr, LRSLib.Library()) + removevredundancy!(p) + @test nrays(p) == nrays(exp) + end + + @testset "detectvlinearity! and then removevredundancy!" begin + p = polyhedron(hr, LRSLib.Library()) + detectvlinearity!(p) + removevredundancy!(p) + @test nrays(p) == nrays(exp) + end + end + +end diff --git a/test/runtests.jl b/test/runtests.jl index eda6188..f355eb3 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -10,3 +10,4 @@ include("matrix.jl") include("polyhedron.jl") include("lp.jl") include("nash.jl") +include("redund.jl")