Conversion between set representations
This section of the manual lists the conversion functions between set representations.
Base.convert
— Methodconvert(::Type{Interval}, r::Rectification{N, IN}) where {N, IN<:Interval}
Convert a rectification of an interval to an interval.
Input
Interval
– target typer
– rectification of an interval
Output
An Interval
.
Base.convert
— Methodconvert(::Type{Interval}, ms::MinkowskiSum{N, IT, IT}) where {N, IT<:Interval}
Convert the Minkowski sum of two intervals to an interval.
Input
Interval
– target typems
– Minkowski sum of two intervals
Output
An interval.
Base.convert
— Methodconvert(::Type{Hyperrectangle}, cp::CartesianProduct{N, HN1, HN2})
where {N, HN1<:AbstractHyperrectangle, HN2<:AbstractHyperrectangle}
Convert the Cartesian product of two hyperrectangular sets to a single hyperrectangle.
Input
Hyperrectangle
– target typeS
– Cartesian product of two hyperrectangular sets
Output
A hyperrectangle.
Algorithm
The result is obtained by concatenating the center and radius of each hyperrectangle. This implementation uses the center
and radius_hyperrectangle
methods.
Base.convert
— Methodconvert(::Type{Hyperrectangle}, cpa::CartesianProductArray{N, HN})
where {N, HN<:AbstractHyperrectangle}
Convert the Cartesian product of a finite number of hyperrectangular sets to a single hyperrectangle.
Input
Hyperrectangle
– target typeS
– Cartesian product array of hyperrectangular set
Output
A hyperrectangle.
Algorithm
This implementation uses the center
and radius_hyperrectangle
methods of AbstractHyperrectangle
.
Base.convert
— Methodconvert(::Type{Hyperrectangle},
cpa::CartesianProductArray{N, IN}) where {N, IN<:Interval}
Convert the Cartesian product of a finite number of intervals to a single hyperrectangle.
Input
Hyperrectangle
– target typeS
– Cartesian product array of intervals
Output
A hyperrectangle.
Algorithm
This implementation uses the min
and max
methods of Interval
to reduce the allocations and improve performance (see LazySets#1143).
Base.convert
— Methodconvert(::Type{Hyperrectangle}, r::Rectification{N, AH})
where {N, AH<:AbstractHyperrectangle}
Convert a rectification of a hyperrectangle to a hyperrectangle.
Input
Hyperrectangle
– target typer
– rectification of a hyperrectangle
Output
A Hyperrectangle
.
Base.convert
— Methodconvert(::Type{HPolygon}, X::LazySet; [check_boundedness]::Bool=true,
prune::Bool=true)
Convert a two-dimensional polytopic set to a polygon in constraint representation.
Input
HPolygon
– target typeX
– two-dimensional polytopic setcheck_boundedness
– (optional, default!isboundedtype(typeof(X))
) iftrue
check whether the setX
is bounded before creating the polygonprune
– (optional, default:true
) flag for removing redundant constraints in the end
Output
A polygon in constraint representation.
Algorithm
We compute the list of constraints of X
, then instantiate the polygon.
Base.convert
— Methodconvert(T::Type{HPolygon}, P::VPolygon)
Convert a polygon in vertex representation to a polygon in constraint representation.
Input
HPolygon
– target typeP
– polygon in vertex representation
Output
A polygon in constraint representation.
Base.convert
— Methodconvert(::Type{HPolygon}, L::LineSegment{N}) where {N}
Convert a line segment to a polygon in constraint representation.
Input
HPolygon
– target typeL
– line segmentprune
– (optional, default:false
) flag for removing redundant constraints in the end
Output
A flat polygon in constraint representation with the minimal number of constraints (four).
Base.convert
— Methodconvert(::Type{HPolygon}, S::AbstractSingleton{N}) where {N}
Convert a singleton to a polygon in constraint representation.
Input
HPolygon
– target typeS
– singleton
Output
A polygon in constraint representation with the minimal number of constraints (three).
Base.convert
— Methodconvert(::Type{HPolygonOpt}, X::LazySet; [check_boundedness]::Bool=true,
prune::Bool=true)
Convert a two-dimensional polytopic set to a polygon in constraint representation.
Input
HPolygonOpt
– target typeX
– two-dimensional polytopic setcheck_boundedness
– (optional, default!isboundedtype(typeof(X))
) iftrue
check whether the setX
is bounded before creating the polygonprune
– (optional, default:true
) flag for removing redundant constraints in the end
Output
A polygon in constraint representation.
Algorithm
We compute the list of constraints of X
, then instantiate the polygon.
Base.convert
— Methodconvert(T::Type{HPolygonOpt}, P::VPolygon)
Convert a polygon in vertex representation to a polygon in constraint representation.
Input
HPolygonOpt
– target typeP
– polygon in vertex representation
Output
A polygon in constraint representation.
Base.convert
— Methodconvert(::Type{HPolygonOpt}, L::LineSegment{N}) where {N}
Convert a line segment to a polygon in constraint representation.
Input
HPolygonOpt
– target typeL
– line segmentprune
– (optional, default:false
) flag for removing redundant constraints in the end
Output
A flat polygon in constraint representation with the minimal number of constraints (four).
Base.convert
— Methodconvert(::Type{HPolygonOpt}, S::AbstractSingleton{N}) where {N}
Convert a singleton to a polygon in constraint representation.
Input
HPolygonOpt
– target typeS
– singleton
Output
A polygon in constraint representation with the minimal number of constraints (three).
Base.convert
— Methodconvert(::Type{VPolygon}, P::AbstractHPolygon)
Convert a polygon in constraint representation to a polygon in vertex representation.
Input
VPolygon
– target typeP
– polygon in constraint representation
Output
A polygon in vertex representation.
Base.convert
— Methodconvert(::Type{Zonotope}, S::LinearMap{N, ZN})
where {N, ZN<:AbstractZonotope}
Convert the lazy linear map of a zonotopic set to a zonotope.
Input
Zonotope
– target typeS
– linear map of a zonotopic set
Output
A zonotope.
Algorithm
This method first applies the (concrete) linear map to the zonotopic set and then converts the result to a Zonotope
type.
Base.convert
— Methodconvert(::Type{Zonotope}, S::LinearMap{N, CartesianProduct{N, HN1, HN2}}
) where {N, HN1<:AbstractHyperrectangle,
HN2<:AbstractHyperrectangle}
Convert the lazy linear map of the Cartesian product of two hyperrectangular sets to a zonotope.
Input
Zonotope
– target typeS
– linear map of the Cartesian product of hyperrectangular sets
Output
A zonotope.
Algorithm
This method first converts the Cartesian product to a zonotope, and then applies the (concrete) linear map to the zonotope.
Base.convert
— Methodconvert(::Type{Zonotope},S::LinearMap{N, CartesianProductArray{N, HN}})
where {N, HN<:AbstractHyperrectangle}
Convert the lazy linear map of the Cartesian product of a finite number of hyperrectangular sets to a zonotope.
Input
Zonotope
– target typeS
– linear map of aCartesianProductArray
of hyperrectangular sets
Output
A zonotope.
Algorithm
This method first converts the Cartesian product array to a zonotope, and then applies the (concrete) linear map to the zonotope.
Base.convert
— Methodconvert(::Type{Zonotope}, cp::CartesianProduct{N, ZN1, ZN2}
) where {N, ZN1<:AbstractZonotope, ZN2<:AbstractZonotope}
Convert the Cartesian product of two zonotopic sets to a new zonotope.
Input
Zonotope
– target typeS
– Cartesian product of two zonotopic sets
Output
A zonotope.
Algorithm
The Cartesian product is obtained by:
- Concatenating the centers of each input zonotope.
- Arranging the generators in block-diagonal fashion, and filled with zeros in the off-diagonal; for this reason, the generator matrix of the returned zonotope is built as a sparse matrix.
Base.convert
— Methodconvert(::Type{Zonotope}, cp::CartesianProduct{N, HN1, HN2}) where {N,
HN1<:AbstractHyperrectangle, HN2<:AbstractHyperrectangle}
Convert the Cartesian product of two hyperrectangular sets to a zonotope.
Input
Zonotope
– target typecp
– Cartesian product of two hyperrectangular sets
Output
This method falls back to the conversion of the Cartesian product to a single hyperrectangle, and then from a hyperrectangle to a zonotope.
Base.convert
— Methodconvert(::Type{Zonotope}, cpa::CartesianProductArray{N, AZ})
where {N, AZ<:AbstractZonotope}
Convert a Cartesian product array of zonotopic sets to a zonotope.
Input
Zonotope
– target typecpa
– Cartesian product array of zonotopic sets
Output
A zonotope with sparse matrix representation.
Base.convert
— Methodconvert(::Type{Zonotope}, cpa::CartesianProductArray{N, HN})
where {N, HN<:AbstractHyperrectangle}
Convert the Cartesian product array of hyperrectangular sets to a zonotope.
Input
Zonotope
– target typecpa
– Cartesian product array of hyperrectangular sets
Output
A zonotope.
Algorithm
This method falls back to the conversion of the Cartesian product to a single hyperrectangle, and then from a hyperrectangle to a zonotope.
Base.convert
— Methodconvert(::Type{CartesianProduct{N, Interval{N}, Interval{N}}},
H::AbstractHyperrectangle{N}) where {N}
Convert a two-dimensional hyperrectangle to the Cartesian product of two intervals.
Input
CartesianProduct
– target typeH
– hyperrectangle
Output
The Cartesian product of two intervals.
Base.convert
— Methodconvert(::Type{CartesianProductArray{N, Interval{N}}},
H::AbstractHyperrectangle{N}) where {N}
Convert a hyperrectangle to the Cartesian product array of intervals.
Input
CartesianProductArray
– target typeH
– hyperrectangle
Output
The Cartesian product of a finite number of intervals.
Base.convert
— Methodconvert(::Type{MinkowskiSumArray},
X::MinkowskiSum{N, ST, MinkowskiSumArray{N, ST}}) where {N, ST}
Convert the Minkowski sum of a Minkowski sum array to a Minkowski sum array.
Input
MinkowskiSumArray
– target typeX
– Minkowski sum of a Minkowski sum array
Output
A Minkowski sum array.
Base.convert
— Methodconvert(::Type{STAR}, P::AbstractPolyhedron{N}) where {N}
Convert a polyhedral set to a star set represented as a lazy affine map.
Input
STAR
– target typeP
– polyhedral set
Output
A star set.
Base.convert
— Methodconvert(::Type{STAR}, X::Star)
Convert a star set to its equivalent representation as a lazy affine map.
Input
STAR
– target typeX
– star set
Output
A star set.
Base.convert
— Methodconvert(::Type{SimpleSparsePolynomialZonotope}, Z::AbstractZonotope)
Convert a zonotope to a simple sparse polynomial zonotope.
Input
SimpleSparsePolynomialZonotope
– target typeZ
– zonotopic set
Output
A simple sparse polynomial zonotope.
Algorithm
This method implements Proposition 3 in [1].
[1] Kochdumper, Althoff. Sparse polynomial zonotopes - a novel set representation for reachability analysis. 2021
Base.convert
— Methodconvert(::Type{SimpleSparsePolynomialZonotope}, SPZ::SparsePolynomialZonotope)
Convert a sparse polynomial zonotope to simple sparse polynomial zonotope.
Input
SimpleSparsePolynomialZonotope
– target typeSPZ
– sparse polynomial zonotope
Output
A simple sparse polynomial zonotope.
Algorithm
The method implements Proposition 3.1.4 from [1].
[1] Kochdumper, Niklas. Extensions of polynomial zonotopes and their application to verification of cyber-physical systems. PhD diss., Technische Universität München, 2022.
Base.convert
— Methodconvert(::Type{SparsePolynomialZonotope}, Z::AbstractZonotope{N}) where {N}
Convert a zonotope to sparse polynomial zonotope.
Input
SparsePolynomialZonotope
– target typeZ
– zonotopic set
Output
A sparse polynomial zonotope.
Algorithm
The method implements Proposition 3.1.9 from [1].
[1] Kochdumper, Niklas. Extensions of polynomial zonotopes and their application to verification of cyber-physical systems. PhD diss., Technische Universität München, 2022.
Base.convert
— Methodconvert(::Type{SparsePolynomialZonotope}, SSPZ::SimpleSparsePolynomialZonotope)
Convert a simple sparse polynomial zonotope to a sparse polynomial zonotope.
Input
SparsePolynomialZonotope
– target typeSSPZ
– simple sparse polynomial zonotope
Output
A sparse polynomial zonotope.