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

Outsource basetype to ReachabilityBase #3503

Merged
merged 1 commit into from
May 14, 2024
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ IntervalArithmetic = "0.15 - 0.21, =0.21.2" # v0.22 removed IntervalBox
JuMP = "0.21 - 0.23, 1"
LinearAlgebra = "<0.0.1, 1.6"
Random = "<0.0.1, 1.6"
ReachabilityBase = "0.2.1"
ReachabilityBase = "0.2.5"
RecipesBase = "0.6 - 0.8, 1"
Reexport = "0.2, 1"
Requires = "0.5, 1"
Expand Down
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
Loading