Set Interfaces
This section of the manual describes the interfaces for different set types. Every set that fits the description of an interface should also implement it. This helps in several ways:
avoid code duplicates,
provide functions for many sets at once,
allow changes in the source code without changing the API.
The interface functions are outlined in the interface documentation. See Common Set Representations for implementations of the interfaces.
The naming convention is such that all interface names (with the exception of the main abstract type LazySet
) should be preceded by Abstract
.
The following diagram shows the interface hierarchy.
LazySet
Every convex set in this library implements this interface.
LazySets.LazySet
— Type.LazySet{N}
Abstract type for convex sets, i.e., sets characterized by a (possibly infinite) intersection of halfspaces, or equivalently, sets $S$ such that for any two elements $x, y ∈ S$ and $0 ≤ λ ≤ 1$ it holds that $λ x + (1-λ) y ∈ S$.
Notes
LazySet
types should be parameterized with a type N
, typically N<:Real
, for using different numeric types.
Every concrete LazySet
must define the following functions:
σ(d::AbstractVector{N}, S::LazySet)
– the support vector ofS
in a given directiond
dim(S::LazySet)::Int
– the ambient dimension ofS
julia> subtypes(LazySet)
19-element Array{Union{DataType, UnionAll},1}:
LazySets.AbstractPointSymmetric
LazySets.AbstractPolytope
LazySets.CacheMinkowskiSum
LazySets.CartesianProduct
LazySets.CartesianProductArray
LazySets.ConvexHull
LazySets.ConvexHullArray
LazySets.EmptySet
LazySets.ExponentialMap
LazySets.ExponentialProjectionMap
LazySets.HalfSpace
LazySets.Hyperplane
LazySets.Intersection
LazySets.IntersectionArray
LazySets.Line
LazySets.LineSegment
LazySets.LinearMap
LazySets.MinkowskiSum
LazySets.MinkowskiSumArray
Support function and support vector
Every LazySet
type must define a function σ
to compute the support vector.
LazySets.support_vector
— Function.support_vector
Alias for the support vector σ.
LazySets.ρ
— Function.ρ(d::AbstractVector{N}, S::LazySet{N})::N where {N<:Real}
Evaluate the support function of a set in a given direction.
Input
d
– directionS
– convex set
Output
The support function of the set S
for the direction d
.
LazySets.support_function
— Function.support_function
Alias for the support function ρ.
Other globally defined set functions
LazySets.an_element
— Method.an_element(S::LazySet{N}) where {N<:Real}
Return some element of a convex set.
Input
S
– convex set
Output
An element of a convex set.
Point symmetric set
Point symmetric sets such as balls of different norms are characterized by a center. Note that there is a special interface combination Point symmetric polytope.
LazySets.AbstractPointSymmetric
— Type.AbstractPointSymmetric{N<:Real} <: LazySet{N}
Abstract type for point symmetric sets.
Notes
Every concrete AbstractPointSymmetric
must define the following functions:
center(::AbstractPointSymmetric{N})::Vector{N}
– return the center point
julia> subtypes(AbstractPointSymmetric)
3-element Array{Union{DataType, UnionAll},1}:
LazySets.Ball2
LazySets.Ballp
LazySets.Ellipsoid
Polytope
A polytope has finitely many vertices (V-representation) resp. facets (H-representation). Note that there is a special interface combination Point symmetric polytope.
LazySets.AbstractPolytope
— Type.AbstractPolytope{N<:Real} <: LazySet{N}
Abstract type for polytopic sets, i.e., sets with finitely many flat facets, or equivalently, sets defined as an intersection of a finite number of halfspaces, or equivalently, sets with finitely many vertices.
Notes
Every concrete AbstractPolytope
must define the following functions:
vertices_list(::AbstractPolytope{N})::Vector{Vector{N}}
– return a list of all vertices
julia> subtypes(AbstractPolytope)
4-element Array{Union{DataType, UnionAll},1}:
LazySets.AbstractPointSymmetricPolytope
LazySets.AbstractPolygon
LazySets.HPolytope
LazySets.VPolytope
This interface defines the following functions:
LazySets.linear_map
— Method.linear_map(M::AbstractMatrix, P::AbstractPolytope{N}) where {N<:Real}
Concrete linear map of an abstract polytype.
Input
M
– matrixP
– abstract polytype
Output
The polytope in V-representation obtained by applying the linear map $M$ to the set $P$. If the given polytope is two-dimensional, a polygon instead of a general polytope is returned.
Polygon
A polygon is a two-dimensional polytope.
LazySets.AbstractPolygon
— Type.AbstractPolygon{N<:Real} <: AbstractPolytope{N}
Abstract type for polygons (i.e., 2D polytopes).
Notes
Every concrete AbstractPolygon
must define the following functions:
tovrep(::AbstractPolygon{N})::VPolygon{N}
– transform into V-representationtohrep(::AbstractPolygon{N})::AbstractHPolygon{N}
– transform into H-representation
julia> subtypes(AbstractPolygon)
2-element Array{Union{DataType, UnionAll},1}:
LazySets.AbstractHPolygon
LazySets.VPolygon
HPolygon
An HPolygon is a polygon in H-representation (or constraint representation).
LazySets.AbstractHPolygon
— Type.AbstractHPolygon{N<:Real} <: AbstractPolygon{N}
Abstract type for polygons in H-representation (i.e., constraints).
Notes
Every concrete AbstractHPolygon
must have the following fields:
constraints::Vector{LinearConstraint{N}}
– the constraints
New subtypes should be added to the convert
method in order to be convertible.
julia> subtypes(AbstractHPolygon)
2-element Array{Union{DataType, UnionAll},1}:
LazySets.HPolygon
LazySets.HPolygonOpt
Point symmetric polytope
A point symmetric polytope is a combination of two other interfaces: Point symmetric set and Polytope.
AbstractPointSymmetricPolytope{N<:Real} <: AbstractPolytope{N}
Abstract type for point symmetric, polytopic sets. It combines the AbstractPointSymmetric
and AbstractPolytope
interfaces. Such a type combination is necessary as long as Julia does not support multiple inheritance.
Notes
Every concrete AbstractPointSymmetricPolytope
must define the following functions:
from
AbstractPointSymmetric
:center(::AbstractPointSymmetricPolytope{N})::Vector{N}
– return the center point
from
AbstractPolytope
:vertices_list(::AbstractPointSymmetricPolytope{N})::Vector{Vector{N}}
– return a list of all vertices
julia> subtypes(AbstractPointSymmetricPolytope)
4-element Array{Union{DataType, UnionAll},1}:
LazySets.AbstractHyperrectangle
LazySets.Ball1
LazySets.Interval
LazySets.Zonotope
Hyperrectangle
A hyperrectangle is a special point symmetric polytope with axis-aligned facets.
LazySets.AbstractHyperrectangle
— Type.AbstractHyperrectangle{N<:Real} <: AbstractPointSymmetricPolytope{N}
Abstract type for hyperrectangular sets.
Notes
Every concrete AbstractHyperrectangle
must define the following functions:
radius_hyperrectangle(::AbstractHyperrectangle{N})::Vector{N}
– return the hyperrectangle's radius, which is a full-dimensional vectorradius_hyperrectangle(::AbstractHyperrectangle{N}, i::Int)::N
– return the hyperrectangle's radius in thei
-th dimension
julia> subtypes(AbstractHyperrectangle)
4-element Array{Union{DataType, UnionAll},1}:
LazySets.AbstractSingleton
LazySets.BallInf
LazySets.Hyperrectangle
LazySets.SymmetricIntervalHull
Singleton
A singleton is a special hyperrectangle consisting of only one point.
LazySets.AbstractSingleton
— Type.AbstractSingleton{N<:Real} <: AbstractHyperrectangle{N}
Abstract type for sets with a single value.
Notes
Every concrete AbstractSingleton
must define the following functions:
element(::AbstractSingleton{N})::Vector{N}
– return the single elementelement(::AbstractSingleton{N}, i::Int)::N
– return the single element's entry in thei
-th dimension
julia> subtypes(AbstractSingleton)
2-element Array{Union{DataType, UnionAll},1}:
LazySets.Singleton
LazySets.ZeroSet
This interface defines the following functions:
LazySets.linear_map
— Method.linear_map(M::AbstractMatrix, P::AbstractPolytope{N}) where {N<:Real}
Concrete linear map of an abstract polytype.
Input
M
– matrixP
– abstract polytype
Output
The polytope in V-representation obtained by applying the linear map $M$ to the set $P$. If the given polytope is two-dimensional, a polygon instead of a general polytope is returned.
linear_map(M::AbstractMatrix, S::AbstractSingleton{N}) where {N<:Real}
Concrete linear map of an abstract singleton.
Input
M
– matrixS
– abstract singleton
Output
The abstract singleton of the same type of $S$ obtained by applying the linear map to the element in $S$.