Skip to content

Commit 7f91a60

Browse files
authored
Merge pull request #3741 from JuliaReach/schillic/minkowski_difference
Fix `minkowski_difference` for polyhedron and bounded set
2 parents dadc425 + 3ec6d94 commit 7f91a60

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/ConcreteOperations/minkowski_difference.jl

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
minkowski_difference(P::LazySet, Q::LazySet)
33
44
Concrete Minkowski difference (geometric difference) of a polytopic set and a
5-
compact convex set.
5+
compact set.
66
77
### Input
88
99
- `P` -- polytopic set
10-
- `Q` -- compact convex set that is subtracted from `P`
10+
- `Q` -- compact set that is subtracted from `P`
1111
1212
### Output
1313
@@ -25,15 +25,20 @@ This method implements [KolmanovskyG98; Theorem 2.3](@citet):
2525
2626
Suppose ``P`` is a polyhedron
2727
```math
28-
P = \\{z ∈ ℝ^n: sᵢᵀz ≤ rᵢ,~i = 1, …, N\\}.
28+
P = \\{z ∈ ℝ^n: sᵢᵀz ≤ rᵢ,~i = 1, …, k\\}.
2929
```
3030
where ``sᵢ ∈ ℝ^n, sᵢ ≠ 0``, and ``rᵢ ∈ ℝ``.
31-
Assume ``ρ(sᵢ,Q)`` is defined for ``i = 1, …, N``.
31+
Assume ``ρ(sᵢ,Q)`` is defined for ``i = 1, …, k``.
3232
Then the Minkowski difference is
3333
3434
```math
35-
\\{z ∈ ℝ^n: sᵢᵀz ≤ rᵢ - ρ(sᵢ,Q),~i = 1, …, N\\}.
35+
\\{z ∈ ℝ^n: sᵢᵀz ≤ rᵢ - ρ(sᵢ,Q),~i = 1, …, k\\}.
3636
```
37+
38+
While the algorithm applies the support function to `Q`, we have that
39+
``P ⊖ Q = P ⊖ \\text{CH}(Q)`` whenever `P` is convex, where CH denotes the
40+
convex hull. Hence, if `Q` is not convex by type information, we wrap it in a
41+
lazy `ConvexHull`.
3742
"""
3843
function minkowski_difference(P::LazySet, Q::LazySet)
3944
@assert dim(P) == dim(Q) "the dimensions of the given sets should match, " *
@@ -43,6 +48,10 @@ function minkowski_difference(P::LazySet, Q::LazySet)
4348
@assert isbounded(Q) "this implementation requires that the second " *
4449
"argument is bounded, but it is not"
4550

51+
if !isconvextype(typeof(Q))
52+
Q = ConvexHull(Q)
53+
end
54+
4655
A, b = tosimplehrep(P)
4756
g_PminusQ = [b[i] - ρ(A[i, :], Q) for i in eachindex(b)]
4857
if isbounded(P)

0 commit comments

Comments
 (0)