Skip to content

Commit fc49d96

Browse files
authored
Fix removevredundancy! (#53)
* Add test/redund.jl Tests should fail for this commit * Translate 0-based indices to Julia's 1-based in removevredundancy! * Set ?linearitydetected = true in detect?linearity! * Update to Polyhedra v0.8 * Revert setting ?linearitydetected = true in detect?linearity!
1 parent 22915a1 commit fc49d96

File tree

4 files changed

+33
-6
lines changed

4 files changed

+33
-6
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Polyhedra = "67491407-f73d-577b-9b50-8179a7c68029"
1010
lrslib_jll = "3873f7d0-7b7c-52c3-bdf4-8ab39b8f337a"
1111

1212
[compat]
13-
Polyhedra = "0.7"
13+
Polyhedra = "0.7, 0.8"
1414
julia = "1.6"
1515
lrslib_jll = "= 0.3.3"
1616

src/polyhedron.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ function getine(p::Polyhedron)
5656
p.ine = LiftedHRepresentation(getextm(p, :Fresh))
5757
p.inem = nothing
5858
p.hlinearitydetected = true
59-
p.noredundantinequality = true
6059
end
6160
end
6261
return p.ine
@@ -75,7 +74,6 @@ function getext(p::Polyhedron)
7574
p.ext = LiftedVRepresentation(getinem(p, :Fresh))
7675
p.extm = nothing
7776
p.vlinearitydetected = true
78-
p.noredundantgenerator = true
7977
end
8078
end
8179
return p.ext
@@ -154,7 +152,7 @@ function Polyhedra.detecthlinearity!(p::Polyhedron)
154152
p.inem = nothing
155153
p.ine = nothing
156154
getine(p)
157-
# getine sets hlinearity as detected and no redundant ineq.
155+
# getine sets hlinearity as detected
158156
end
159157
end
160158
function Polyhedra.detectvlinearity!(p::Polyhedron)
@@ -163,7 +161,7 @@ function Polyhedra.detectvlinearity!(p::Polyhedron)
163161
p.extm = nothing
164162
p.ext = nothing
165163
getext(p)
166-
# getext sets vlinearity as detected and no redundant gen.
164+
# getext sets vlinearity as detected
167165
end
168166
end
169167
function Polyhedra.removehredundancy!(p::Polyhedron)
@@ -185,7 +183,7 @@ function Polyhedra.removevredundancy!(p::Polyhedron)
185183
detectvlinearity!(p)
186184
ext = getext(p)
187185
extm = getextm(p, :AlmostFresh) # FIXME does it need to be fresh ?
188-
redset = redund(extm)
186+
redset = BitSet(redund(extm) .+ 1)
189187
nonred = setdiff(BitSet(1:size(ext.R, 1)), redset)
190188
nonred = collect(setdiff(nonred, ext.linset))
191189
lin = collect(ext.linset)

test/redund.jl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
@testset "Tests for redundancy removal" begin
2+
3+
@testset "Test for issue #52" begin
4+
A = [0 1 0; -1 0 0; 0 -1 0; 0 0 -1; 1 0 0]
5+
b = [2, -1, -1, -1, 2]
6+
linset = BitSet(5)
7+
hr = hrep(A, b, linset)
8+
9+
V = [2 1 1;
10+
2 2 1]
11+
R = [0 0 1]
12+
exp = vrep(V, R)
13+
14+
@testset "removevredundancy!" begin
15+
p = polyhedron(hr, LRSLib.Library())
16+
removevredundancy!(p)
17+
@test nrays(p) == nrays(exp)
18+
end
19+
20+
@testset "detectvlinearity! and then removevredundancy!" begin
21+
p = polyhedron(hr, LRSLib.Library())
22+
detectvlinearity!(p)
23+
removevredundancy!(p)
24+
@test nrays(p) == nrays(exp)
25+
end
26+
end
27+
28+
end

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ include("matrix.jl")
1010
include("polyhedron.jl")
1111
include("lp.jl")
1212
include("nash.jl")
13+
include("redund.jl")

0 commit comments

Comments
 (0)