Skip to content

Commit

Permalink
Merge pull request #649 from JuliaReach/schillic/639
Browse files Browse the repository at this point in the history
#639 - Compact sets
  • Loading branch information
schillic authored Sep 22, 2018
2 parents 450261c + fb4b372 commit 808c6bd
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 0 deletions.
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

0 comments on commit 808c6bd

Please sign in to comment.