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

#2522 - Concrete projection of interval x zonotope #2525

Merged
merged 2 commits into from
Jan 29, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/LazyOperations/CartesianProduct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -325,3 +325,31 @@ function project(cp::CartesianProduct{N, <:Interval, <:AbstractHyperrectangle{N}
end
return Hyperrectangle(cH[block_vec], rH[block_vec], check_bounds=false)
end

"""
project(cp::CartesianProduct{N, <:Interval, <:AbstractZonotope{N}}, block::AbstractVector{Int}) where {N}

Concrete projection of a Cartesian product between an interval and a zonotopic set.

### Input

- `cp` -- Cartesian product between an interval and a zonotopic set
- `block` -- block structure, a vector with the dimensions of interest

### Output

A set representing the projection of the cartesian product `cp` on the
dimensions specified by `block`.
"""
function project(cp::CartesianProduct{N, <:Interval, <:AbstractZonotope{N}}, block::AbstractVector{Int}) where {N}
block_vec = collect(block)
Z = cp.Y
if 1 ∉ block_vec
block_vec .-= 1
M = projection_matrix(block_vec, dim(Z), N)
else
M = projection_matrix(block_vec, dim(cp), N)
Z = convert(Zonotope, cp)
end
SebastianGuadalupe marked this conversation as resolved.
Show resolved Hide resolved
return linear_map(M, Z)
end
4 changes: 4 additions & 0 deletions test/unit_CartesianProduct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,10 @@ for N in [Float64, Float32]
cp = Interval(N(0), N(2)) × Hyperrectangle(N[2, 3], N[1, 1])
@test project(cp, 1:2) == Hyperrectangle(N[1, 2], N[1, 1])
@test project(cp, 2:3) == Hyperrectangle(N[2, 3], N[1, 1])

cp = Interval(N(0), N(2)) × Zonotope(N[2, 3], N[1 0; 0 1])
@test isequivalent(project(cp, 1:2), Zonotope(N[1, 2], N[1 0; 0 1]))
@test isequivalent(project(cp, 2:3), Zonotope(N[2, 3], N[1 0; 0 1]))
schillic marked this conversation as resolved.
Show resolved Hide resolved
end

for N in [Float64]
Expand Down