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

Generalize discretization for GLGM06 #713

Merged
merged 4 commits into from
Jan 16, 2020
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
27 changes: 19 additions & 8 deletions src/ReachSets/discretize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -701,8 +701,8 @@ end

# version using concrete operations with zonotopes
function _discretize_interpolation_homog(X0, ϕ, Einit, set_operations::Val{:zonotope})
Einit = convert(Zonotope, Einit)
Z1 = convert(Zonotope, X0)
Einit = _convert_or_overapproximate(Zonotope, Einit)
Z1 = _convert_or_overapproximate(Zonotope, X0)
Z2 = linear_map(ϕ, minkowski_sum(Z1, Einit))
Ω0 = overapproximate(ConvexHull(Z1, Z2), Zonotope)
return Ω0
Expand All @@ -711,11 +711,11 @@ end
# version using concrete operations with zonotopes
function _discretize_interpolation_inhomog(δ, U0, U, X0, ϕ, Einit, Eψ0, A, sih, Phi2Aabs, set_operations::Val{:zonotope})
n = size(A, 1)
Einit = convert(Zonotope, Einit)
Eψ0 = convert(Zonotope, Eψ0)
Z1 = convert(Zonotope, X0)
Einit = _convert_or_overapproximate(Zonotope, Einit)
Eψ0 = _convert_or_overapproximate(Zonotope, Eψ0)
Z1 = _convert_or_overapproximate(Zonotope, X0)
ϕX0 = linear_map(ϕ, Z1)
U0 = convert(Zonotope, U0)
U0 = _convert_or_overapproximate(Zonotope, U0)
δI = Matrix(δ*I, n, n)
δU0 = linear_map(δI, U0)
Z2 = reduce(minkowski_sum, [ϕX0, δU0, Eψ0, Einit])
Expand All @@ -727,8 +727,8 @@ function _discretize_interpolation_inhomog(δ, U0, U, X0, ϕ, Einit, Eψ0, A, si
elseif U isa VaryingInput
Ud = Vector{LazySet}(undef, length(U))
for (k, Uk) in enumerate(U)
Eψk = convert(Zonotope, sih(Phi2Aabs * sih(A * Uk)))
Uk = convert(Zonotope, Uk)
Eψk = _convert_or_overapproximate(Zonotope, sih(Phi2Aabs * sih(A * Uk)))
Uk = _convert_or_overapproximate(Zonotope, Uk)
δUk = linear_map(δI, Uk)
Ud[k] = minkowski_sum(δUk, Eψk)
end
Expand Down Expand Up @@ -887,3 +887,14 @@ function _discretize_interval_matrix_inhomog(U, Ω0_homog, linear_maps,
end
return Ω0, Ud
end

# fallback implementation for conversion (if applicable) or overapproximation
function _convert_or_overapproximate(X::Type{<:AbstractPolytope}, Y::LazySet)
if applicable(convert, X, Y)
return convert(X, Y)
elseif applicable(overapproximate, Y, X)
return overapproximate(Y, X)
else
return convert(X, overapproximate(Y, Hyperrectangle))
end
end
4 changes: 4 additions & 0 deletions test/Reachability/solve_continuous.jl
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ s = solve(IVP(LCS(A), X0), Options(:T=>0.1), op=GLGM06(:max_order=>15))
# affine system, x' = Ax + Bu
s = solve(IVP(CLCCS(A, B, nothing, U), X0), Options(:T=>0.1), op=GLGM06())

# initial set which cannot be converted to a zonotope
X0 = Ball2(ones(4), 0.1)
s = solve(IVP(LCS(A), X0), Options(:T=>0.1), op=GLGM06())

# ======================
# Unbounded-time setting
# ======================
Expand Down