Skip to content

Commit 6232c3d

Browse files
authored
Merge pull request #3725 from JuliaReach/schillic/isparametrictype
Add `isparametrictype` trait
2 parents cec5df9 + ab28bda commit 6232c3d

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

src/ConcreteOperations/exact_sum.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# the only parametric sets in this library are polynomial zonotopes;
2-
# hence, we compute the normal Minkowski sum for all other set combinations
1+
# for non-parametric set types, the exact sum coincides with the Minkowski sum
32
function exact_sum(X::LazySet, Y::LazySet)
43
@assert dim(X) == dim(Y) "the dimensions of the given sets should match, " *
54
"but they are $(dim(X)) and $(dim(Y)), respectively"
65

7-
if X isa AbstractPolynomialZonotope || Y isa AbstractPolynomialZonotope
6+
if isparametrictype(typeof(X)) || isparametrictype(typeof(Y))
87
throw(ArgumentError("`exact_sum` for set types $(typeof(X)) and " *
98
"$(typeof(Y)) is not implemented"))
109
end
10+
1111
return minkowski_sum(X, Y)
1212
end

src/Interfaces/AbstractPolynomialZonotope.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ end
123123

124124
isboundedtype(::Type{<:AbstractPolynomialZonotope}) = true
125125

126+
isparametrictype(::Type{<:AbstractPolynomialZonotope}) = true
127+
126128
dim(PZ::AbstractPolynomialZonotope) = length(center(PZ))
127129

128130
isempty(PZ::AbstractPolynomialZonotope) = false

src/Interfaces/LazySet.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,3 +1650,6 @@ function vertices_list_1d(X::LazySet)
16501650
l, h = extrema(X, 1)
16511651
return _isapprox(l, h) ? [[l]] : [[l], [h]]
16521652
end
1653+
1654+
# internal function to detect parametric set types
1655+
isparametrictype(::Type{<:LazySet}) = false

0 commit comments

Comments
 (0)