Unary operations on sets
In this section we show which typical set operations this library supports.
The following table lists all operations that take one set as argument in the columns. In the rows we list all set types, both the interfaces (where we abbreviate the Abstract
prefix), the basic set types, and the lazy set operations, each sorted alphabetically. The table entries have the following meaning.
- "x" indicates that the operation is implemented for the respective set type.
- "i" indicates that the operation is inherited from a supertype.
- "(·)" indicates that the operation is partly implemented/inherited.
type ↓ \ operation → | dim | ρ | σ | an_element | ∈ | isempty | isbounded | linear_map | translate | norm | radius | diameter |
---|---|---|---|---|---|---|---|---|---|---|---|---|
Interfaces | ||||||||||||
LazySet | x | x | x | x | ||||||||
APolytope | i | i | x | x | x | i | ||||||
ACentrallySymmetric | x | i | x | x | x | i | ||||||
ACentrallySymmetricPolytope | i | i | i | x | i | i | i | |||||
APolygon | x | i | i | i | i | i | i | |||||
AHyperrectangle | i | i | x | i | x | i | i | i | x | x | i | |
AHPolygon | i | i | x | x | i | i | i | i | ||||
ASingleton | i | i | x | i | x | i | i | x | i | i | i | |
Basic set types | ||||||||||||
Ball1 | i | i | x | i | x | i | i | i | x | i | ||
Ball2 | i | i | x | i | x | i | i | x | i | |||
BallInf | i | i | i | i | i | i | i | i | x | i | x | i |
Ballp | i | i | x | i | x | i | i | x | i | |||
Ellipsoid | i | x | x | i | x | i | i | x | i | |||
EmptySet | x | i | x | x | x | x | x | x | x | x | x | |
HalfSpace | x | x | x | x | x | x | x | x | i | |||
HPolygon /HPolygonOpt | i | i | x | i | i | i | i | i | x | i | ||
HPolyhedron | x | x | x | i | x | x | x | x | x | i | ||
HPolytope | x | x | x | i | x | x | i | x | x | i | ||
Hyperplane | x | x | x | x | x | x | x | x | i | |||
Hyperrectangle | i | i | i | i | i | i | i | i | x | i | i | i |
Interval | x | i | x | x | x | i | i | i | x | i | i | i |
Line2D | x | i | x | x | x | x | x | x | i | |||
LineSegment | x | i | x | x | x | i | i | i | x | i | ||
Singleton | i | i | i | i | i | i | i | i | x | i | i | i |
Universe | x | x | x | x | x | x | x | x | x | x | x | |
VPolygon | i | i | x | x | x | i | i | x | x | i | ||
VPolytope | x | i | x | i | x | i | i | x | x | i | ||
ZeroSet | x | i | x | i | x | i | i | x | x | i | i | i |
Zonotope | i | x | x | i | x | i | i | x | x | i | ||
Lazy set operation types | ||||||||||||
CartesianProduct | x | x | x | i | x | x | x | i | ||||
CartesianProductArray | x | x | x | i | x | x | x | i | ||||
ConvexHull | x | x | x | i | x | x | i | |||||
ConvexHullArray | x | x | x | i | x | x | i | |||||
ExponentialMap | x | x | x | i | x | x | x | i | ||||
ExponentialProjectionMap | x | i | x | i | x | x | i | |||||
Intersection | x | x | i | x | x | x | i | |||||
IntersectionArray | x | i | i | x | x | i | ||||||
LinearMap | x | x | x | x | x | x | x | i | ||||
MinkowskiSum | x | x | x | i | x | x | i | |||||
MinkowskiSumArray | x | x | x | i | x | x | i | |||||
CachedMinkowskiSumArray | x | i | x | i | x | x | i | |||||
ResetMap | x | x | x | x | x | i | ||||||
SymmetricIntervalHull | x | i | x | i | i | i | i | i | i | i | i | |
Translation | x | x | x | x | x | x | x | i | ||||
Non-convex operations | ||||||||||||
Complement | x | x | x | |||||||||
Rectification | x | i | (x) | x | x | x | x | |||||
UnionSet | x | x | x | x | x | x | x | |||||
UnionSetArray | x | x | x | x | x | x | x |
Examples
We use the following four sets for illustration.
using LazySets, LazySets.Approximations, Plots
B1 = Ball1(-ones(2), 1.)
B2 = Ball2(ones(2), 1.)
BI = BallInf(zeros(2), 1.)
H = Hyperrectangle(ones(2), ones(2))
sets = [B1, B2, BI, H]
function plot_sets(sets)
for S in sets
println(S)
plot!(S, 1e-2, fillalpha=0.1)
end
end
function plot_points(points, prefix)
for i in eachindex(points)
p = points[i]
num_occur = length(findfirst(x -> x == p, points[1:i]))
x = p[1]
y = p[2]
if num_occur == 1
x += 0.15
elseif num_occur == 2
y += 0.15
elseif num_occur == 3
x -= 0.15
else
y -= 0.15
end
plot!(Singleton(p))
plot!(annotations=(x, y, text("$(prefix)$(i)")))
end
end
plot1 = plot()
plot_sets(sets)
plot1
dim
This function returns the dimension of the set.
dim(B1), dim(B2), dim(BI), dim(H)
(2, 2, 2, 2)
ρ
/σ
These functions return the support function resp. the support vector of the set.
an_element
This function returns some element in the set. Consecutive calls to this function typically return the same element.
an_element(B1), an_element(B2), an_element(BI), an_element(H)
([-1.0, -1.0], [1.0, 1.0], [0.0, 0.0], [1.0, 1.0])
∈
This function checks containment of a given vector in the set. The operator can be used in infix notation (v ∈ S
) and in inverse operand order (S ∋ v
). Alias: in
p1 = [1.5, 1.5]
p2 = [0.1, 0.1]
p3 = [-0.9, -0.8]
points = [p1, p2, p3]
for p in [p1, p2, p3]
println("$p ∈ (B1, B2, BI, H)? ($(p ∈ B1), $(p ∈ B2), $(p ∈ BI), $(p ∈ H))")
end
[1.5, 1.5] ∈ (B1, B2, BI, H)? (false, true, false, true)
[0.1, 0.1] ∈ (B1, B2, BI, H)? (false, false, true, true)
[-0.9, -0.8] ∈ (B1, B2, BI, H)? (true, false, true, false)
plot1 = plot()
plot_sets(sets)
plot_points(points, "p")
plot1
isempty
This function checks if the set is empty.
linear_map
This function applies a concrete linear map to the set. The resulting set may be of a different type.
norm
This function returns the norm of a set. It is defined as the norm of the enclosing ball (of the given norm) of minimal volume centered in the origin.
# print 1-norm, 2-norm, and infinity norm (if available)
println(("-", "-", norm(B1, Inf)))
println(("-", "-", norm(B2, Inf)))
println((norm(BI, 1), norm(BI, 2), norm(BI, Inf)))
println((norm(H, 1), norm(H, 2), norm(H, Inf)))
("-", "-", 2.0)
("-", "-", 2.0)
(2.0, 1.4142135623730951, 1.0)
(4.0, 2.8284271247461903, 2.0)
radius
This function returns the radius of a set. It is defined as the radius of the enclosing ball (of the given norm) of minimal volume with the same center.
radius(B1), radius(B2), radius(BI), radius(H)
(1.0, 1.0, 1.0, 1.0)
diameter
This function returns the diameter of a set. It is defined as the diameter of the enclosing ball (of the given norm) of minimal volume with the same center. The implementation is inherited for all set types if the norm is the infinity norm, in which case the result is defined as twice the radius.
diameter(B1), diameter(B2), diameter(BI), diameter(H)
(2.0, 2.0, 2.0, 2.0)