JuliaReach / LazySets.jl

Scalable symbolic-numeric set computations in Julia
https://juliareach.github.io/LazySets.jl/
Other
226 stars 32 forks source link

Plotting of lazy intersection can crash #2790

Open schillic opened 3 years ago

schillic commented 3 years ago

The emptiness check can crash for lazy intersections. We should catch such an error and continue with the overapproximation. If we later detect that the set is empty, we would just skip the plotting.

julia> X = VPolygon([[0.0, 3.0], [3.0, 1.0], [3.0, 3.0]])
julia> Y = VPolygon([[0.0, 0.0], [3.0, 0.0], [0.0, 2.0]]) ⊕ Ball2([0.0, 0.0], 0.0)

julia> plot(X ∩ Y)
ERROR: AssertionError: this function requires that the list of constraints is available for both arguments; try overapproximating with an `HPolytope` first
Stacktrace:
  [1] macro expansion
    @ ~/.julia/dev/LazySets/src/Assertions/Assertions.jl:23 [inlined]
  [2] minkowski_sum(P::VPolygon{Float64, Vector{Float64}}, Q::Ball2{Float64, Vector{Float64}}; backend::Nothing, algorithm::Nothing, prune::Bool)
    @ LazySets ~/.julia/dev/LazySets/src/ConcreteOperations/minkowski_sum.jl:68
  [3] minkowski_sum(P::VPolygon{Float64, Vector{Float64}}, Q::Ball2{Float64, Vector{Float64}})
    @ LazySets ~/.julia/dev/LazySets/src/ConcreteOperations/minkowski_sum.jl:49
  [4] constraints_list(ms::MinkowskiSum{Float64, VPolygon{Float64, Vector{Float64}}, Ball2{Float64, Vector{Float64}}})
    @ LazySets ~/.julia/dev/LazySets/src/LazyOperations/MinkowskiSum.jl:213
  [5] _normal_Vector(P::MinkowskiSum{Float64, VPolygon{Float64, Vector{Float64}}, Ball2{Float64, Vector{Float64}}})
    @ LazySets ~/.julia/dev/LazySets/src/Sets/HalfSpace.jl:519
  [6] _is_intersection_empty_polyhedron(P::VPolygon{Float64, Vector{Float64}}, X::MinkowskiSum{Float64, VPolygon{Float64, Vector{Float64}}, Ball2{Float64, Vector{Float64}}}, witness::Bool; solver::Nothing, algorithm::String)
    @ LazySets ~/.julia/dev/LazySets/src/ConcreteOperations/isdisjoint.jl:1024
  [7] #is_intersection_empty#375
    @ ~/.julia/dev/LazySets/src/ConcreteOperations/isdisjoint.jl:995 [inlined]
  [8] is_intersection_empty (repeats 2 times)
    @ ~/.julia/dev/LazySets/src/ConcreteOperations/isdisjoint.jl:995 [inlined]
  [9] isempty(cap::Intersection{Float64, VPolygon{Float64, Vector{Float64}}, MinkowskiSum{Float64, VPolygon{Float64, Vector{Float64}}, Ball2{Float64, Vector{Float64}}}})
    @ LazySets ~/.julia/dev/LazySets/src/LazyOperations/Intersection.jl:656
 [10] plot_recipe(cap::Intersection{Float64, VPolygon{Float64, Vector{Float64}}, MinkowskiSum{Float64, VPolygon{Float64, Vector{Float64}}, Ball2{Float64, Vector{Float64}}}}, ε::Float64, Nφ::Int64)
    @ LazySets ~/.julia/dev/LazySets/src/LazyOperations/Intersection.jl:684
 [11] plot_recipe(cap::Intersection{Float64, VPolygon{Float64, Vector{Float64}}, MinkowskiSum{Float64, VPolygon{Float64, Vector{Float64}}, Ball2{Float64, Vector{Float64}}}}, ε::Float64)
    @ LazySets ~/.julia/dev/LazySets/src/LazyOperations/Intersection.jl:682
 [12] macro expansion
    @ ~/.julia/dev/LazySets/src/Plotting/plot_recipes.jl:511 [inlined]
[...]
schillic commented 2 years ago

I just had a similar crash in the auxiliary function _update_plot_limits!, which computes a box approximation. If the intersection is empty, that will crash.