# Conversion between set representations

This section of the manual lists the conversion functions between set representations.

Base.convertMethod
convert(T::Type{HPOLYGON}, P::VPolygon) where {HPOLYGON<:AbstractHPolygon}

Converts a polygon in vertex representation to a polygon in constraint representation.

Input

• HPOLYGON – type used for dispatch
• P – polygon in vertex representation

Output

A polygon in constraint representation.

source
Base.convertMethod
convert(::Type{Hyperrectangle}, H::AbstractHyperrectangle)

Convert a hyperrectangular set to a hyperrectangle.

Input

• Hyperrectangle – hyperrectangle type, used for dispatch
• H – hyperrectangular set

Output

A hyperrectangle.

Examples

julia> convert(Hyperrectangle, Interval(0.0, 1.0))
Hyperrectangle{Float64, Vector{Float64}, Vector{Float64}}([0.5], [0.5])
source
Base.convertMethod
convert(::Type{Interval}, H::AbstractHyperrectangle)

Converts a hyperrectangular set to an interval.

Input

• Interval – interval type, used for dispatch
• H – hyperrectangular set

Output

An interval.

Examples

julia> convert(Interval, Hyperrectangle([0.5], [0.5]))
Interval{Float64, IntervalArithmetic.Interval{Float64}}([0, 1])
source
Base.convertMethod
convert(::Type{Interval}, S::ConvexSet{N}) where {N<:Real}

Converts a convex set to an interval.

Input

• Interval – interval type, used for dispatch
• S – convex set

Output

An interval.

source
Base.convertMethod
convert(::Type{Hyperrectangle},
cpa::CartesianProductArray{N, HN}) where {N<:Real, HN<:AbstractHyperrectangle{N}}

Converts the cartesian product of a finite number of hyperrectangular sets to a single hyperrectangle.

Input

• Hyperrectangle – type used for dispatch
• S – cartesian product array of hyperrectangular set

Output

A hyperrectangle.

Algorithm

This implementation uses the center and radius_hyperrectangle methods of AbstractHyperrectangle.

source
Base.convertMethod
convert(::Type{Hyperrectangle},
cpa::CartesianProductArray{N, Interval{N}}) where {N<:Real}

Converts the cartesian product of a finite number of intervals to a single hyperrectangle.

Input

• Hyperrectangle – type used for dispatch
• S – cartesian product array of intervals

Output

A hyperrectangle.

Algorithm

