AffineMap

Affine map (AffineMap)

AffineMap{N<:Real, S<:LazySet{N}, NM, MAT<:AbstractMatrix{NM},
          VN<:AbstractVector{NM}} <: LazySet{N}

Type that represents an affine transformation $M⋅X ⊕ v$ of a convex set $X$.

Fields

  • M – matrix/linear map
  • X – convex set
  • v – translation vector

Notes

An affine map is the composition of a linear map and a translation. This type is parametric in the coefficients of the linear map, NM, which may be different from the numeric type of the wrapped set (N). However, the numeric type of the translation vector should be NM.

Examples

For the examples we create a $3×2$ matrix, a two-dimensional unit square, and a three-dimensional vector. Then we combine them in an AffineMap.

julia> A = [1 2; 1 3; 1 4]; X = BallInf([0, 0], 1); b2 = [1, 2]; b3 = [1, 2, 3];

julia> AffineMap(A, X, b3)
AffineMap{Int64,BallInf{Int64},Int64,Array{Int64,2},Array{Int64,1}}([1 2; 1 3; 1 4], BallInf{Int64}([0, 0], 1), [1, 2, 3])

For convenience, A does not need to be a matrix but we also allow to use UniformScalings resp. scalars (interpreted as a scaling, i.e., a scaled identity matrix). Scaling by $1$ is ignored and simplified to a pure Translation.

julia> using LinearAlgebra

julia> am = AffineMap(2I, X, b2)
AffineMap{Int64,BallInf{Int64},Int64,Diagonal{Int64,Array{Int64,1}},Array{Int64,1}}([2 0; 0 2], BallInf{Int64}([0, 0], 1), [1, 2])

julia> AffineMap(2, X, b2) == am
true

julia> AffineMap(1, X, b2)
Translation{Int64,Array{Int64,1},BallInf{Int64}}(BallInf{Int64}([0, 0], 1), [1, 2])

Applying a linear map to an AffineMap object combines the two maps into a new AffineMap instance. Again we can make use of the conversion for convenience.

julia> B = [2 0; 0 2]; am2 = B * am
AffineMap{Int64,BallInf{Int64},Int64,Array{Int64,2},Array{Int64,1}}([4 0; 0 4], BallInf{Int64}([0, 0], 1), [2, 4])

julia> 2 * am == am2
true

The application of an AffineMap to a ZeroSet or an EmptySet is simplified automatically.

julia> AffineMap(A, ZeroSet{Int}(2), b3)
Singleton{Int64,Array{Int64,1}}([1, 2, 3])

julia> AffineMap(A, EmptySet{Int}(), b3)
EmptySet{Int64}()
source
LazySets.dimMethod.
dim(am::AffineMap)

Return the dimension of an affine map.

Input

  • am – affine map

Output

The dimension of an affine map.

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

Return the support vector of an affine map.

Input

  • d – direction
  • am – affine map

Output

The support vector in the given direction.

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

Return the support function of an affine map.

Input

  • d – direction
  • am – affine map

Output

The support function in the given direction.

source
an_element(am::AffineMap)

Return some element of an affine map.

Input

  • am – affine map

Output

An element of the affine map. It relies on the an_element function of the wrapped set.

source
Base.isemptyMethod.
isempty(am::AffineMap)

Return whether an affine map is empty or not.

Input

  • am – affine map

Output

true iff the wrapped set is empty and the affine vector is empty.

source
LazySets.isboundedMethod.
isbounded(am::AffineMap; cond_tol::Number=DEFAULT_COND_TOL)

Determine whether an affine map is bounded.

Input

  • am – affine map
  • cond_tol – (optional) tolerance of matrix condition (used to check whether the matrix is invertible)

Output

true iff the affine map is bounded.

Algorithm

We first check if the matrix is zero or the wrapped set is bounded. If not, we perform a sufficient check whether the matrix is invertible. If the matrix is invertible, then the map being bounded is equivalent to the wrapped set being bounded, and hence the map is unbounded. Otherwise, we check boundedness via isbounded_unit_dimensions.

source
Base.:∈Method.
∈(x::AbstractVector{N}, am::AffineMap{N}) where {N<:Real}

Check whether a given point is contained in the affine map of a convex set.

Input

  • x – point/vector
  • am – affine map of a convex set

Output

true iff $x ∈ am$.

Algorithm

Note that $x ∈ M⋅S ⊕ v$ iff $M^{-1}⋅(x - v) ∈ S$. This implementation does not explicitly invert the matrix, which is why it also works for non-square matrices.

Examples

julia> am = AffineMap([2.0 0.0; 0.0 1.0], BallInf([1., 1.], 1.), [-1.0, -1.0]);

julia> [5.0, 1.0] ∈ am
false

julia> [3.0, 1.0] ∈ am
true

An example with a non-square matrix:

julia> B = BallInf(zeros(4), 1.);

julia> M = [1. 0 0 0; 0 1 0 0]/2;

julia> [0.5, 0.5] ∈ M*B
true
source
vertices_list(am::AffineMap{N}; [apply_convex_hull]::Bool) where {N<:Real}

Return the list of vertices of a (polyhedral) affine map.

Input

  • am – affine map
  • apply_convex_hull – (optional, default: true) if true, apply the convex hull operation to the list of vertices transformed by the affine map

Output

A list of vertices.

Algorithm

This implementation computes all vertices of X, then transforms them through the affine map, i.e. x ↦ M*x + v for each vertex x of X. By default, the convex hull operation is taken before returning this list. For dimensions three or higher, this operation relies on the functionality through the concrete polyhedra library Polyhedra.jl.

If you are not interested in taking the convex hull of the resulting vertices under the affine map, pass apply_convex_hull=false as a keyword argument.

Note that we assume that the underlying set X is polyhedral, either concretely or lazily, i.e. there the function vertices_list should be applicable.

source
constraints_list(am::AffineMap{N}) where {N<:Real}

Return the list of constraints of a (polyhedral) affine map.

Input

  • am – affine map

Output

The list of constraints of the affine map.

Notes

We assume that the underlying set X is polyhedral, i.e., offers a method constraints_list(X).

Algorithm

Falls back to the list of constraints of the translation of a lazy linear map.

source
linear_map(M::AbstractMatrix{N}, am::AffineMap{N}) where {N<:Real}

Return the linear map of a lazy affine map.

Input

  • M – matrix
  • am – affine map

Output

A set corresponding to the linear map of the lazy affine map of a set.

source