Closed aquohn closed 2 years ago
The problem is that rpoly
has insufficient type information: VPolytope{Rational, Vector{Rational}}
does not fully reveal the numeric type (the {Int}
in Rational{Int}
is missing). This could be either a LazySets
bug or a problem in how you create the VPolytope
(not possible to say from the one line).
Thanks for the prompt response! It was indeed the missing numeric type: I supplied the points for the vrep as Vector{Rational}
; changing to Vector{Rational{Int64}}
fixed it.
The Int64
seems to be introduced at [19]
, which is given by
function convert(::Type{HPolytope}, P::HRep{N}) where {N}
VT = Polyhedra.hvectortype(P)
constraints = Vector{LinearConstraint{N, VT}}()
for hi in Polyhedra.allhalfspaces(P)
a, b = hi.a, hi.β
if isapproxzero(norm(a))
@assert b >= zero(N) "the half-space is inconsistent since it has a " *
"zero normal direction but the constraint is negative"
continue
end
push!(constraints, HalfSpace(hi.a, hi.β))
end
return HPolytope(constraints)
end
which in turn is called by
function tohrep(P::VPolytope{N};
backend=default_polyhedra_backend(P)) where {N}
vl = P.vertices
if isempty(vl)
return EmptySet{N}(dim(P))
end
require(:Polyhedra; fun_name="tohrep")
return convert(HPolytope, polyhedron(P; backend=backend))
end
It seems the assumption regarding the numeric type is being made by the call to polyhedron(P)
from Polyhedra.jl
; is it supposed to assume the numeric type is Int64
?
Sorry, I do not follow. Does it work or not? If you create the Vector
with the full type, LazySets
is supposed to preserve it through all calls and eventually to Polyhedra
. If this is not the case, I suggest to open an issue with LazySets
.
About guessing Int64
: I am not sure this should be the job of the library.
Yes, it works with the full type. I'm trying to trace where the type assumption Int64
was introduced, since that breaks the conversion. It seems to have been introduced at [19]
in the stack trace.
Julia throws an error when I try to get the constraints of a vrep polytope (using the
LazySets.jl
interface); looks like a bug in thePolyhedra.jl
implementation?