Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#934 - Add exact projection method #935

Merged
merged 5 commits into from Dec 11, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
64 changes: 63 additions & 1 deletion src/Approximations/decompositions.jl
Expand Up @@ -228,7 +228,7 @@ function decompose(S::LazySet{N};

if directions != nothing
# template directions
# potentially defined option set_type is *ignored*
# potentially defined option set_type is *ignored*
block_start = 1
@inbounds for bi in blocks
push!(result, project(S, block_start:(block_start + bi - 1), directions(bi), n))
Expand Down Expand Up @@ -268,6 +268,42 @@ function decompose(S::LazySet{N};
return CartesianProductArray(result)
end


"""
decompose_explicit(S::LazySet{N};
blocks::AbstractVector{Int}=default_block_structure(S, set_type)
)::CartesianProductArray where {N<:Real}

Decompose a high-dimensional set into a Cartesian product of overapproximations
schillic marked this conversation as resolved.
Show resolved Hide resolved
of the projections over the specified subspaces.

### Input

- `S` -- set
- `blocks` -- (optional, default: [2, …, 2] or [1, …, 1])
block structure - a vector with the size of each block

### Output

A `CartesianProductArray` containing lazy low-dimensional exact
projections.
"""

function decompose_explicit(S::LazySet{N};
schillic marked this conversation as resolved.
Show resolved Hide resolved
blocks::AbstractVector{Int}=default_block_structure(S, Interval)
)::CartesianProductArray where {N<:Real}
n = dim(S)
result = Vector{LazySet{N}}()

block_start = 1
@inbounds for bi in blocks
push!(result, project(S, block_start:(block_start + bi - 1), n))
block_start += bi
end

return CartesianProductArray(result)
end

"""
project(S::LazySet{N},
block::AbstractVector{Int},
Expand Down Expand Up @@ -442,3 +478,29 @@ The template direction approximation of the projection of `S`.
M = sparse(1:length(block), block, ones(N, length(block)), length(block), n)
return overapproximate(M * S, directions)
end

"""
project(S::LazySet{N},
block::AbstractVector{Int},
n::Int
)::HPolytope where {N<:Real}
schillic marked this conversation as resolved.
Show resolved Hide resolved

Project a high-dimensional set to a low-dimensional set.
schillic marked this conversation as resolved.
Show resolved Hide resolved

### Input

- `S` -- set
- `block` -- block structure - a vector with the dimensions of interest
- `n` -- (optional, default: `dim(S)`) ambient dimension of the set `S`

### Output

The lazy linear map of the projection of `S`.
"""
schillic marked this conversation as resolved.
Show resolved Hide resolved
@inline function project(S::LazySet{N},
schillic marked this conversation as resolved.
Show resolved Hide resolved
block::AbstractVector{Int},
n::Int=dim(S)
)::LinearMap where {N<:Real}
M = sparse(1:length(block), block, ones(N, length(block)), length(block), n)
return M * S
end