This implementation uses the min and max methods of Interval to reduce the allocatons and improve performance (see LazySets#1143).

source
Base.convertMethod
convert(::Type{HPOLYGON}, H::AbstractHyperrectangle) where
{HPOLYGON<:AbstractHPolygon}

Converts a hyperrectangular set to a polygon in constraint representation.

Input

• HPOLYGON – type used for dispatch
• H – hyperrectangular set

Output

A polygon in constraint representation.

source
Base.convertMethod
convert(::Type{HPOLYGON}, P::HPolytope{N, VN};
prune::Bool=true) where {N<:Real, VN<:AbstractVector{N}, HPOLYGON<:AbstractHPolygon}

Convert from 2D polytope in H-representation to polygon in H-representation.

Input

• type – target type
• P – source polytope (must be 2D)
• prune – (optional, default: true) flag for removing redundant constraints in the end

Output

The 2D polytope represented as polygon.

source
Base.convertMethod
convert(::Type{HPOLYGON}, S::AbstractSingleton{N}
) where {N<:Real, HPOLYGON<:AbstractHPolygon}

Convert from singleton to polygon in H-representation.

Input

• type – target type
• S – singleton

Output

A polygon in constraint representation with the minimal number of constraints (three).

source
Base.convertMethod
convert(::Type{HPOLYGON}, L::LineSegment{N}
) where {N<:Real, HPOLYGON<:AbstractHPolygon}

Convert from line segment to polygon in H-representation.

Input

• type – target type
• L – line segment
• prune – (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).

source
Base.convertMethod
convert(::Type{HPOLYGON}, X::ConvexSet; [check_boundedness]::Bool=true) where {HPOLYGON<:AbstractHPolygon}

Converts a polyhedral set to a polygon in vertex representation.

Input

• PT – type used for dispatch
• X – set
• check_boundedness – (optional, default true) if true check whether the set X is bounded before creating the polygon

Output

A polygon in constraint representation.

Algorithm

We compute the list of constraints of X, then instantiate the polygon.

source
Base.convertMethod
convert(::Type{HPolyhedron}, P::AbstractPolytope)

Convert a polytopic set to a polyhedron in H-representation.

Input

• type – target type
• P – source polytope

Output

The given polytope represented as a polyhedron in constraint representation.

source
Base.convertMethod
convert(::Type{HPolytope}, P::AbstractHPolygon)

Convert from polygon in H-representation to polytope in H-representation.

Input

• type – target type
• P – source polygon

Output

The polygon represented as 2D polytope.

source
Base.convertMethod
convert(::Type{HPolytope}, H::AbstractHyperrectangle)

Converts a hyperrectangular set to a polytope in constraint representation.

Input

• HPolytope – type used for dispatch
• H – hyperrectangular set

Output

A polytope in constraint representation.

source
Base.convertMethod
convert(::Type{HPolytope}, P::AbstractPolytope)

Convert a polytopic set to a polytope in H-representation.

Input

• type – target type
• P – source polytope

Output

The given polytope represented as a polytope in constraint representation.

Algorithm

First the list of constraints of P is computed, then the corresponding HPolytope is created.

source
Base.convertMethod
convert(::Type{HPolytope}, P::VPolytope)

Convert from polytope in V-representation to polytope in H-representation.

Input

• type – target type
• P – source polytope

Output

The polytope in the dual representation.

Algorithm

The tohrep function is invoked. It requires the Polyhedra package.

source
Base.convertMethod
convert(::Type{VPolygon}, P::AbstractHPolygon)

Converts a polygon in constraint representation to a polygon in vertex representation.

Input

• VPolygon – type used for dispatch
• P – polygon in constraint representation

Output

A polygon in vertex representation.

source
Base.convertMethod
convert(::Type{VPolytope}, X::ConvexSet; [prune]::Bool=true)

Generic conversion to polytope in vertex representation.

Input

• type – target type
• X – set
• prune – (optional, default: true) option to remove redundant vertices

Output

The given set represented as a polytope in vertex representation.

Algorithm

We compute the list of vertices of X and wrap the result in a polytope in vertex representation, VPolytope. Use the option prune to select whether or not to remove redundant vertices before constructing the polytope.

source
Base.convertMethod
convert(::Type{VPolytope}, P::AbstractPolytope)

Convert polytopic type to polytope in V-representation.

Input

• type – target type
• P – source polytope

Output

The set P represented as a VPolytope.

source
Base.convertMethod
convert(::Type{VPolytope}, P::HPolytope)

Convert from polytope in H-representation to polytope in V-representation.

Input

• type – target type
• P – source polytope

Output

The polytope in the dual representation.

Algorithm

The tovrep function is invoked. It requires the Polyhedra package.

source
Base.convertMethod
convert(::Type{Zonotope}, Z::AbstractZonotope)

Converts a zonotopic set to a zonotope.

Input

• Zonotope – type, used for dispatch
• H – zonotopic set

Output

A zonotope.

source
Base.convertMethod
convert(::Type{IntervalArithmetic.IntervalBox}, H::AbstractHyperrectangle)

Converts a hyperrectangular set to an IntervalBox from IntervalArithmetic.

Input

• IntervalBox – type used for dispatch
• H – hyperrectangular set

Output

An IntervalBox.

source
Base.convertMethod
convert(::Type{Hyperrectangle}, IB::IntervalArithmetic.IntervalBox)

Converts an IntervalBox from IntervalArithmetic to a hyperrectangular set.

Input

• Hyperrectangle – type used for dispatch
• IB – interval box

Output

A Hyperrectangle.

Notes

IntervalArithmetic.IntervalBox uses static vectors to store each component interval, hence the resulting Hyperrectangle has its center and radius represented as a static vector (SArray).

source
Base.convertMethod
convert(::Type{Zonotope}, cp::CartesianProduct{N, ZN1, ZN2}
) where {N<:Real, ZN1<:AbstractZonotope{N}, ZN2<:AbstractZonotope{N}}

Converts the cartesian product of two zonotopes to a new zonotope.

Input

• Zonotope – type used for dispatch
• S – cartesian product of two zonotopes

Output

A zonotope.

Algorithm

The cartesian product is obtained by:

• Concatenating the centers of each input zonotope.
• Arranging the generators in block-diagional 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.
source
Base.convertMethod
convert(::Type{Hyperrectangle},
cp::CartesianProduct{N, HN1, HN2}) where {N<:Real, HN1<:AbstractHyperrectangle{N}, HN2<:AbstractHyperrectangle{N}}

Converts the cartesian product of two hyperrectangular sets to a single hyperrectangle.

Input

• Hyperrectangle – type used for dispatch
• S – 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 of AbstractHyperrectangle.

source
Base.convertMethod
convert(::Type{Zonotope}, cp::CartesianProduct{N, HN1, HN2}) where {N<:Real,
HN1<:AbstractHyperrectangle{N}, HN2<:AbstractHyperrectangle{N}}

Converts the cartesian product of two hyperrectangular sets to a zonotope.

Input

• Zonotope – type, used for dispatch
• cp – 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.

source
Base.convertMethod
convert(::Type{Zonotope}, cpa::CartesianProductArray{N, HN})
where {N<:Real, HN<:AbstractHyperrectangle{N}}

Converts the cartesian product array of hyperrectangular sets to a zonotope.

Input

• Zonotope – type, used for dispatch
• cpa – 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.

source
Base.convertMethod
convert(::Type{Zonotope}, S::LinearMap{N, ZN}
) where {N, ZN<:AbstractZonotope{N}}

Converts the lazy linear map of a zonotopic set to a zonotope.

Input

• Zonotope – type, used for dispatch
• S – 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.

source
Base.convertMethod
convert(::Type{Zonotope}, S::LinearMap{N, CartesianProduct{N, HN1, HN2}}
) where {N, HN1<:AbstractHyperrectangle{N},
HN2<:AbstractHyperrectangle{N}}

Converts the lazy linear map of the cartesian product of two hyperrectangular sets to a zonotope.

Input

• Zonotope – type, used for dispatch
• S – 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.

source
Base.convertMethod
convert(::Type{Zonotope},S::LinearMap{N, CartesianProductArray{N, HN}}
) where {N, HN<:AbstractHyperrectangle{N}}

Converts the lazy linear map of the cartesian product of a finite number of hyperrectangular sets to a zonotope.

Input

• Zonotope – type, used for dispatch
• S – linear map of a CartesianProductArray 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.

source
Base.convertMethod
convert(::Type{CartesianProduct{N, Interval{N}, Interval{N}}},
H::AbstractHyperrectangle{N}) where {N<:Real}

Converts a two-dimensional hyperrectangle to the cartesian product of two intervals.

Input

• CartesianProduct – type used for dispatch
• H – hyperrectangle

Output

The cartesian product of two intervals.

source
Base.convertMethod
convert(::Type{CartesianProductArray{N, Interval{N}}},
H::AbstractHyperrectangle{N}) where {N<:Real}

Converts a hyperrectangle to the cartesian product array of intervals.

Input

• CartesianProductArray – type used for dispatch
• H – hyperrectangle

Output

The cartesian product of a finite number of intervals.

source
Base.convertMethod
convert(::Type{Hyperrectangle}, r::Rectification{N, AH})
where {N<:Real, AH<:AbstractHyperrectangle{N}}

Converts a rectification of a hyperrectangle to a hyperrectangle.

Input

• Hyperrectangle – type used for dispatch
• r – rectification of a hyperrectangle

Output

A Hyperrectangle.

source
Base.convertMethod
convert(::Type{Interval},
r::Rectification{N, IN}) where {N<:Real, IN<:Interval{N}}

Converts a rectification of an interval to an interval.

Input

• Interval – type used for dispatch
• r – rectification of an interval

Output

An Interval.

source
Base.convertMethod
convert(::Type{IntervalArithmetic.Interval}, X::ConvexSet)

Converts a convex set to an Interval from IntervalArithmetic.

Input

• Interval – type used for dispatch, from IntervalArithmetic
• X – convex set

Output

An IntervalArithmetic.Interval.

source
Base.convertMethod
convert(::Type{Interval}, x::IntervalArithmetic.Interval)

Converts an Interval from IntervalArithmetic to an interval in LazySets.

Input

• Interval – type used for dispatch
• x – interval (IntervalArithmetic.Interval)

Output

A LazySets.Interval.

source
Base.convertMethod
convert(::Type{VPolytope},
X::ConvexHullArray{N, Singleton{N, VT}}) where {N, VT}

Converts the convex hull array of singletons to a polytope in V-representation.

Input

• VPolytope – type used for dispatch
• X – convex hull array of singletons

Output

A polytope in vertex representation.

source
Base.convertMethod
convert(::Type{VPolygon}, X::ConvexSet)

Generic conversion to polygon in vertex representation.

Input

• type – target type
• X – set

Output

The 2D set represented as a polygon.

Algorithm

We compute the list of vertices of X and wrap the result in a polygon in vertex representation, which guarantees that the vertices are sorted in counter-clockwise fashion.

source
Base.convertMethod
convert(::Type{MinkowskiSumArray},
X::MinkowskiSum{N, ST, MinkowskiSumArray{N, ST}}) where {N, ST}

Converts the Minkowski sum of a Minkowski sum array to a Minkowski sum array.

Input

• MinkowskiSumArray – type used for dispatch
• X – Minkowski sum of a Minkowski sum array

Output

A Minkowski sum array.

source
Base.convertMethod
convert(::Type{Interval}, x::MinkowskiSum{N, IT, IT}) where {N, IT<:Interval{N}}

Converts the Minkowski sum of two intervals into an interval.

Input

• Interval – type used for dispatch
• x – Minkowski sum of a pair of intervals

Output

An interval.

source
Base.convertMethod
convert(::Type{HParallelotope}, Z::AbstractZonotope{N}) where {N}

Converts a zonotopic set of order one into a parallelotope in constraint representation.

Input

• HParallelotope – type used for dispatch
• Z – zonotopic set

Output

A parallelotope in constraint representation.

Notes

This function requires that the list of constraints of Z are obtained in the particular order returned from the constraints list function of a Zonotope.

source
Base.convertMethod
convert(::Type{Zonotope}, cp::CartesianProduct{N, AZ1, AZ2}) where
{N, AZ1<:AbstractZonotope{N}, AZ2<:AbstractZonotope{N}}

Converts a cartesian product of two zonotopes into a zonotope.

Input

• Zonotope – type used for dispatch
• cp – cartesian product of two zonotopes

Output

A zonotope.

Notes

This implementation creates a Zonotope with sparse vector and matrix representation.

source
Base.convertMethod
convert(::Type{Zonotope}, cpa::CartesianProductArray{N, AZ})
where {N, AZ<:AbstractZonotope{N}}

Converts a cartesian product array of zonotopes into a zonotope.

Input

• Zonotope – type used for dispatch
• cpa – cartesian product array of zonotopes

Output

A zonotope.

Notes

This function requires the use of SparseArrays.

source
Base.convertMethod
convert(::Type{STAR}, P::AbstractPolyhedron{N}) where {N}

Converts a polyhedral set into a star set represented as a lazy affine map.

Input

• STAR – type used for dispatch
• P – polyhedral set

Output

A star set.

source
Base.convertMethod
convert(::Type{STAR}, X::Star)

Converts a star set into its equivalent representation as a lazy affine map.

Input

• STAR – type used for dispatch
• X – star set

Output

A star set.

source
Base.convertMethod
convert(::Type{Star}, P::AbstractPolyhedron{N}) where {N}

Converts a polyhedral set into a star set.

Input

• Star – type used for dispatch
• P – polyhedral set

Output

A star set.

source
Base.convertMethod
convert(::Type{SimpleSparsePolynomialZonotope}, Z::Zonotope)

Convert a zonotope to a simple sparse polynomial zonotope.

Algorithm

This method implements Proposition 3 in .

 Kochdumper, Althoff. Sparse polynomial zonotopes - a novel set representation for reachability analysis. 2021

source
Base.convertMethod
convert(::Type{SimpleSparsePolynomialZonotope}, SPZ::SparsePolynomialZonotope)

Convert a sparse polynomial zonotope to simple sparse polynomial zonotope.

source
Base.convertMethod
convert(::Type{SparsePolynomialZonotope}, Z::AbstractZonotope{N}) where {N}

Convert a zonotope to sparse polynomial zonotope.

source
Base.convertMethod
convert(::Type{SparsePolynomialZonotope}, SSPZ::SimpleSparsePolynomialZonotope)

Convert a simple sparse polynomial zonotope to a sparse polynomial zonotope.

source