diff --git a/src/ConcreteOperations/exact_sum.jl b/src/ConcreteOperations/exact_sum.jl new file mode 100644 index 0000000000..8a86f21177 --- /dev/null +++ b/src/ConcreteOperations/exact_sum.jl @@ -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 diff --git a/src/ConcreteOperations/minkowski_sum.jl b/src/ConcreteOperations/minkowski_sum.jl index db31af12e5..28e9fb01e9 100644 --- a/src/ConcreteOperations/minkowski_sum.jl +++ b/src/ConcreteOperations/minkowski_sum.jl @@ -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. """ @@ -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)) diff --git a/src/LazySets.jl b/src/LazySets.jl index dbe10ea97d..9886c17692 100644 --- a/src/LazySets.jl +++ b/src/LazySets.jl @@ -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")