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

Merge and generalize overapproximate methods with HPolytope #844

Merged
merged 1 commit into from
Aug 28, 2024
Merged
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
24 changes: 9 additions & 15 deletions src/Discretization/Overapproximate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,15 @@ end
# _overapproximate
# ================

function _overapproximate(X::Hyperrectangle, T::Type{HPolytope{N,VT}}) where {N,VT}
# TODO create overapproximation using VT directly
Y = overapproximate(X, BoxDirections(dim(X)))
return convert(T, Y)
function _overapproximate(X::AbstractPolytope, T::Type{<:HPolytope})
P = HPolytope(constraints_list(X))
return convert(T, P)
end

# overapproximate a hyperrectangular set with a polytope with `Vector` directions
# (by default it uses `SingleEntryVector` directions)
function _overapproximate(H::AbstractHyperrectangle, ::Type{<:HPolytope})
return HPolytope([HalfSpace(Vector(c.a), c.b) for c in constraints_list(H)])
end

function _overapproximate(lm::LinearMap{N,<:AbstractZonotope{N},NM,<:AbstractIntervalMatrix{NM}},
Expand Down Expand Up @@ -112,17 +117,6 @@ function _overapproximate(S::LazySet{N}, ::Type{<:Hyperrectangle}) where {N}
return Hyperrectangle(c, r)
end

# overapproximate a hyperrectangular set with a polytope
# TODO clean-up
function _overapproximate(H::AbstractHyperrectangle, T::Type{<:HPolytope})
return _overapproximate_hyperrectangle(H, T)
end
_overapproximate(H::Hyperrectangle, T::Type{<:HPolytope}) = _overapproximate_hyperrectangle(H, T)
function _overapproximate_hyperrectangle(H, ::Type{<:HPolytope})
P = overapproximate(H, Hyperrectangle)
return HPolytope([HalfSpace(Vector(c.a), c.b) for c in constraints_list(H)])
end

# compared to LazySets.Approximations._overapproximate_hparallelotope,
# this function does inv(Matrix(Γ))
function _overapproximate_hparallelotope(Z::AbstractZonotope, indices=1:dim(Z))
Expand Down