From 92b5729b45bc7fb11a296a933848bcccd27b356e Mon Sep 17 00:00:00 2001 From: schillic Date: Wed, 8 Jan 2025 08:50:49 +0100 Subject: [PATCH 1/2] merge methods --- src/ReachSets/AbstractReachSet.jl | 8 +++----- src/ReachSets/TaylorModelReachSet.jl | 4 ---- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/ReachSets/AbstractReachSet.jl b/src/ReachSets/AbstractReachSet.jl index 6793c5f7cf..7fb4c99c53 100644 --- a/src/ReachSets/AbstractReachSet.jl +++ b/src/ReachSets/AbstractReachSet.jl @@ -258,16 +258,14 @@ end # Concrete intersection methods # ------------------------------ -function intersection(R::AbstractReachSet, S::AbstractReachSet) - return _intersection(set(R), set(S), FallbackIntersection()) -end -function _intersection(R::AbstractReachSet, S::AbstractReachSet, method::AbstractIntersectionMethod) +function intersection(R::AbstractReachSet, S::AbstractReachSet, + method::AbstractIntersectionMethod=FallbackIntersection()) return _intersection(set(R), set(S), method) end # fallback methods for reach-sets @commutative function _intersection(R::AbstractReachSet, X::LazySet, - method::AbstractIntersectionMethod) + method::AbstractIntersectionMethod=FallbackIntersection()) return _intersection(set(R), X, method) end diff --git a/src/ReachSets/TaylorModelReachSet.jl b/src/ReachSets/TaylorModelReachSet.jl index 06030a2ba1..9f28ed2df7 100644 --- a/src/ReachSets/TaylorModelReachSet.jl +++ b/src/ReachSets/TaylorModelReachSet.jl @@ -69,10 +69,6 @@ end # ====================== # for TMs, we overapproximate with a zonotope -function _intersection(R::TaylorModelReachSet, Y::LazySet) - return _intersection(R, Y, FallbackIntersection()) -end - function _intersection(R::TaylorModelReachSet, Y::LazySet, ::FallbackIntersection) X = set(overapproximate(R, Zonotope)) return intersection(X, Y) From 6538da6a083582d6aa5495c38dfc058fdb989df7 Mon Sep 17 00:00:00 2001 From: schillic Date: Wed, 8 Jan 2025 09:02:27 +0100 Subject: [PATCH 2/2] let intersection of reach sets create a reach set --- src/ReachSets/AbstractReachSet.jl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ReachSets/AbstractReachSet.jl b/src/ReachSets/AbstractReachSet.jl index 7fb4c99c53..1006a0d8e6 100644 --- a/src/ReachSets/AbstractReachSet.jl +++ b/src/ReachSets/AbstractReachSet.jl @@ -260,7 +260,15 @@ end function intersection(R::AbstractReachSet, S::AbstractReachSet, method::AbstractIntersectionMethod=FallbackIntersection()) - return _intersection(set(R), set(S), method) + T1 = tspan(R) + T2 = tspan(S) + T = T1 ∩ T2 + if isempty(T) + throw(ArgumentError("cannot intersect reach sets with disjoint time intervals")) + end + + cap = _intersection(set(R), set(S), method) + return ReachSet(cap, T) end # fallback methods for reach-sets