Cartesian product
Binary Cartesian product (CartesianProduct)
LazySets.CartesianProduct
— Type.CartesianProduct{N<:Real, S1<:LazySet{N}, S2<:LazySet{N}} <: LazySet{N}
Type that represents a Cartesian product of two convex sets.
Fields
X
– first convex setY
– second convex set
Notes
The Cartesian product of three elements is obtained recursively. See also CartesianProductArray
for an implementation of a Cartesian product of many sets without recursion, instead using an array.
The EmptySet
is the absorbing element for CartesianProduct
.
Examples
The Cartesian product between two sets X
and Y
can be constructed either using CartesianProduct(X, Y)
or the short-cut notation X × Y
:
julia> I1 = Interval(0, 1);
julia> I2 = Interval(2, 4);
julia> I12 = I1 × I2;
julia> typeof(I12)
CartesianProduct{Float64,Interval{Float64,IntervalArithmetic.Interval{Float64}},Interval{Float64,IntervalArithmetic.Interval{Float64}}}
A hyperrectangle is the cartesian product of intervals, so we can convert I12
exactly to a Hyperrectangle
type:
julia> convert(Hyperrectangle, I12)
Hyperrectangle{Float64,Array{Float64,1},Array{Float64,1}}([0.5, 3.0], [0.5, 1.0])
LinearAlgebra.:×
— Method.×
Alias for the binary Cartesian product.
Base.:*
— Method. *(X::LazySet, Y::LazySet)
Alias for the binary Cartesian product.
LazySets.swap
— Method.swap(cp::CartesianProduct)
Return a new CartesianProduct
object with the arguments swapped.
Input
cp
– Cartesian product of two convex sets
Output
A new CartesianProduct
object with the arguments swapped.
LazySets.dim
— Method.dim(cp::CartesianProduct)
Return the dimension of a Cartesian product.
Input
cp
– Cartesian product
Output
The ambient dimension of the Cartesian product.
LazySets.ρ
— Method.ρ(d::AbstractVector{N}, cp::CartesianProduct{N}) where {N<:Real}
Return the support function of a Cartesian product.
Input
d
– directioncp
– Cartesian product
Output
The support function in the given direction. If the direction has norm zero, the result depends on the wrapped sets.
LazySets.σ
— Method.σ(d::AbstractVector{N}, cp::CartesianProduct{N}) where {N<:Real}
Return the support vector of a Cartesian product.
Input
d
– directioncp
– Cartesian product
Output
The support vector in the given direction. If the direction has norm zero, the result depends on the wrapped sets.
LazySets.isbounded
— Method.isbounded(cp::CartesianProduct)
Determine whether a Cartesian product is bounded.
Input
cp
– Cartesian product
Output
true
iff both wrapped sets are bounded.
Base.:∈
— Method.∈(x::AbstractVector{N}, cp::CartesianProduct{N}) where {N<:Real}
Check whether a given point is contained in a Cartesian product.
Input
x
– point/vectorcp
– Cartesian product
Output
true
iff $x ∈ cp$.
Base.isempty
— Method.isempty(cp::CartesianProduct)
Return if a Cartesian product is empty or not.
Input
cp
– Cartesian product
Output
true
iff any of the sub-blocks is empty.
LazySets.constraints_list
— Method.constraints_list(cp::CartesianProduct{N}) where {N<:Real}
Return the list of constraints of a (polyhedral) Cartesian product.
Input
cp
– Cartesian product
Output
A list of constraints.
LazySets.vertices_list
— Method.vertices_list(cp::CartesianProduct{N}) where {N<:Real}
Return the list of vertices of a (polytopic) Cartesian product.
Input
cp
– Cartesian product
Output
A list of vertices.
Algorithm
We assume that the underlying sets are polytopic. Then the high-dimensional set of vertices is just the Cartesian product of the low-dimensional sets of vertices.
LazySets.linear_map
— Method.linear_map(M::AbstractMatrix{N}, cp::CartesianProduct{N}) where {N<:Real}
Concrete linear map of a (polyhedral) Cartesian product.
Input
M
– matrixcp
– Cartesian product of two convex sets
Output
A polytope if cp
is bounded and a polyhedron otherwise.
Algorithm
We convert the Cartesian product to constraint representation and then call linear_map
on the corresponding polyhedron.
Inherited from LazySet
:
$n$-ary Cartesian product (CartesianProductArray)
LazySets.CartesianProductArray
— Type.CartesianProductArray{N<:Real, S<:LazySet{N}} <: LazySet{N}
Type that represents the Cartesian product of a finite number of convex sets.
Fields
array
– array of sets
Notes
The EmptySet
is the absorbing element for CartesianProductArray
.
Constructors:
CartesianProductArray(array::Vector{<:LazySet})
– default constructorCartesianProductArray([n]::Int=0, [N]::Type=Float64)
– constructor for an empty product with optional size hint and numeric type
LazySets.dim
— Method.dim(cpa::CartesianProductArray)
Return the dimension of a Cartesian product of a finite number of convex sets.
Input
cpa
– Cartesian product array
Output
The ambient dimension of the Cartesian product of a finite number of convex sets.
LazySets.ρ
— Method.ρ(d::AbstractVector{N}, cp::CartesianProductArray{N}) where {N<:Real}
Return the support function of a Cartesian product array.
Input
d
– directioncpa
– Cartesian product array
Output
The support function in the given direction. If the direction has norm zero, the result depends on the wrapped sets.
LazySets.σ
— Method.σ(d::AbstractVector{N}, cpa::CartesianProductArray{N}) where {N<:Real}
Support vector of a Cartesian product array.
Input
d
– directioncpa
– Cartesian product array
Output
The support vector in the given direction. If the direction has norm zero, the result depends on the product sets.
LazySets.isbounded
— Method.isbounded(cpa::CartesianProductArray)
Determine whether a Cartesian product of a finite number of convex sets is bounded.
Input
cpa
– Cartesian product of a finite number of convex sets
Output
true
iff all wrapped sets are bounded.
Base.:∈
— Method.∈(x::AbstractVector{N}, cpa::CartesianProductArray{N}) where {N<:Real}
Check whether a given point is contained in a Cartesian product of a finite number of sets.
Input
x
– point/vectorcpa
– Cartesian product array
Output
true
iff $x ∈ \text{cpa}$.
Base.isempty
— Method.isempty(cpa::CartesianProductArray)
Return if a Cartesian product is empty or not.
Input
cp
– Cartesian product
Output
true
iff any of the sub-blocks is empty.
LazySets.constraints_list
— Method.constraints_list(cpa::CartesianProductArray{N}) where {N<:Real}
Return the list of constraints of a (polyhedral) Cartesian product of a finite number of sets.
Input
cpa
– Cartesian product array
Output
A list of constraints.
LazySets.vertices_list
— Method.vertices_list(cpa::CartesianProductArray{N}) where {N<:Real}
Return the list of vertices of a (polytopic) Cartesian product of a finite number of sets.
Input
cpa
– Cartesian product array
Output
A list of vertices.
Algorithm
We assume that the underlying sets are polytopic. Then the high-dimensional set of vertices is just the Cartesian product of the low-dimensional sets of vertices.
LazySets.linear_map
— Method.linear_map(M::AbstractMatrix{N}, cpa::CartesianProductArray{N} ) where {N<:Real}
Concrete linear map of a Cartesian product of a finite number of convex sets.
Input
M
– matrixcpa
– Cartesian product of a finite number of convex sets
Output
A polytope.
Algorithm
We check if the matrix is invertible. If so, we convert the Cartesian product to constraint representation. Otherwise, we convert the Cartesian product to vertex representation. In both cases, we then call linear_map
on the resulting polytope.
LazySets.array
— Method.array(cpa::CartesianProductArray{N, S}) where {N<:Real, S<:LazySet{N}}
Return the array of a Cartesian product of a finite number of convex sets.
Input
cpa
– Cartesian product array
Output
The array of a Cartesian product of a finite number of convex sets.
array(cha::ConvexHullArray{N, S}) where {N<:Real, S<:LazySet{N}}
Return the array of a convex hull of a finite number of convex sets.
Input
cha
– convex hull array
Output
The array of a convex hull of a finite number of convex sets.
array(ia::IntersectionArray{N, S}) where {N<:Real, S<:LazySet{N}}
Return the array of an intersection of a finite number of convex sets.
Input
ia
– intersection of a finite number of convex sets
Output
The array of an intersection of a finite number of convex sets.
array(msa::MinkowskiSumArray{N, S}) where {N<:Real, S<:LazySet{N}}
Return the array of a Minkowski sum of a finite number of convex sets.
Input
msa
– Minkowski sum array
Output
The array of a Minkowski sum of a finite number of convex sets.
array(cms::CachedMinkowskiSumArray{N, S}) where {N<:Real, S<:LazySet{N}}
Return the array of a caching Minkowski sum.
Input
cms
– caching Minkowski sum
Output
The array of a caching Minkowski sum.
array(cup::UnionSetArray{N, S}) where {N<:Real, S<:LazySet{N}}
Return the array of a union of a finite number of convex sets.
Input
cup
– union of a finite number of convex sets
Output
The array that holds the union of a finite number of convex sets.
LazySets.block_structure
— Method.block_structure(cpa::CartesianProductArray{N}) where {N}
Returns an array containing the dimension ranges of each block in a CartesianProductArray
.
Input
cpa
– Cartesian product array
Output
A vector of ranges
Example
julia> using LazySets: block_structure
julia> cpa = CartesianProductArray([BallInf(zeros(n), 1.0) for n in [3, 1, 2]]);
julia> block_structure(cpa)
3-element Array{UnitRange{Int64},1}:
1:3
4:4
5:6
LazySets.block_to_dimension_indices
— Method.blocktodimension_indices(cpa::CartesianProductArray{N}, vars::Vector{Int}) where {N}
Returns a vector mapping block index i
to tuple (f, l)
such that either f = l = -1
or f
is the first dimension index and l
is the last dimension index of the i
-th block, depending on whether one of the block's dimension indices is specified in vars
.
Input
cpa
– Cartesian product arrayvars
– list containing the variables of interest, sorted in ascending order
Output
(i) A vector of tuples, where values in tuple relate to range of dimensions in the i-th block. (ii) Number of constrained blocks
Example
julia> using LazySets: block_to_dimension_indices
julia> cpa = CartesianProductArray([BallInf(zeros(n), 1.0) for n in [1, 3, 2, 3]]);
julia> m, k = block_to_dimension_indices(cpa, [2, 4, 8]);
julia> m
4-element Array{Tuple{Int64,Int64},1}:
(-1, -1)
(2, 4)
(-1, -1)
(7, 9)
julia> k
2
This vector represents the mapping "second block from dimension 2 to dimension 4, fourth block from dimension 7 to dimension 9." These blocks contain the dimensions specified in [2, 4, 8]
. Number of constrained variables here is 2 (2nd and 4th blocks)
LazySets.substitute_blocks
— Method.substituteblocks(lowdimcpa::CartesianProductArray{N}, origcpa::CartesianProductArray{N}, blocks::Vector{Tuple{Int,Int}}) where {N}
Return merged Cartesian Product Array between original CPA and some low-dimensional CPA, which represents updated subset of variables in specified blocks.
Input
low_dim_cpa
– low-dimensional cartesian product arrayorig_cpa
– original high-dimensional Cartesian product arrayblocks
– index of the first variable in each block oforig_cpa
Output
Merged cartesian product array
Inherited from LazySet
: