Skip to content

Commit a3bbbe7

Browse files
authored
Merge pull request #3841 from JuliaReach/schillic/simplify
Simplify `overapproximate` of `SPZ` to `VPolytope`
2 parents 4ba8d8f + 6772ed2 commit a3bbbe7

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

src/Approximations/overapproximate.jl

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -616,27 +616,30 @@ Overapproximate a sparse polynomial zonotope with a polytope in vertex represent
616616
617617
### Output
618618
619-
A `VPolytope` that overapproximates the sparse polynomial zonotope.
619+
A `VPolytope`.
620620
621621
### Algorithm
622622
623623
This method implements [Kochdumper21a; Proposition 3.1.15](@citet).
624-
The idea is to split `P` into a linear and nonlinear part (such that `P = P₁ ⊕ P₂`).
624+
The idea is to split `P` into a linear and nonlinear part (such that `P = P₁ ⊕ P₂`).
625625
The nonlinear part is enclosed by a zonotope. Then we combine the vertices
626626
of both sets and finally apply a convex-hull algorithm.
627627
"""
628628
function overapproximate(P::SparsePolynomialZonotope{N}, ::Type{<:VPolytope}) where {N}
629+
n = dim(P)
629630
c = center(P)
630631
G = genmat_dep(P)
631632
GI = genmat_indep(P)
632633
E = expmat(P)
633-
idx = P.idx
634634

635-
H = [j for j in 1:size(E, 2) if any(E[:, j] .> 1)]
636-
K = setdiff(1:size(E, 2), H)
635+
H = Int[]
636+
K = Int[]
637+
for j in 1:size(E, 2)
638+
push!(any(E[:, j] .> 1) ? H : K, j)
639+
end
637640

638641
if !isempty(H)
639-
SPZ₂ = SparsePolynomialZonotope(c, G[:, H], zeros(N, length(c), 0), E[:, H], idx)
642+
SPZ₂ = SparsePolynomialZonotope(c, G[:, H], zeros(N, n, 0), E[:, H], P.idx)
640643
Z = overapproximate(SPZ₂, Zonotope)
641644
c_z = center(Z)
642645
GI_mod = hcat(GI, genmat(Z))
@@ -648,15 +651,15 @@ function overapproximate(P::SparsePolynomialZonotope{N}, ::Type{<:VPolytope}) wh
648651
G_mod = G[:, K]
649652
E_mod = E[:, K]
650653

651-
# P̄ = SparsePolynomialZonotope(c_z, G_mod, GI_mod, E_mod, idx)
652-
# Compute vertices of a Z-representation
654+
# conceptually: P̄ = SparsePolynomialZonotope(c_z, G_mod, GI_mod, E_mod)
655+
# compute vertices of a Z-representation
653656
p = size(E, 1)
654657
dep_params = Iterators.product(fill([-one(N), one(N)], p)...)
655-
indep_params = Iterators.product(fill([-one(N), one(N)], size(GI_mod, 2))...)
658+
vlist_Z = vertices_list(Zonotope(zeros(N, n), GI_mod))
656659

657-
V = Vector{Vector{N}}()
660+
vlist = Vector{Vector{N}}()
658661
for α in dep_params
659-
dep_term = zeros(N, size(c))
662+
dep_term = copy(c_z)
660663
for j in axes(G_mod, 2)
661664
prod = one(N)
662665
for k in 1:p
@@ -666,19 +669,15 @@ function overapproximate(P::SparsePolynomialZonotope{N}, ::Type{<:VPolytope}) wh
666669
end
667670
dep_term += prod * G_mod[:, j]
668671
end
669-
for β in indep_params
670-
indep_term = zeros(N, size(c))
671-
for j in axes(GI_mod, 2)
672-
indep_term += β[j] * GI_mod[:, j]
673-
end
674-
point = c_z + dep_term + indep_term
675-
push!(V, point)
672+
for p in vlist_Z
673+
point = dep_term + p
674+
push!(vlist, point)
676675
end
677676
end
678677

679-
convex_hull!(V)
678+
convex_hull!(vlist)
680679

681-
return VPolytope(V)
680+
return VPolytope(vlist)
682681
end
683682

684683
# function to be loaded by Requires

0 commit comments

Comments
 (0)