It's All Set - LazySets Errors: Showing Types and set_tolerance not defined

Hi all,

I get two errors on LazySets tutorial at the last section, the first one:

using LazySets

println("=== Concrete set types ===\n")
for S in subtypes(LazySet, true)
    if !isoperationtype(S)
        println(S)
    end
end
println("\n=== Lazy set types ===\n")
for S in subtypes(LazySet, true)
    if isoperationtype(S)
        println(S)
    end
end

get:
=== Concrete set types ===

Ball1
Ball2
BallInf
Ballp
DensePolynomialZonotope
Ellipsoid
EmptySet
HParallelotope
HPolygon
HPolygonOpt
HPolyhedron
HPolytope
HalfSpace
Hyperplane
Hyperrectangle
Interval
LazySets.AbstractStar
Line
Line2D
LineSegment

MethodError: no method matching isoperationtype(::Type{QuadraticMap})
Closest candidates are:
** isoperationtype(::ConvexSet) at ~/.julia/packages/LazySets/7LPS2/src/Interfaces/ConvexSet.jl:796**
** isoperationtype(::Type{<:ConvexHull}) at ~/.julia/packages/LazySets/7LPS2/src/LazyOperations/ConvexHull.jl:53**
** isoperationtype(::Type{<:Singleton}) at ~/.julia/packages/LazySets/7LPS2/src/Sets/Singleton.jl:32**
** …**

Stacktrace:
** [1] top-level scope**
** @ ./In[65]:3**
** [2] eval**
** @ ./boot.jl:373 [inlined]**
** [3] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)**
** @ Base ./loading.jl:1196**

Then the second one:

import Polyhedra, CDDLib
using LazySets, LaTeXStrings, Optim
using Plots: plot, plot!, text, lens!, bbox

p(args...; kwargs...) = plot(xlims=(0,4), ylims=(0,4), ratio=1, lab="",
                        xlab=L"x_{1}", ylab=L"x_{2}", args...; kwargs...)
p!(args...; kwargs...) = plot!(lab="", args...; kwargs...);

polygon() = VPolygon([[1.0, 1.0], [1.000000001, 1.0]])

# default relative tolerance
@show LazySets._rtol(Float64)

P1 = polygon()

@show vertices_list(P1)

# increase relative tolerance
LazySets.set_rtol(Float64, 1e-9)

P2 = polygon()

@show vertices_list(P2)

p(xlims=(0.9999999985, 1.000000002), ylims=(0.9999999985, 1.000000002))
p!(P1)
p!(P2)

# reset relative tolerance to default
LazySets.set_tolerance(Float64)

p!()

get:
LazySets._rtol(Float64) = 1.0e-9
vertices_list(P1) = [[1.0, 1.0], [1.000000001, 1.0]]
vertices_list(P2) = [[1.0, 1.0], [1.000000001, 1.0]]

UndefVarError: set_tolerance not defined

Stacktrace:
** [1] getproperty(x::Module, f::Symbol)**
** @ Base ./Base.jl:35**
** [2] top-level scope**
** @ In[70]:30**
** [3] eval**
** @ ./boot.jl:373 [inlined]**
** [4] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)**
** @ Base ./loading.jl:1196**

For this first one, it seems the QuadraticMap type was added just a month ago to LazySets, and I think they missed to add a isoperationtype(::Type{QuadraticMap}) method (or maybe it was intentional, in which case the tutorial needs to be updated). Either way, I’ll open an issue for this, thanks for reporting it.

For now, you can do:

julia> for S in subtypes(LazySet, true)
           # these three types don't have an `isoperationtype` method, so work around it
           S in (QuadraticMap, SimpleSparsePolynomialZonotope, SparsePolynomialZonotope) && continue
           if !isoperationtype(S)
               println(S)
           end
       end

to print out the rest of the concrete set types.

1 Like

For the second issue, set_tolerance seems to have been moved into a separate package, so that line should be changed to:

LazySets.Comparison.set_tolerance(Float64)