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

#639 - Compact sets #649

Merged
merged 3 commits into from
Sep 22, 2018
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
7 changes: 7 additions & 0 deletions docs/src/lib/interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ an_element(::LazySet{Real})
==(::LazySet, ::LazySet)
```

### Aliases for set types

```@docs
CompactSet
NonCompactSet
```

## Centrally symmetric set

Centrally symmetric sets such as balls of different norms are characterized by a
Expand Down
5 changes: 5 additions & 0 deletions src/LazySets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ include("concrete_intersection.jl")
include("is_intersection_empty.jl")
include("is_subset.jl")

# =======
# Aliases
# =======
include("aliases.jl")

# =====================
# Approximations module
# =====================
Expand Down
34 changes: 34 additions & 0 deletions src/aliases.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
export CompactSet,
NonCompactSet

"""
CompactSet

An alias for compact set types.

### Notes

Most lazy operations are not captured by this alias because whether their result
is compact or not depends on the argument(s).
"""
const CompactSet = Union{
AbstractCentrallySymmetric,
AbstractPolytope,
EmptySet
}

"""
NonCompactSet

An alias for non-compact set types.

### Notes

Most lazy operations are not captured by this alias because whether their result
is non-compact or not depends on the argument(s).
"""
const NonCompactSet = Union{
HalfSpace,
Hyperplane,
Line
}
5 changes: 5 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ if test_suite_basic
@time @testset "LazySets.CartesianProduct" begin include("unit_CartesianProduct.jl") end
@time @testset "LazySets.SymmetricIntervalHull" begin include("unit_SymmetricIntervalHull.jl") end

# ======================
# Testing set interfaces
# ======================
@time @testset "LazySets.CompactSet" begin include("unit_CompactSet.jl") end

# =================================================================
# Algorithms for approximation of convex sets using support vectors
# =================================================================
Expand Down
16 changes: 16 additions & 0 deletions test/unit_CompactSet.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
for N in [Float64, Rational{Int}, Float32]
# compact set
@test Ball1 <: CompactSet && !(Ball1 <: NonCompactSet)
b = Ball1(N[0, 1], N(1))
@test b isa CompactSet && !(b isa NonCompactSet)

# non-compact set
@test Line <: NonCompactSet && !(Line <: CompactSet)
l = Line(N[0, 1], N(1))
@test l isa NonCompactSet && !(l isa CompactSet)

# lazy operations are neither compact nor non-compact by default
@test !(MinkowskiSum <: CompactSet) && !(MinkowskiSum <: NonCompactSet)
ms = b + l
@test !(ms isa CompactSet) && !(ms isa NonCompactSet)
end