Weird Behaviour/Bug in Polyhedra.jl

I observed a strange behaviour with Polyhedra.jl. As a result of a rather complicated algorithm, I obtained a polyhedron as an intersection of half-planes. However, when I want to compute the vertices forming the complex hull, I get an empty set even though the polyhedron is not empty.

    verticesPoly = collect(points(doubledescription(poly)))
    println("vertices Poly ", verticesPoly) 
    println(poly)
    println(doubledescription(poly))
    println("The poly is ","not"^(!isempty(polyhedron(poly, CDDLib.Library(:float)))), " empty ")

Which gives the following output

vertices Poly Vector{Float64}[]
HalfSpace([-2.7574372873656063, -1.0], -0.36977619761786795) ∩ HalfSpace([2.7574372873656063, 1.0], 0.37977619761786796) ∩ HalfSpace([-2.847841082745452, -1.0], -0.28454512417330524) ∩ HalfSpace([2.847841082745452, 1.0], 0.29454512417330525) ∩ HalfSpace([-2.9382448781252974, -1.0], -0.1969492542069525) ∩ HalfSpace([2.9382448781252974, 1.0], 0.2069492542069525) ∩ HalfSpace([-3.028648673505143, -1.0], -0.10770400784273976) ∩ HalfSpace([3.028648673505143, 1.0], 0.11770400784273977) ∩ HalfSpace([-3.119052468884989, -1.0], -0.017538276125857677) ∩ HalfSpace([3.119052468884989, 1.0], 0.02753827612585768) ∩ HalfSpace([-3.2094562642648348, -1.0], 0.07281153203555704) ∩ HalfSpace([3.2094562642648348, 1.0], -0.06281153203555703) ∩ HalfSpace([-3.29986005964468, -1.0], 0.1626075043292363) ∩ HalfSpace([3.29986005964468, 1.0], -0.15260750432923628) ∩ HalfSpace([-3.390263855024526, -1.0], 0.2511162517763226) ∩ HalfSpace([3.390263855024526, 1.0], -0.2411162517763226) ∩ HalfSpace([-3.4806676504043716, -1.0], 0.33761489852556953) ∩ HalfSpace([3.4806676504043716, 1.0], -0.3276148985255695) ∩ HalfSpace([-3.571071445784217, -1.0], 0.42139698578387413) ∩ HalfSpace([3.571071445784217, 1.0], -0.4113969857838741) … 

The poly is not empty 

Am I doing something wrong? Whenever I run this code on other instances (outputted again by the rather complicated algorithm) this gives the expected behaviour.

Found it! It’s a precision issue. isempty can be called with more precision than float.

isempty(polyhedron(poly, CDDLib.Library(:exact))) 
1 Like