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

#1170 - Faster hyperrectangular overapproximation of the linear map of a hyperrectangular set #1172

Merged
merged 3 commits into from
Feb 27, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
32 changes: 32 additions & 0 deletions src/Approximations/overapproximate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,37 @@ function overapproximate(S::CartesianProductArray{N, <:AbstractHyperrectangle{N}
return convert(Hyperrectangle, S)
end

"""
overapproximate(lm::LinearMap{N, <:AbstractHyperrectangle{N}},
::Type{Hyperrectangle}) where {N}

Return a tight overapproximation of the linear map of a hyperrectangular set
using a hyperrectangle.

### Input

- `S` -- linear map of a hyperrectangular set
- `Hyperrectangle` -- type for dispatch

### Output

A hyperrectangle.

### Algorithm

If `c` and `r` denote the center and vector radius of a hyperrectangle `H`,
a tight hyperrectangular overapproximation of `M * H` is obtained by transforming
`c ↦ M*c` and `r ↦ abs.(⋅) * c`, where `abs.(⋅)` denotes the element-wise absolute
mforets marked this conversation as resolved.
Show resolved Hide resolved
value operator.
"""
function overapproximate(lm::LinearMap{N, <:AbstractHyperrectangle{N}},
::Type{Hyperrectangle}) where {N<:Real}
M, X = lm.M, lm.X
center_MX = M * center(X)
radius_MX = abs.(M) * radius_hyperrectangle(X)
return Hyperrectangle(center_MX, radius_MX)
end

"""
overapproximate(S::LazySet)::Union{Hyperrectangle, EmptySet}

Expand Down Expand Up @@ -413,3 +444,4 @@ function overapproximate(cap::Intersection{N,
) where {N<:Real}
return overapproximate(swap(cap), dir; kwargs...)
end

6 changes: 6 additions & 0 deletions test/unit_overapproximate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ for N in [Float64, Rational{Int}, Float32]
Zoa = overapproximate(Z, Hyperrectangle) # faster o.a.
Zba = box_approximation(Z) # default o.a. implementation that uses supp function
@test Zoa.center ≈ Zba.center && Zoa.radius ≈ Zba.radius

# overapproximation of the lazy linear map of a hyperrectangular set
H = Hyperrectangle(N[0, 0], N[1/2, 1])
M = Diagonal(N[2, 2])
OA = overapproximate(M*H, Hyperrectangle)
@test OA isa Hyperrectangle && OA.center == N[0, 0] && OA.radius == N[1, 2]
end

# tests that do not work with Rational{Int}
Expand Down