Skip to content

Commit

Permalink
add box_approximation for Rectification
Browse files Browse the repository at this point in the history
  • Loading branch information
schillic committed May 15, 2019
1 parent b1420d1 commit 7de9107
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
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 a 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

0 comments on commit 7de9107

Please sign in to comment.