Skip to content

3D volume fails on tiny point sets #321

@bqi343

Description

@bqi343

When using the default library (or CDDLib), an AssertionError is thrown when computing the volume of a 3D polyhedron where the same point is passed twice to vrep.

using Polyhedra, CDDLib, QHull

const libs = [Polyhedra.default_library(3, Float64), CDDLib.Library(:float), QHull.Library()]

function get_volume(point_set::Matrix{T}, lib) where {T}
    poly = polyhedron(vrep(point_set), lib)
    Polyhedra.volume(poly)
end

@testset "test_volume_tricky" begin
    points = [-1.0 0.0 1.0
        0.0 0.0 1.0
        0.0 0.0 0.0
        -1.0 -1.0 0.0
        -1.0 -1.0 0.0]
    for lib in libs
        # same error for default library or CDDLib
        # expected answer (0.16666666666666666) for qhull
        println(lib, " ", get_volume(points, lib))
    end
end
Full Stacktrace
test_volume_tricky: Error During Test at /Users/benq/.julia/packages/ReTest/WnRIG/src/ReTest.jl:517
  Got exception outside of a @test
  AssertionError: codim >= 0
  Stacktrace:
    [1] _triangulation(Δs::Vector{Vector{Polyhedra.Index{Float64, Vector{Float64}}}}, Δ::Vector{Polyhedra.Index{Float64, Vector{Float64}}}, v_idx::Vector{Polyhedra.Index{Float64, Vector{Float64}}}, h_idx::Vector{Polyhedra.Index{Float64, HalfSpace{Float64, Vector{Float64}}}}, incident_idx::Dict{Polyhedra.Index{Float64, HalfSpace{Float64, Vector{Float64}}}, Set{Polyhedra.Index{Float64, Vector{Float64}}}}, is_weak_adjacent::Dict{Tuple{Polyhedra.Index{Float64, HalfSpace{Float64, Vector{Float64}}}, Polyhedra.Index{Float64, HalfSpace{Float64, Vector{Float64}}}}, Bool}, codim::Int64)
      @ Polyhedra ~/.julia/packages/Polyhedra/Xhcfx/src/triangulation.jl:10
    [2] _triangulation(Δs::Vector{Vector{Polyhedra.Index{Float64, Vector{Float64}}}}, Δ::Vector{Polyhedra.Index{Float64, Vector{Float64}}}, v_idx::Vector{Polyhedra.Index{Float64, Vector{Float64}}}, h_idx::Vector{Polyhedra.Index{Float64, HalfSpace{Float64, Vector{Float64}}}}, incident_idx::Dict{Polyhedra.Index{Float64, HalfSpace{Float64, Vector{Float64}}}, Set{Polyhedra.Index{Float64, Vector{Float64}}}}, is_weak_adjacent::Dict{Tuple{Polyhedra.Index{Float64, HalfSpace{Float64, Vector{Float64}}}, Polyhedra.Index{Float64, HalfSpace{Float64, Vector{Float64}}}}, Bool}, codim::Int64) (repeats 4 times)
      @ Polyhedra ~/.julia/packages/Polyhedra/Xhcfx/src/triangulation.jl:34
    [3] triangulation_indices(p::DefaultPolyhedron{Float64, MixedMatHRep{Float64, Matrix{Float64}}, MixedMatVRep{Float64, Matrix{Float64}}})
      @ Polyhedra ~/.julia/packages/Polyhedra/Xhcfx/src/triangulation.jl:46
    [4] triangulation
      @ ~/.julia/packages/Polyhedra/Xhcfx/src/triangulation.jl:50 [inlined]
    [5] volume(p::DefaultPolyhedron{Float64, MixedMatHRep{Float64, Matrix{Float64}}, MixedMatVRep{Float64, Matrix{Float64}}})
      @ Polyhedra ~/.julia/packages/Polyhedra/Xhcfx/src/polyhedron.jl:100
    [6] get_volume(point_set::Matrix{Float64}, lib::DefaultLibrary{Float64})
      @ Main.InnerProductMaxTests ~/Dev/InnerProductMax/test/compare_chull.jl:9
    [7] macro expansion
      @ ~/Dev/InnerProductMax/test/compare_chull.jl:15 [inlined]
    [8] macro expansion
      @ ~/.julia/packages/ReTest/WnRIG/src/testset.jl:654 [inlined]
    [9] macro expansion
      @ ~/Dev/InnerProductMax/test/compare_chull.jl:13 [inlined]
   [10] top-level scope
      @ ~/.julia/packages/ReTest/WnRIG/src/ReTest.jl:517
   [11] eval
      @ ./boot.jl:368 [inlined]
   [12] (::ReTest.var"#80#98"{ReTest.Testset.Format})(mod::Module, ts::ReTest.TestsetExpr, pat::ReTest.And, chan::NamedTuple{(:out, :compute, :preview), Tuple{Distributed.RemoteChannel{Channel{Union{Nothing, ReTest.Testset.ReTestSet}}}, Channel{Nothing}, Nothing}})
      @ ReTest ~/.julia/packages/ReTest/WnRIG/src/ReTest.jl:1160
   [13] #invokelatest#2
      @ ./essentials.jl:729 [inlined]
   [14] invokelatest
      @ ./essentials.jl:726 [inlined]
   [15] #153
      @ /Applications/Julia-1.8.app/Contents/Resources/julia/share/julia/stdlib/v1.8/Distributed/src/remotecall.jl:425 [inlined]
   [16] run_work_thunk(thunk::Distributed.var"#153#154"{ReTest.var"#80#98"{ReTest.Testset.Format}, Tuple{Module, ReTest.TestsetExpr, ReTest.And, NamedTuple{(:out, :compute, :preview), Tuple{Distributed.RemoteChannel{Channel{Union{Nothing, ReTest.Testset.ReTestSet}}}, Channel{Nothing}, Nothing}}}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}}, print_error::Bool)
      @ Distributed /Applications/Julia-1.8.app/Contents/Resources/julia/share/julia/stdlib/v1.8/Distributed/src/process_messages.jl:70
   [17] remotecall_fetch(::Function, ::Distributed.LocalProcess, ::Module, ::Vararg{Any}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
      @ Distributed /Applications/Julia-1.8.app/Contents/Resources/julia/share/julia/stdlib/v1.8/Distributed/src/remotecall.jl:450
   [18] remotecall_fetch(::Function, ::Distributed.LocalProcess, ::Module, ::Vararg{Any})
      @ Distributed /Applications/Julia-1.8.app/Contents/Resources/julia/share/julia/stdlib/v1.8/Distributed/src/remotecall.jl:449
   [19] remotecall_fetch(::Function, ::Int64, ::Module, ::Vararg{Any}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
      @ Distributed /Applications/Julia-1.8.app/Contents/Resources/julia/share/julia/stdlib/v1.8/Distributed/src/remotecall.jl:492
   [20] remotecall_fetch
      @ /Applications/Julia-1.8.app/Contents/Resources/julia/share/julia/stdlib/v1.8/Distributed/src/remotecall.jl:492 [inlined]
   [21] macro expansion
      @ ~/.julia/packages/ReTest/WnRIG/src/ReTest.jl:1157 [inlined]
   [22] (::ReTest.var"#78#96"{Int64, ReTest.Testset.Format, Nothing, ReTest.Testset.ReTestSet, Base.Threads.Atomic{Bool}, Channel{Nothing}, Distributed.RemoteChannel{Channel{Union{Nothing, ReTest.Testset.ReTestSet}}}, Vector{Any}, ReTest.And, Module})()
      @ ReTest ./task.jl:484

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions