Skip to content

Commit

Permalink
add quadratic map of a zonotope
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianGuadalupe committed Jul 28, 2020
1 parent 77e9f6c commit 66b7852
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/src/lib/sets/Zonotope.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ split(::AbstractZonotope, ::Int)
split(::AbstractZonotope, ::AbstractVector{Int}, ::AbstractVector{Int})
remove_zero_generators(::Zonotope)
linear_map!(::Zonotope, ::AbstractMatrix, ::Zonotope)
quadratic_map(::Zonotope{N}, ::Array{A}) where {N, A<:Array{N}}
```

Inherited from [`LazySet`](@ref):
Expand Down
52 changes: 52 additions & 0 deletions src/Sets/Zonotope.jl
Original file line number Diff line number Diff line change
Expand Up @@ -427,3 +427,55 @@ function linear_map!(Zout::Zonotope, M::AbstractMatrix, Z::Zonotope)
mul!(Zout.generators, M, Z.generators)
return Zout
end

"""
quadratic_map(Z::Zonotope{N}, Q::Array{A}) where {N, A<:Array{N}}
Return the overapproximation of the quadratic map of the given zonotope.
### Input
- `Z` -- zonotope
- `Q` -- array of square matrices
### Output
The overapproximation of the quadratic map of the given zonotope.
### Algorithm
This function implements [Lemma 1, 1]
[1] *Matthias Althoff and Bruce H. Krogh. 2012. Avoiding geometric intersection
operations in reachability analysis of hybrid systems. In Proceedings of the
15th ACM international conference on Hybrid Systems: Computation and Control
(HSCC ’12). Association for Computing Machinery, New York, NY, USA, 45–54.*
"""
function quadratic_map(Z::Zonotope{N}, Q::Array{A}) where {N, A<:Array{N}}
@assert length(Q) == dim(Z) "the length of Q needs to match the dimension of Z"
G = genmat(Z)
c = center(Z)
n, p = size(G)
h = Array{N}(undef, n, binomial(p+2, 2)-1)
d = Vector{N}(undef, n)
for i=1:n
aux = 0
g(x) = G[:, x]
for s=1:p
aux += g(s)' * Q[i] * g(s)
end
d[i] = c' * Q[i] * c + 0.5 * aux
for j=1:p
h[i, j] = c' * Q[i] * g(j) + g(j)' * Q[i] * c
h[i, p+j] = 0.5 * g(j)' * Q[i] * g(j)
end
l = 0
for j=1:p-1
for k=j+1:p
l += 1
h[i, 2p+l] = g(j)' * Q[i] * g(k) + g(k)' * Q[i] * g(j)
end
end
end
return Zonotope(d, h)
end

0 comments on commit 66b7852

Please sign in to comment.