Less than approx equals? <≈

Less than approx equals?

LazySets.jl internally uses LazySets._leq; you can check the definition in src/Utils/comparisons.jl, and the approximate equality can be changed with the set_x functions where x is atol, rtol or ztol. For example:

# approximate membership test
julia> [1.5, 1.5] ∈ LineSegment([1.5, 1.50000000000001], [1.5, 2.0])
true

# change the default Float64 tolerance
julia> r = LazySets._rtol(Float64);

julia> LazySets.set_rtol(Float64, 1e-20)
1.0e-20

julia> [1.5, 1.5] ∈ LineSegment([1.5, 1.50000000000001], [1.5, 2.0])
false

julia> LazySets.set_rtol(Float64, r); # revert change

For the intersection of line segments,

using LazySets, Plots

α = 1.5000000000001
β = 1.4999999999999999
A = LineSegment([1.0, β], [2.0, β])
B = LineSegment([1.5, α], [1.5, 2])
plot(A, lab="A")
plot!(B, lab="B")

LazySets.set_rtol(Float64, 1e-12)
@show intersection(A, B)
LazySets.set_rtol(Float64, 1e-20)
@show intersection(A, B)

intersection(A, B) = Singleton{Float64,Array{Float64,1}}([1.5, 1.5])
intersection(A, B) = EmptySet{Float64}(2)

(Note: for these examples you’ll need to checkout the branch mforets/robust_in_linesegment until it’s been merged :wink: )

1 Like