JuliaPolyhedra / Polyhedra.jl

Polyhedral Computation Interface
Other
172 stars 27 forks source link

Missing method for sethrep! (caused by removevredundancy! with ztol) #298

Closed schillic closed 2 years ago

schillic commented 2 years ago

I just tried to fix the original problem behind #270 and found another problem:

(@v1.7) pkg> st Polyhedra
      Status `~/.julia/environments/v1.7/Project.toml`
  [67491407] Polyhedra v0.7.3

julia> using Polyhedra

julia> A = [1.0; -1.0;;];

julia> b = [1.0, 0.0];

julia> Q = polyhedron(hrep(A, b))
Polyhedron Interval{Float64, StaticArrays.SVector{1, Float64}, StaticArrays.Size{(1,)}}:
2-element iterator of HalfSpace{Float64, StaticArrays.SVector{1, Float64}}:
 HalfSpace([1.0], 1.0)
 HalfSpace([-1.0], 0.0):
2-element iterator of StaticArrays.SVector{1, Float64}:
 [1.0]
 [-0.0]

julia> removevredundancy!(Q; ztol=1e-7)
┌ Warning: Cannot detect exact linearity as no solver was provided and the polyhedron is not affine.
│ As fallback, we will only detect halfspaces from opposite hyperplanes but that may not detect all halfspaces.
│ Set a solver if you believe that the polyhedron may have more linearity.
│ To provide a solver to a polyhedron, first select a solver from https://jump.dev/JuMP.jl/stable/installation/#Getting-Solvers-1.
│ If you choose for instance `GLPK`, do `using GLPK; solver = GLPK.Optimizer`.
│ Then provide the solver to the library. For instance, with the default library, do `lib = DefaultLibrary{Float64}(solver)`
│ or if you use an external library, say `QHull`, do `lib = QHull.Library(solver)`.
│ Then when you create the polyhedron, say from a representation `rep`, do `polyhedron(rep, lib)`.
└ @ Polyhedra ~/.julia/packages/Polyhedra/BmL2i/src/linearity.jl:231
ERROR: MethodError: no method matching sethrep!(::Interval{Float64, StaticArrays.SVector{1, Float64}, StaticArrays.Size{(1,)}}, ::Polyhedra.Hull{Float64, StaticArrays.SVector{1, Float64}, StaticArrays.Size{(1,)}})
Closest candidates are:
  sethrep!(::Any, ::Any, ::Any) at ~/.julia/packages/Polyhedra/BmL2i/src/defaultlibrary.jl:115
  sethrep!(::Interval{T, AT}, ::HRep) where {T, AT} at ~/.julia/packages/Polyhedra/BmL2i/src/interval.jl:203
Stacktrace:
 [1] setvrep!(p::Interval{Float64, StaticArrays.SVector{1, Float64}, StaticArrays.Size{(1,)}}, v::Polyhedra.Hull{Float64, StaticArrays.SVector{1, Float64}, StaticArrays.Size{(1,)}}, red::Polyhedra.Redundancy)
   @ Polyhedra ~/.julia/packages/Polyhedra/BmL2i/src/defaultlibrary.jl:116
 [2] detectvlinearity!(p::Interval{Float64, StaticArrays.SVector{1, Float64}, StaticArrays.Size{(1,)}}, solver::Nothing; kws::Base.Pairs{Symbol, Float64, Tuple{Symbol}, NamedTuple{(:ztol,), Tuple{Float64}}})
   @ Polyhedra ~/.julia/packages/Polyhedra/BmL2i/src/linearity.jl:56
 [3] removevredundancy!(p::Interval{Float64, StaticArrays.SVector{1, Float64}, StaticArrays.Size{(1,)}}; strongly::Bool, planar::Bool, kws::Base.Pairs{Symbol, Float64, Tuple{Symbol}, NamedTuple{(:ztol,), Tuple{Float64}}})
   @ Polyhedra ~/.julia/packages/Polyhedra/BmL2i/src/redundancy.jl:127
schillic commented 2 years ago

Thanks for fixing! Do you mind making a new release?

blegat commented 2 years ago

Done :)