Hyperrectangles (AbstractHyperrectangle)
A hyperrectangle is a special centrally symmetric polytope with axis-aligned facets.
LazySets.AbstractHyperrectangle
— TypeAbstractHyperrectangle{N} <: AbstractZonotope{N}
Abstract type for hyperrectangular sets.
Notes
See Hyperrectangle
for a standard implementation of this interface.
Every concrete AbstractHyperrectangle
must define the following functions:
radius_hyperrectangle(::AbstractHyperrectangle)
– return the hyperrectangle's radius, which is a full-dimensional vector
Among other functions, the following functions are then automatically defined:
isflat(::AbstractHyperrectangle)
– check whether the hyperrectangle's radius is zero in some dimensionradius_hyperrectangle(::AbstractHyperrectangle, i::Int)
– return the hyperrectangle's radius in thei
-th dimension
Every hyperrectangular set is also a zonotopic set; see AbstractZonotope
.
The subtypes of AbstractHyperrectangle
(including abstract interfaces):
julia> subtypes(AbstractHyperrectangle)
5-element Vector{Any}:
AbstractSingleton
BallInf
Hyperrectangle
Interval
SymmetricIntervalHull
This interface requires to implement the following function:
LazySets.radius_hyperrectangle
— Methodradius_hyperrectangle(H::AbstractHyperrectangle)
Return the hyperrectangle radius of a hyperrectangular set.
Input
H
– hyperrectangular set
Output
The hyperrectangle radius of H
, which is a full-dimensional vector.
This interface defines the following functions:
LazySets.□
— Method□(c, r)
Convenience constructor of Hyperrectangle
s or BallInf
s depending on the type of r
.
Input
c
– centerr
– radius (either a vector forHyperrectangle
or a number forBallInf
)
Output
A Hyperrectangle
s or BallInf
s depending on the type of r
.
Notes
The function symbol can be typed via \square<tab>
.
LazySets.API.constraints_list
— Methodconstraints_list(X::LazySet)
Compute a list of linear constraints of a polyhedral set.
Input
X
– polyhedral set
Output
A list of the linear constraints of X
.
LazySets.API.constraints_list
— MethodExtended help
constraints_list(H::AbstractHyperrectangle)
Output
A list of $2n$ linear constraints, where $n$ is the dimension of H
.
LazySets.isflat
— Methodisflat(H::AbstractHyperrectangle)
Check whether a hyperrectangular set is flat, i.e., whether its radius is zero in some dimension.
Input
H
– hyperrectangular set
Output
true
iff the hyperrectangular set is flat.
Notes
For robustness with respect to floating-point inputs, this function relies on the result of isapproxzero
when applied to the radius in some dimension. Hence this function depends on the absolute zero tolerance ABSZTOL
.
LazySets.ngens
— Methodngens(Z::AbstractZonotope)
Return the number of generators of a zonotopic set.
Input
Z
– zonotopic set
Output
An integer representing the number of generators.
LazySets.ngens
— MethodExtended help
ngens(H::AbstractHyperrectangle)
Algorithm
A hyperrectangular set has one generator for each non-flat dimension.
LinearAlgebra.norm
— Functionnorm(X::LazySet, [p]::Real=Inf)
Return the norm of a set.
Input
X
– setp
– (optional, default:Inf
) norm
Output
A real number representing the norm.
Notes
The norm of a set is the norm of the enclosing ball (of the given $p$-norm) of minimal volume that is centered in the origin.
LinearAlgebra.norm
— FunctionExtended help
norm(H::AbstractHyperrectangle, [p]::Real=Inf)
Algorithm
Recall that the norm is defined as
\[‖ X ‖ = \max_{x ∈ X} ‖ x ‖_p = max_{x ∈ \text{vertices}(X)} ‖ x ‖_p.\]
The last equality holds because the optimum of a convex function over a polytope is attained at one of its vertices.
This implementation uses the fact that the maximum is attained in the vertex $c + \text{diag}(\text{sign}(c)) r$ for any $p$-norm. Hence it suffices to take the $p$-norm of this particular vertex. This statement is proved below. Note that, in particular, there is no need to compute the $p$-norm for each vertex, which can be very expensive.
If $X$ is a hyperrectangle and the $n$-dimensional vectors center and radius of the hyperrectangle are denoted $c$ and $r$ respectively, then reasoning on the $2^n$ vertices we have that:
\[\max_{x ∈ \text{vertices}(X)} ‖ x ‖_p = \max_{α_1, …, α_n ∈ \{-1, 1\}} (|c_1 + α_1 r_1|^p + ... + |c_n + α_n r_n|^p)^{1/p}.\]
The function $x ↦ x^p$, $p > 0$, is monotonically increasing and thus the maximum of each term $|c_i + α_i r_i|^p$ is given by $|c_i + \text{sign}(c_i) r_i|^p$ for each $i$. Hence, $x^* := \text{argmax}_{x ∈ X} ‖ x ‖_p$ is the vertex $c + \text{diag}(\text{sign}(c)) r$.
LazySets.API.radius
— Functionradius(X::LazySet, [p]::Real=Inf)
Return the radius of a set.
Input
X
– setp
– (optional, default:Inf
) norm
Output
A real number representing the radius.
Notes
The radius of a set is the radius of the enclosing ball (of the given $p$-norm) of minimal volume with the same center.
LazySets.API.radius
— FunctionExtended help
radius(H::AbstractHyperrectangle, [p]::Real=Inf)
Notes
The result is defined as the radius of the enclosing ball of the given $p$-norm of minimal volume with the same center. It is the same for all corners of a hyperrectangular set.
LazySets.radius_hyperrectangle
— Methodradius_hyperrectangle(H::AbstractHyperrectangle, i::Int)
Return the hyperrectangle radius of a hyperrectangular set in a given dimension.
Input
H
– hyperrectangular seti
– dimension
Output
The hyperrectangle radius of H
in dimension i
.
ReachabilityBase.Arrays.rectify
— Methodrectify(X::LazySet)
Compute the rectification of a set.
Input
X
– set
Output
A set representing the rectification of X
.
ReachabilityBase.Arrays.rectify
— MethodExtended help
rectify(H::AbstractHyperrectangle)
Output
A Hyperrectangle
.
LazySets.API.reflect
— Methodreflect(X::LazySet)
Compute the reflection of a set in the origin.
Input
X
– set
Output
A set representing the reflection $-X$.
LazySets.API.reflect
— MethodExtended help
reflect(H::AbstractHyperrectangle)
Output
A Hyperrectangle
.
Algorithm
If $H$ has center $c$ and radius $r$, then $-H$ has center $-c$ and radius $r$.
LazySets.API.vertices_list
— Methodvertices_list(X::LazySet)
Compute a list of vertices of a polytopic set.
Input
X
– polytopic set
Output
A list of the vertices of X
.
LazySets.API.vertices_list
— MethodExtended help
vertices_list(H::AbstractHyperrectangle; kwargs...)
Notes
Zeros in the radius are correctly handled, i.e., the result does not contain any duplicate vertices.
Algorithm
First we identify the dimensions where H
is flat, i.e., its radius is zero. We also compute the number of vertices that we have to create.
Next we create the vertices. We do this by enumerating all vectors v
of length n
(the dimension of H
) with entries -1
/0
/1
and construct the corresponding vertex as follows:
\[ \text{vertex}(v)(i) = \begin{cases} c(i) + r(i) & v(i) = 1 \\ c(i) & v(i) = 0 \\ c(i) - r(i) & v(i) = -1. \end{cases}\]
For enumerating the vectors v
, we modify the current v
from left to right by changing entries -1
to 1
, skipping entries 0
, and stopping at the first entry 1
(but changing it to -1
). This way we only need to change the vertex in those dimensions where v
has changed, which usually is a smaller number than n
.
LazySets.API.volume
— Methodvolume(X::LazySet)
Compute the volume, or Lebesgue measure, of a set.
Input
X
– set
Output
A real number representing the Lebesgue measure of X
.
Notes
The Lebesgue measure has the following common special cases:
- In 1D, it coincides with the length.
- In 2D, it coincides with the area (see also
area
). - In 3D, it coincides with the volume.
In higher dimensions, it is also known as the hypervolume or simply volume.
LazySets.API.volume
— MethodExtended help
volume(H::AbstractHyperrectangle)
Algorithm
The volume of the $n$-dimensional hyperrectangle $H$ with radius vector $r$ is $2ⁿ ∏ᵢ rᵢ$ where $rᵢ$ denotes the $i$-th component of $r$.
Base.:∈
— Method∈(x::AbstractVector, X::LazySet)
Check whether a point lies in a set.
Input
x
– point/vectorX
– set
Output
true
iff $x ∈ X$.
Base.:∈
— MethodExtended help
∈(x::AbstractVector, H::AbstractHyperrectangle)
Algorithm
Let $H$ be an $n$-dimensional hyperrectangular set, $c_i$ and $r_i$ be the center and radius, and $x_i$ be the vector $x$ in dimension $i$, respectively. Then $x ∈ H$ iff $|c_i - x_i| ≤ r_i$ for all $i=1,…,n$.
Base.split
— Methodsplit(H::AbstractHyperrectangle, num_blocks::AbstractVector{Int})
Partition a hyperrectangular set into uniform sub-hyperrectangles.
Input
H
– hyperrectangular setnum_blocks
– number of blocks in the partition for each dimension
Output
A list of Hyperrectangle
s.
LazySets.API.σ
— Methodσ(d::AbstractVector, X::LazySet)
Compute a support vector of a set in a given direction.
Input
d
– directionX
– set
Output
A support vector of X
in direction d
.
Notes
A convenience alias support_vector
is also available.
LazySets.API.σ
— MethodExtended help
σ(d::AbstractVector, H::AbstractHyperrectangle)
Notes
If the direction vector is zero in dimension $i$, the result will have the center's coordinate in that dimension. For instance, for the two-dimensional infinity-norm ball, if the direction points to the right, the result is the vector [1, 0]
in the middle of the right-hand facet.
If the direction has norm zero, the result can be any point in H
. The default implementation returns the center of H
.
LazySets.API.difference
— Methoddifference(X::LazySet, Y::LazySet)
Compute the set difference of two sets.
Input
X
– setY
– set
Output
A set representing the difference $X ∖ Y$.
Notes
The set difference is defined as:
\[ X ∖ Y = \{x \mid x ∈ X \text{ and } x ∉ Y \}\]
LazySets.API.difference
— MethodExtended help
difference(X::AbstractHyperrectangle, Y::AbstractHyperrectangle)
Output
A UnionSetArray
consisting of the union of hyperrectangles. Note that this union is in general not convex.
Algorithm
This implementation uses IntervalArithmetic.setdiff
.
LazySets.API.intersection
— Methodintersection(X::LazySet, Y::LazySet)
Compute the intersection of two sets.
Input
X
– setY
– set
Output
A set representing the intersection $X ∩ Y$.
Notes
The intersection of two sets $X$ and $Y$ is defined as
\[ X ∩ Y = \{x \mid x ∈ X \text{ and } x ∈ Y\}.\]
LazySets.API.intersection
— Methodintersection(H1::AbstractHyperrectangle, H2::AbstractHyperrectangle)
Compute the intersection of two hyperrectangular sets.
Input
H1
– hyperrectangular setH2
– hyperrectangular set
Output
If the hyperrectangular sets do not intersect, the result is the empty set. Otherwise the result is the hyperrectangle that describes the intersection.
Algorithm
In each isolated direction i
we compute the rightmost left border and the leftmost right border of the hyperrectangular sets. If these borders contradict, then the intersection is empty. Otherwise the resulting hyperrectangle uses these borders in each dimension.
Base.isdisjoint
— Methodisdisjoint(X::LazySet, Y::LazySet, [witness]::Bool=false)
Check whether two sets are disjoint (i.e., do not intersect), and optionally compute a witness.
Input
X
– setY
– setwitness
– (optional, default:false
) compute a witness if activated
Output
- If the
witness
option is deactivated:true
iff $X ∩ Y = ∅$ - If the
witness
option is activated:(true, [])
iff $X ∩ Y = ∅$(false, v)
iff $X ∩ Y ≠ ∅$ for some $v ∈ X ∩ Y$
Notes
The convenience alias is_intersection_empty
is also available.
Base.isdisjoint
— FunctionExtended help
isdisjoint(H1::AbstractHyperrectangle, H2::AbstractHyperrectangle,
[witness]::Bool=false)
Algorithm
$H1 ∩ H2 ≠ ∅$ iff $|c_2 - c_1| ≤ r_1 + r_2$, where $≤$ is taken component-wise.
A witness is computed by starting in one center and moving toward the other center for as long as the minimum of the radius and the center distance. In other words, the witness is the point in H1
that is closest to the center of H2
.
Base.:⊆
— Method⊆(X::LazySet, Y::LazySet, [witness]::Bool=false)
Check whether a set is a subset of another set, and optionally compute a witness.
Input
X
– setY
– setwitness
– (optional, default:false
) compute a witness if activated
Output
- If the
witness
option is deactivated:true
iff $X ⊆ Y$ - If the
witness
option is activated:(true, [])
iff $X ⊆ Y$(false, v)
iff $X ⊈ Y$ for some $v ∈ X ∖ Y$
Notes
The convenience alias issubset
is also available.
Base.:⊆
— FunctionExtended help
⊆(H1::AbstractHyperrectangle, H2::AbstractHyperrectangle,
[witness]::Bool=false)
Algorithm
$H1 ⊆ H2$ iff $c_1 + r_1 ≤ c_2 + r_2 ∧ c_1 - r_1 ≥ c_2 - r_2$ iff $r_1 - r_2 ≤ c_1 - c_2 ≤ -(r_1 - r_2)$, where $≤$ is taken component-wise.
LazySets.API.minkowski_difference
— Methodminkowski_difference(X::LazySet, Y::LazySet)
Compute the Minkowski difference of two sets.
Input
X
– setY
– set
Output
A set representing the Minkowski difference $X ⊖ Y$.
Notes
The Minkowski difference of two sets $X$ and $Y$ is defined as
\[ X ⊖ Y = \{z \mid \{z\} ⊕ Y ⊆ X\}\]
The convenience alias pontryagin_difference
is also available.
There is some inconsistency in the literature regarding the naming conventions. In this library, both Minkowski difference and Pontryagin difference refer to the geometric difference of two sets.
LazySets.API.minkowski_difference
— MethodExtended help
minkowski_difference(H1::AbstractHyperrectangle, H2::AbstractHyperrectangle)
Output
A Hyperrectangle
, or an EmptySet
if the difference is empty.
LazySets.API.minkowski_sum
— Methodminkowski_sum(X::LazySet, Y::LazySet)
Compute the Minkowski sum of two sets.
Input
X
– setY
– set
Output
A set representing the Minkowski sum $X ⊕ Y$.
Notes
The Minkowski sum of two sets $X$ and $Y$ is defined as
\[ X ⊕ Y = \{x + y \mid x ∈ X, y ∈ Y\}.\]
LazySets.API.minkowski_sum
— MethodExtended help
minkowski_sum(H1::AbstractHyperrectangle, H2::AbstractHyperrectangle)
Algorithm
The resulting hyperrectangle is obtained by summing up the centers and radii.
Undocumented implementations:
Inherited from LazySet
:
chebyshev_center_radius
complement
concretize
constraints
convex_hull
copy(::Type{LazySet})
delaunay
diameter
eltype
eltype
isoperation
polyhedron
rationalize
singleton_list
surface
tosimplehrep
triangulate
vertices
affine_map
exponential_map
is_interior_point
sample
scale
translate
convex_hull
exact_sum
≈
==
isequivalent
⊂
Inherited from ConvexSet
:
Inherited from AbstractPolyhedron
:
Inherited from AbstractPolytope
:
Inherited from AbstractCentrallySymmetricPolytope
:
Inherited from AbstractZonotope
:
Implementations
Concrete set representations:
Lazy set operations: