From d2e61681197de3fcd76645d71e8641ac719da937 Mon Sep 17 00:00:00 2001 From: schillic Date: Wed, 1 Jan 2025 11:31:22 +0100 Subject: [PATCH] fix 'minkowski_difference' for polyhedron and bounded set --- .../minkowski_difference.jl | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/ConcreteOperations/minkowski_difference.jl b/src/ConcreteOperations/minkowski_difference.jl index 7dedd1bfa2..bc0fef5191 100644 --- a/src/ConcreteOperations/minkowski_difference.jl +++ b/src/ConcreteOperations/minkowski_difference.jl @@ -2,12 +2,12 @@ minkowski_difference(P::LazySet, Q::LazySet) Concrete Minkowski difference (geometric difference) of a polytopic set and a -compact convex set. +compact set. ### Input - `P` -- polytopic set -- `Q` -- compact convex set that is subtracted from `P` +- `Q` -- compact set that is subtracted from `P` ### Output @@ -25,16 +25,21 @@ This method implements Theorem 2.3 in [1]: Suppose ``P`` is a polyhedron ```math -P = \\{z ∈ ℝ^n: sᵢᵀz ≤ rᵢ,~i = 1, …, N\\}. +P = \\{z ∈ ℝ^n: sᵢᵀz ≤ rᵢ,~i = 1, …, k\\}. ``` where ``sᵢ ∈ ℝ^n, sᵢ ≠ 0``, and ``rᵢ ∈ ℝ``. -Assume ``ρ(sᵢ,Q)`` is defined for ``i = 1, …, N``. +Assume ``ρ(sᵢ,Q)`` is defined for ``i = 1, …, k``. Then the Minkowski difference is ```math -\\{z ∈ ℝ^n: sᵢᵀz ≤ rᵢ - ρ(sᵢ,Q),~i = 1, …, N\\}. +\\{z ∈ ℝ^n: sᵢᵀz ≤ rᵢ - ρ(sᵢ,Q),~i = 1, …, k\\}. ``` +While the algorithm applies the support function to `Q`, we have that +``P ⊖ Q = P ⊖ \\text{CH}(Q)`` whenever `P` is convex, where CH denotes the +convex hull. Hence, if `Q` is not convex by type information, we wrap it in a +lazy `ConvexHull`. + [1] Ilya Kolmanovsky and Elmer G. Gilbert (1997). *Theory and computation of disturbance invariant sets for discrete-time linear systems.* [Mathematical Problems in Engineering Volume 4, Issue 4, Pages @@ -46,6 +51,10 @@ function minkowski_difference(P::LazySet, Q::LazySet) @assert isbounded(Q) "this implementation requires that the second " * "argument is bounded, but it is not" + if !isconvextype(typeof(Q)) + Q = ConvexHull(Q) + end + A, b = tosimplehrep(P) g_PminusQ = [b[i] - ρ(A[i, :], Q) for i in eachindex(b)] if isbounded(P)