Skip to content

Commit

Permalink
Added overapproximation of Lazy linear map of cartesian product array
Browse files Browse the repository at this point in the history
  • Loading branch information
kpotomkin committed Jun 1, 2019
1 parent fe2132b commit ef60e2e
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions src/Approximations/overapproximate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -516,3 +516,58 @@ function overapproximate(cap::Intersection{N,
return overapproximate(swap(cap), dir; kwargs...)
end

"""
overapproximate(lm::LinearMap{N, <:CartesianProductArray{N, <:LazySet{N}}},
dir::Type{<:AbstractDirections})::CartesianProductArray{N, HPolytope{N}} where {N}
Overapproximating a lazy linear map of cartesian product array with template directions for each block.
### Input
- `lm` -- lazy linear map of cartesian product array
- `dir` -- (concrete) direction representation
### Output
An `CartesianProductArray` with overapproximation of the each block with the directions from `dir`.
"""
function overapproximate(lm::LinearMap{N, <:CartesianProductArray{N, <:LazySet{N}}},
dir::Type{<:AbstractDirections})::CartesianProductArray{N, HPolytope{N}} where {N}

if !(size(lm.M, 2) == dim(lm.X))
error("Matrix needs to be commensurate with the cartesian product")
end

cp = lm.X
M = lm.M

array = Vector{HPolytope{N}}
sizehint!(array,length(cp.array))
col_st_index, col_end_ind = 0, 0

for bi in 1:length(cp.array)
col_st_index = col_end_ind + 1
n = dim(cp.array[bi])
col_end_ind += n

start_ind, end_ind = 1, n
matrices = Vector{Matrix{N}}()

while end_ind <= size(M, 2)
push!(matrices, M[col_st_index : col_end_ind, start_ind : end_ind])
start_ind = end_ind + 1
end_ind += n
end

v_block = MinkowskiSumArray()

for m in matrices
push!(v_block.array,LinearMap(m, cp.array[bi]))
end

push!(array, Approximations.overapproximate(v_block, dir{N}(dim(v_block))))
end

result = CartesianProductArray{N, HPolytope{N}}(array)
return result
end

0 comments on commit ef60e2e

Please sign in to comment.