Skip to content
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
10 changes: 5 additions & 5 deletions src/ConcreteOperations/issubset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ end

function _issubset_in_hyperrectangle(S, H, witness)
n = dim(S)
@assert n == dim(H)
@assert n == dim(H) "incompatible set dimensions $n and $(dim(H))"
N = promote_type(eltype(S), eltype(H))

for i in 1:n
Expand Down Expand Up @@ -84,7 +84,7 @@ end
"""
function ⊆(H1::AbstractHyperrectangle, H2::AbstractHyperrectangle,
witness::Bool=false)
@assert dim(H1) == dim(H2)
@assert dim(H1) == dim(H2) "incompatible set dimensions $(dim(H1)) and $(dim(H2))"
N = promote_type(eltype(H1), eltype(H2))

@inbounds for i in 1:dim(H1)
Expand Down Expand Up @@ -137,7 +137,7 @@ Since ``S`` is convex, ``P ⊆ S`` iff ``v ∈ S`` for all vertices ``v`` of ``P
"""
function ⊆(P::AbstractPolytope, S::LazySet, witness::Bool=false;
algorithm=nothing)
@assert dim(P) == dim(S)
@assert dim(P) == dim(S) "incompatible set dimensions $(dim(P)) and $(dim(S))"
if !isconvextype(typeof(S))
error("an inclusion check for the given combination of set types is " *
"not available")
Expand Down Expand Up @@ -210,7 +210,7 @@ end
# S ⊆ P where P = ⟨Cx ≤ d⟩ iff y ≤ d where y is the upper corner of box(C*S).
# See [WetzlingerKBA23; Proposition 7](@citet).
function _issubset_in_polyhedron_high(S::LazySet, P::LazySet, witness::Bool=false)
@assert dim(S) == dim(P)
@assert dim(S) == dim(P) "incompatible set dimensions $(dim(S)) and $(dim(P))"

C, d = tosimplehrep(P)
x = high(C * S)
Expand All @@ -231,7 +231,7 @@ end
# See [WetzlingerKBA23; Proposition 7](@citet).
function _issubset_zonotope_in_polyhedron(Z::AbstractZonotope, P::LazySet,
witness::Bool=false)
@assert dim(Z) == dim(P)
@assert dim(Z) == dim(P) "incompatible set dimensions $(dim(Z)) and $(dim(P))"

# corner case: no generator
if ngens(Z) == 0
Expand Down
12 changes: 9 additions & 3 deletions src/ConcreteOperations/minkowski_difference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,16 @@ end

for T in (:LazySet, :AbstractZonotope, :AbstractHyperrectangle)
# Minkowski difference with singleton is a translation
@eval minkowski_difference(X::($T), S::AbstractSingleton) = translate(X, -element(S))
@eval function minkowski_difference(X::($T), S::AbstractSingleton)
@assert dim(X) == dim(S) "incompatible set dimensions $(dim(X)) and $(dim(S))"
return translate(X, -element(S))
end

# Minkowski difference with ZeroSet is the identity
@eval minkowski_difference(X::($T), ::ZeroSet) = X
@eval function minkowski_difference(X::($T), Z::ZeroSet)
@assert dim(X) == dim(Z) "incompatible set dimensions $(dim(X)) and $(dim(Z))"
return X
end
end

"""
Expand All @@ -81,7 +87,7 @@ A `Hyperrectangle`, or an `EmptySet` if the difference is empty.
function minkowski_difference(H1::AbstractHyperrectangle,
H2::AbstractHyperrectangle)
n = dim(H1)
@assert n == dim(H2) "incompatible dimensions"
@assert n == dim(H2) "incompatible dimensions $n and $(dim(H2))"

N = promote_type(eltype(H1), eltype(H2))
r = Vector{N}(undef, n)
Expand Down
1 change: 1 addition & 0 deletions src/ConcreteOperations/minkowski_sum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ end
The resulting hyperrectangle is obtained by summing up the centers and radii.
"""
function minkowski_sum(H1::AbstractHyperrectangle, H2::AbstractHyperrectangle)
@assert dim(H1) == dim(H2) "incompatible set dimensions $(dim(H1)) and $(dim(H2))"
c = center(H1) + center(H2)
r = radius_hyperrectangle(H1) + radius_hyperrectangle(H2)
return Hyperrectangle(c, r)
Expand Down
4 changes: 2 additions & 2 deletions test/Sets/Interval.jl
Original file line number Diff line number Diff line change
Expand Up @@ -554,8 +554,8 @@ for N in [Float64, Float32, Rational{Int}]
@test U2 isa Universe{N} && dim(U2) == 1

# minkowski_sum
@test_throws DimensionMismatch minkowski_sum(X, X2)
@test_throws DimensionMismatch minkowski_sum(X2, X)
@test_throws AssertionError minkowski_sum(X, X2)
@test_throws AssertionError minkowski_sum(X2, X)
# Interval + Interval = Interval
Y = minkowski_sum(X, X)
Z = Interval(N(0), N(4))
Expand Down
Loading