LazySets.jl icon indicating copy to clipboard operation
LazySets.jl copied to clipboard

Support function of lazy intersection with Optim depends on the order of the operands

Open schillic opened this issue 4 years ago • 2 comments

The box approximation with Optim is too coarse.

julia> X = BallInf([1.0, 2.0], 0.5);
julia> Y = linear_map([1 0; -1 1], BallInf([2.0, 2.0], 1.0));

julia> Z = box_approximation(X ∩ Y)  # requires Optim
Hyperrectangle{Float64, Vector{Float64}, Vector{Float64}}([1.2499999998151363, 1.9999999999999998], [0.25000000018486335, 0.4999999999999998])

julia> plot(X)
julia> plot!(Y)
julia> plot!(Z, ls=:dash)

2

Note that with the "min" heuristics the result of box_approximate is correct.

schillic avatar Jul 23 '21 16:07 schillic

as in other cases, we could make that Z = box_approximation(::Intersection) concretizes its input if it's 2D and use the fallback otherwise. this has two advantages, it is faster and more precise.

mforets avatar Jul 23 '21 16:07 mforets

The problem is with the order of the operands. We choose to iterate the constraints of the second set. One option is to do it symmetrically.

https://github.com/JuliaReach/LazySets.jl/blob/e46871a72fd5c9a8ee3d2d76d6d1d506fc22ffb1/src/LazyOperations/Intersection.jl#L454-L455

julia> W = box_approximation(Y ∩ X)
Hyperrectangle{Float64, Vector{Float64}, Vector{Float64}}([1.2500000017389405, 1.74999999878812], [0.25000000173894055, 0.2500000012118808])

julia> plot!(W, ls=:dot)

2

schillic avatar Jul 23 '21 16:07 schillic