Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix removevredundancy! #53

Merged
merged 5 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
8 changes: 3 additions & 5 deletions src/polyhedron.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ function getine(p::Polyhedron)
p.ine = LiftedHRepresentation(getextm(p, :Fresh))
p.inem = nothing
p.hlinearitydetected = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave the setting of hlinearitydetected here and add a mention to the issue to say that in some examples there are still redundant elements

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed back p.hlinearitydetected = true and p.vlinearitydetected = true in getine and getext.

(By the way, please feel free to edit this branch.)

p.noredundantinequality = true
end
end
return p.ine
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
28 changes: 28 additions & 0 deletions test/redund.jl
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ include("matrix.jl")
include("polyhedron.jl")
include("lp.jl")
include("nash.jl")
include("redund.jl")
Loading