Skip to content

Commit

Permalink
Merge pull request #3503 from JuliaReach/schillic/basetype
Browse files Browse the repository at this point in the history
Outsource `basetype` to ReachabilityBase
  • Loading branch information
schillic authored May 14, 2024
2 parents 3f9b7ae + cef46ba commit 05f27b0
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 54 deletions.
14 changes: 10 additions & 4 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,21 @@ instantaneous.
julia> Y = CH(SparseMatrixExp(A * δ) * X0 + δ * B * U, X0);
```

By asking for the concrete type of `Y`, we see that it has a convex hull type,
parameterized by the types of its arguments, corresponding to the mathematical
formulation:
By asking for the (parameter-free) type of `Y`, we see that it is a lazy convex
hull:

```jldoctest index_label
julia> basetype(Y)
julia> LazySets.basetype(Y)
ConvexHull
```

The full type includes type parameters for the types of the arguments:

```jldoctest index_label
julia> typeof(Y)
ConvexHull{Float64, MinkowskiSum{Float64, ExponentialMap{Float64, Ball2{Float64, Vector{Float64}}}, LinearMap{Float64, BallInf{Float64, Vector{Float64}}, Float64, Matrix{Float64}}}, Ball2{Float64, Vector{Float64}}}
```

Now suppose that we are interested in observing the projection of ``\mathcal{Y}``
onto the variables number 1 and 500.
First we define the ``2×1000`` projection matrix and apply it to ``\mathcal{Y}`` as
Expand Down
1 change: 0 additions & 1 deletion docs/src/lib/interfaces/LazySet.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ extrema(::LazySet, ::Int)
extrema(::LazySet)
convex_hull(::LazySet; kwargs...)
triangulate(::LazySet)
basetype
isboundedtype(::Type{<:LazySet})
isbounded(::LazySet)
_isbounded_unit_dimensions(::LazySet)
Expand Down
46 changes: 0 additions & 46 deletions src/Interfaces/LazySet.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export LazySet,
basetype,
neutral,
absorbing,
tosimplehrep,
Expand Down Expand Up @@ -326,51 +325,6 @@ The default implementation assumes that the first type parameter is `N`.
"""
eltype(::LazySet{N}) where {N} = N

"""
basetype(T::Type{<:LazySet})
Return the base type of the given set type (i.e., without type parameters).
### Input
- `T` -- set type
### Output
The base type of `T`.
"""
basetype(T::Type{<:LazySet}) = Base.typename(T).wrapper

"""
basetype(X::LazySet)
Return the base type of the given set (i.e., without type parameters).
### Input
- `X` -- set
### Output
The base type of `X`.
### Examples
```jldoctest
julia> Z = rand(Zonotope);
julia> basetype(Z)
Zonotope
julia> basetype(Z + Z)
MinkowskiSum
julia> basetype(LinearMap(rand(2, 2), Z + Z))
LinearMap
```
"""
basetype(X::LazySet) = basetype(typeof(X))

"""
### Algorithm
Expand Down
1 change: 1 addition & 0 deletions src/LazySets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ using ReachabilityBase.Commutative
using ReachabilityBase.Distribution
using ReachabilityBase.Subtypes
using ReachabilityBase.Arrays
using ReachabilityBase.Basetype

# =================
# External packages
Expand Down
5 changes: 2 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ using Symbolics
# ==============================
# Non-exported helper functions
# ==============================
using LazySets: _leq, _geq, isapproxzero, _isapprox, _ztol, ispermutation
using LazySets.Arrays: isinvertible, inner, allequal,
is_cyclic_permutation, SingleEntryVector
using LazySets: _leq, _geq, isapproxzero, _isapprox, _ztol, ispermutation, basetype
using LazySets.Arrays: isinvertible, inner, allequal, is_cyclic_permutation, SingleEntryVector

global test_suite_basic = true
global test_suite_polyhedra = true
Expand Down

0 comments on commit 05f27b0

Please sign in to comment.