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

#2154 - Compute the overapproximation of the convex hull array of zonotopes with a zonotope recursively #2185

Merged
merged 8 commits into from
Jun 23, 2020
33 changes: 33 additions & 0 deletions src/Approximations/overapproximate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1703,3 +1703,36 @@ function overapproximate(r::Rectification{N, <:AbstractZonotope{N}}, ::Type{<:Zo

return Zonotope(c, remove_zero_columns(Gout))
end

"""
overapproximate(CHA::ConvexHullArray{N, <:AbstractZonotope{N}}, ::Type{<:Zonotope}) where {N}

Overapproximation of the convex hull array of zonotopic sets.

### Input

- `CHA` -- convex hull array of zonotopic sets
- `Zonotope` -- type for dispatch

### Output

A zonotope overapproximation of the convex hull array of zonotopic sets.

### Algorithm

This function iteratively applies the overapproximation algorithm for the
convex hull of two zonotopes to the given array of zonotopes.
"""
function overapproximate(CHA::ConvexHullArray{N, <:AbstractZonotope{N}}, ::Type{<:Zonotope}) where {N}
arr = array(CHA)
n = length(arr)
if n == 1
return arr[1]
else
Zaux = overapproximate(ConvexHull(arr[1], arr[2]), Zonotope)
for k in 3:n
Zaux = overapproximate(ConvexHull(Zaux, arr[k]), Zonotope)
end
return Zaux
end
end
11 changes: 11 additions & 0 deletions test/unit_overapproximate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -373,4 +373,15 @@ for N in [Float64]
y = set_variables("y", numvars=2, order=1)
p = zero(y[1])
@test get_linear_coeffs(p) == N[0, 0]

# Zonotope approximation of convex hull array of zonotopes
Z1 = Zonotope(N[3, 0], N[1 2 1; 1 1 2])
Z2 = Zonotope(N[1, 0], N[-2 1; 1 1])
Z3 = Zonotope(N[0, 0], N[1 0; 0 1])
@test overapproximate(ConvexHullArray([Z1]), Zonotope) == Z1
@test overapproximate(ConvexHullArray([Z1, Z2]), Zonotope) == overapproximate(ConvexHull(Z1, Z2), Zonotope)
Y = overapproximate(ConvexHullArray([Z1, Z2, Z3]), Zonotope)
@test Z1 ⊆ Y
@test Z2 ⊆ Y
@test Z3 ⊆ Y
end