Skip to content

Commit

Permalink
merge/generalize overapproximate methods
Browse files Browse the repository at this point in the history
  • Loading branch information
schillic committed Jun 16, 2024
1 parent ad8edd5 commit 0bb1aaa
Showing 1 changed file with 9 additions and 15 deletions.
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

0 comments on commit 0bb1aaa

Please sign in to comment.