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

Add isparametrictype trait #3725

Merged
merged 1 commit into from
Feb 20, 2025
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
add 'isparametrictype' trait
  • Loading branch information
schillic committed Jan 4, 2025
commit ab28bda39c6f23bb4f0e1708947fd8c0f3fd360c
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 @@ -119,4 +119,6 @@ end

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

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

dim(PZ::AbstractPolynomialZonotope) = length(center(PZ))
3 changes: 3 additions & 0 deletions src/Interfaces/LazySet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1669,3 +1669,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
Loading