CartesianProduct

Cartesian product

Binary Cartesian product (CartesianProduct)

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 set
  • Y – 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])
source
LinearAlgebra.:×Method.
×

Alias for the binary Cartesian product.

source
Base.:*Method.
    *(X::LazySet, Y::LazySet)

Alias for the binary Cartesian product.

source
LazySets.swapMethod.
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.

source
LazySets.dimMethod.
dim(cp::CartesianProduct)

Return the dimension of a Cartesian product.

Input

  • cp – Cartesian product

Output

The ambient dimension of the Cartesian product.

source
LazySets.ρMethod.
ρ(d::AbstractVector{N}, cp::CartesianProduct{N}) where {N<:Real}

Return the support function of a Cartesian product.

Input

  • d – direction
  • cp – Cartesian product

Output

The support function in the given direction. If the direction has norm zero, the result depends on the wrapped sets.

source
LazySets.σMethod.
σ(d::AbstractVector{N}, cp::CartesianProduct{N}) where {N<:Real}

Return the support vector of a Cartesian product.

Input

  • d – direction
  • cp – Cartesian product

Output

The support vector in the given direction. If the direction has norm zero, the result depends on the wrapped sets.

source
LazySets.isboundedMethod.
isbounded(cp::CartesianProduct)

Determine whether a Cartesian product is bounded.

Input

  • cp – Cartesian product

Output

true iff both wrapped sets are bounded.

source
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/vector
  • cp – Cartesian product

Output

true iff $x ∈ cp$.

source
Base.isemptyMethod.
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.

source
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.

source
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.

source
linear_map(M::AbstractMatrix{N}, cp::CartesianProduct{N}) where {N<:Real}

Concrete linear map of a (polyhedral) Cartesian product.

Input

  • M – matrix
  • cp – Cartesian product of two 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.

source

Inherited from LazySet:

$n$-ary Cartesian product (CartesianProductArray)

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 constructor

  • CartesianProductArray([n]::Int=0, [N]::Type=Float64)

– constructor for an empty product with optional size hint and numeric type

source
LazySets.dimMethod.

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.

source
LazySets.ρMethod.

ρ(d::AbstractVector{N}, cp::CartesianProductArray{N}) where {N<:Real}

Return the support function of a Cartesian product array.

Input

  • d – direction
  • cpa – Cartesian product array

Output

The support function in the given direction. If the direction has norm zero, the result depends on the wrapped sets.

source
LazySets.σMethod.

σ(d::AbstractVector{N}, cpa::CartesianProductArray{N}) where {N<:Real}

Support vector of a Cartesian product array.

Input

  • d – direction
  • cpa – Cartesian product array

Output

The support vector in the given direction. If the direction has norm zero, the result depends on the product sets.

source
LazySets.isboundedMethod.

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.

source
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/vector
  • cpa – Cartesian product array

Output

true iff $x ∈ \text{cpa}$.

source
Base.isemptyMethod.

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.

source

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.

source

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.

source

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 – matrix
  • cpa – 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.

source
LazySets.arrayMethod.

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.

source
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.

source

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.

source

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.

source
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.

source

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.

source

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
source

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 array
  • vars – 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> block_to_dimension_indices(cpa, [2, 4, 8])
(Tuple{Int64,Int64}[(-1, -1), (2, 4), (-1, -1), (7, 9)], 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)

source

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 array
  • orig_cpa – original high-dimensional Cartesian product array
  • blocks – index of the first variable in each block of orig_cpa

Output

Merged cartesian product array

source

Inherited from LazySet: