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

#1176 - Box approximation for Rectification #1376

Merged
merged 1 commit into from
May 23, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
30 changes: 30 additions & 0 deletions src/Approximations/box_approximations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,36 @@ box_approximation(S::AbstractHyperrectangle) =
# special case: empty set
box_approximation(∅::EmptySet) = ∅

"""
box_approximation(r::Rectification{N}
)::Union{Hyperrectangle{N}, EmptySet{N}} where {N<:Real}

Overapproximate the rectification of a convex set by a tight hyperrectangle.

### Input

- `S` -- rectification of a convex set

### Output

A hyperrectangle.

### Algorithm

Box approximation and rectification distribute.
Hence we first check whether the wrapped set is empty.
If so, we return the empty set.
Otherwise, we compute the box approximation of the wrapped set, rectify the
resulting box (which is simple), and finally convert the resulting set to a box.
"""
function box_approximation(r::Rectification{N}
)::Union{Hyperrectangle{N}, EmptySet{N}} where {N<:Real}
if isempty(r.X)
return EmptySet{N}()
end
return convert(Hyperrectangle, Rectification(box_approximation(r.X)))
end

"""
interval_hull

Expand Down
5 changes: 5 additions & 0 deletions test/unit_box_approximation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ for N in [Float64, Rational{Int}, Float32]
E = EmptySet{N}()
@test box_approximation(E) == E

# rectification
@test box_approximation(Rectification(EmptySet{N}())) isa EmptySet{N}
r = Rectification(Ball1(N[0, 0], N(1)))
@test box_approximation(r) == Hyperrectangle(low=N[0, 0], high=N[1, 1])

# ===================================================================
# Testing box_approximation_symmetric (= symmetric interval hull)
# ===================================================================
Expand Down