Skip to content

Commit

Permalink
Merge pull request #3725 from JuliaReach/schillic/isparametrictype
Browse files Browse the repository at this point in the history
Add `isparametrictype` trait
  • Loading branch information
schillic authored Feb 20, 2025
2 parents cec5df9 + ab28bda commit 6232c3d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ConcreteOperations/exact_sum.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# the only parametric sets in this library are polynomial zonotopes;
# hence, we compute the normal Minkowski sum for all other set combinations
# for non-parametric set types, the exact sum coincides with the Minkowski sum
function exact_sum(X::LazySet, Y::LazySet)
@assert dim(X) == dim(Y) "the dimensions of the given sets should match, " *
"but they are $(dim(X)) and $(dim(Y)), respectively"

if X isa AbstractPolynomialZonotope || Y isa AbstractPolynomialZonotope
if isparametrictype(typeof(X)) || isparametrictype(typeof(Y))
throw(ArgumentError("`exact_sum` for set types $(typeof(X)) and " *
"$(typeof(Y)) is not implemented"))
end

return minkowski_sum(X, Y)
end
2 changes: 2 additions & 0 deletions src/Interfaces/AbstractPolynomialZonotope.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ end

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

isparametrictype(::Type{<:AbstractPolynomialZonotope}) = true

dim(PZ::AbstractPolynomialZonotope) = length(center(PZ))

isempty(PZ::AbstractPolynomialZonotope) = false
Expand Down
3 changes: 3 additions & 0 deletions src/Interfaces/LazySet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1650,3 +1650,6 @@ function vertices_list_1d(X::LazySet)
l, h = extrema(X, 1)
return _isapprox(l, h) ? [[l]] : [[l], [h]]
end

# internal function to detect parametric set types
isparametrictype(::Type{<:LazySet}) = false

0 comments on commit 6232c3d

Please sign in to comment.