Skip to content

Commit

Permalink
Merge pull request #3670 from JuliaReach/schillic/exact_sum
Browse files Browse the repository at this point in the history
Default implementation for `exact_sum`
  • Loading branch information
schillic authored Dec 14, 2024
2 parents 9cae0bd + a336b5d commit dd5361b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
12 changes: 12 additions & 0 deletions src/ConcreteOperations/exact_sum.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# the only parametric sets in this library are polynomial zonotopes;
# hence, we compute the normal Minkowski sum for all other set combinations
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
throw(ArgumentError("`exact_sum` for set types $(typeof(X)) and " *
"$(typeof(Y)) is not implemented"))
end
return minkowski_sum(X, Y)
end
6 changes: 3 additions & 3 deletions src/ConcreteOperations/minkowski_sum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ be bounded by their types, and an `HPolyhedron` otherwise.
### Notes
This function requires that the list of constraints of both sets `P` and `Q` can
This method requires that the list of constraints of both sets `P` and `Q` can
be obtained. After obtaining the respective lists of constraints, the
`minkowski_sum` method for polyhedral sets is used.
"""
Expand All @@ -33,8 +33,8 @@ function minkowski_sum(P::LazySet, Q::LazySet;
@assert n == dim(Q) "expected that the sets have the same dimension, " *
"but they are $n and $(dim(Q)) respectively"

@assert ispolyhedral(P) && ispolyhedral(Q) "this function requires " *
"polyhedral sets; try overapproximating with an `HPolytope` or " *
@assert ispolyhedral(P) && ispolyhedral(Q) "this method requires polyhedral sets; try " *
"overapproximating with an `HPolytope` or " *
"`HPolyhedron` first"

if n == 2 && isboundedtype(typeof(P)) && isboundedtype(typeof(Q))
Expand Down
1 change: 1 addition & 0 deletions src/LazySets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ include("ConcreteOperations/cartesian_product.jl")
include("ConcreteOperations/convex_hull.jl")
include("ConcreteOperations/difference.jl")
include("ConcreteOperations/distance.jl")
include("ConcreteOperations/exact_sum.jl")
include("ConcreteOperations/intersection.jl")
include("ConcreteOperations/isapprox.jl")
include("ConcreteOperations/isdisjoint.jl")
Expand Down

0 comments on commit dd5361b

Please sign in to comment.