Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix overapproximate of SSPZ with Zonotope and dom #3531

Merged
merged 1 commit into from
Jun 26, 2024
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
7 changes: 4 additions & 3 deletions src/Approximations/overapproximate_zonotope.jl
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,9 @@ function _overapproximate_union_zonotope_GGP09(X::LazySet{N}) where {N}
end

# Given center, (dependent) generator matrix and exponent matrix of a (simple)
# sparse polynomial zonotope, compute thew new center and generator matrix of
# its zonotope overapproximation.
# sparse polynomial zonotope, compute the new center and generator matrix of
# its zonotope overapproximation. This method assumes that the parameter domain
# is [-1, 1]ᵖ.
function _zonotope_overapprox!(c, G, E)
@inbounds for (j, g) in enumerate(eachcol(G))
if all(iseven, E[:, j])
Expand Down Expand Up @@ -284,7 +285,7 @@ function overapproximate(P::SimpleSparsePolynomialZonotope, ::Type{<:Zonotope},
end
m, r = IA.midpoint_radius(α)
cnew .+= m * g
Gnew[:, j] .= abs.(g) * r
Gnew[:, j] .= r * g
end
return Zonotope(cnew, Gnew)
end
Expand Down
4 changes: 3 additions & 1 deletion test/Sets/SimpleSparsePolynomialZonotope.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ for N in [Float64, Float32, Rational{Int}]
@test nparams(S) == 2
@test order(S) == 1 // 1

@test overapproximate(S, Zonotope) == Zonotope(N[3.0, 1], N[1 1; 2 1.0])
Z = Zonotope(N[3.0, 1], N[1 1; 2 1.0])
@test overapproximate(S, Zonotope) == Z
@test overapproximate(S, UnionSetArray{Zonotope}; nsdiv=1) == UnionSetArray([Z])
@test length(overapproximate(S, UnionSetArray{Zonotope}; nsdiv=3)) == 9
if vIA >= v"0.19.0" # `mince` with non-uniform partition was introduced in IA v0.19.0
@test length(overapproximate(S, UnionSetArray{Zonotope}; partition=(2, 3))) == 6
Expand Down
8 changes: 8 additions & 0 deletions test/Sets/SparsePolynomialZonotope.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ for N in [Float64, Float32, Rational{Int}]
0 0 0 1 0 1;
0 0 0 0 1 3]
Z = overapproximate(PZ2, Zonotope)
SSPZ2 = convert(SimpleSparsePolynomialZonotope, PZ2)
dom2 = IntervalBox(IA.interval(N(-1), N(1)), IA.interval(N(-1), N(1)))
Z2 = overapproximate(SSPZ2, Zonotope, dom2)
@test isequivalent(Z, Z2)
CPPZ = cartesian_product(PZ, Z)
@test center(CPPZ) == N[4, 4, 0, 0]
@test genmat_dep(CPPZ) == N[2 1 2;
Expand Down Expand Up @@ -130,6 +134,10 @@ for N in [Float64, Float32, Rational{Int}]
l2, u2 = extrema(PZ; algorithm="lowhigh")
H2 = Hyperrectangle(; low=l2, high=u2)
@test H2 ⊆ H1 == Hyperrectangle(N[0, 0], N[7 // 2, 5 // 2])
Z = Zonotope(N[0, 0], N[3//2 1 1; 3//2 0 -1])
@test isequivalent(overapproximate(PZ, Zonotope), Z)
SSPZ2 = convert(SimpleSparsePolynomialZonotope, PZ)
@test isequivalent(overapproximate(SSPZ2, Zonotope, dom2), Z)
end

for N in [Float64]
Expand Down
Loading