Skip to content

Commit

Permalink
adapt to renamed kwarg in 'Polyhedra.removeredundancy' ('ztol' -> 'tol')
Browse files Browse the repository at this point in the history
  • Loading branch information
schillic committed Jan 21, 2025
1 parent 404e940 commit 5527533
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/ConcreteOperations/intersection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ A `VPolytope`.
### Notes
If `prunefunc` is `nothing`, this implementation sets it to
`(X -> removevredundancy!(X; ztol=_ztol(eltype(P1))))`.
`(X -> removevredundancy!(X; tol=_ztol(eltype(P1))))`.
"""
function intersection(P1::Union{VPolygon,VPolytope},
P2::Union{VPolygon,VPolytope};
Expand Down Expand Up @@ -578,7 +578,7 @@ function intersection(P1::Union{VPolygon,VPolytope},

N = promote_type(eltype(P1), eltype(P2))
if isnothing(prunefunc)
prunefunc = (X -> removevredundancy!(X; ztol=_ztol(N)))
prunefunc = (X -> _removeredundancy!(X; N=N))
end
prunefunc(Pint)

Expand Down
13 changes: 13 additions & 0 deletions src/Initialization/init_Polyhedra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ function _is_polyhedra_backend(backend::Polyhedra.Library)
return true
end

# in v0.8.0, `Polyhedra` renamed the kwarg `ztol` to `tol`
@static if hasmethod(Polyhedra.detecthlinearity, (Polyhedra.HRepresentation, Any), (:ztol,))
function _removeredundancy!(X; N)
return removevredundancy!(X; ztol=_ztol(N))
end
else
@assert hasmethod(Polyhedra.detecthlinearity, (Polyhedra.HRepresentation, Any), (:tol,))

function _removeredundancy!(X; N)
return removevredundancy!(X; tol=_ztol(N))
end
end

eval(load_polyhedra_mesh())
eval(load_Polyhedra_polyhedron())

Expand Down
3 changes: 2 additions & 1 deletion src/Interfaces/AbstractPolyhedron.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,14 @@ function _linear_map_hrep_helper(M::AbstractMatrix, P::LazySet,
return HPolyhedron(constraints)
end

# internal functions; defined here due to dependency SymEngine and submodules
# internal functions; defined here due to optional dependencies and submodules
function isfeasible end
function remove_redundant_constraints end
function remove_redundant_constraints! end
function _ishalfspace end
function _ishyperplanar end
function _parse_linear_expression end
function _removeredundancy! end

# To account for the compilation order, other functions are defined in the file
# AbstractPolyhedron_functions.jl
3 changes: 2 additions & 1 deletion src/Sets/HPolytope/HPolytopeModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ using Reexport, Requires
using ..LazySets: AbstractPolytope, LazySet, AbstractLinearMapAlgorithm,
default_polyhedra_backend, vertices_list_1d,
_infeasible_constraints_list, _linear_map_hrep,
_minkowski_sum_hrep_preprocess, _normal_Vector
_minkowski_sum_hrep_preprocess, _normal_Vector,
_removeredundancy!
using ..HalfSpaceModule: HalfSpace
using Random: AbstractRNG, GLOBAL_RNG
using ReachabilityBase.Distribution: reseed!
Expand Down
2 changes: 1 addition & 1 deletion src/Sets/HPolytope/vertices_list.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function vertices_list(P::HPolytope; backend=nothing, prune::Bool=true)
end
Q = Polyhedra.polyhedron(P; backend=backend)
if prune
Polyhedra.removevredundancy!(Q; ztol=_ztol(N))
_removeredundancy!(Q; N=N)
end
return collect(Polyhedra.points(Q))
end
3 changes: 2 additions & 1 deletion src/Sets/VPolytope/VPolytopeModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ using Reexport, Requires
using ..LazySets: AbstractPolytope, LazySet, LinearMapVRep, default_lp_solver,
default_lp_solver_polyhedra, default_polyhedra_backend,
is_lp_infeasible, is_lp_optimal, linprog, _extrema_vlist,
_high_vlist, _low_vlist, _minkowski_sum_vrep_nd
_high_vlist, _low_vlist, _minkowski_sum_vrep_nd,
_removeredundancy!
using LinearAlgebra: dot
using Random: AbstractRNG, GLOBAL_RNG
using ReachabilityBase.Arrays: projection_matrix
Expand Down
2 changes: 1 addition & 1 deletion src/Sets/VPolytope/remove_redundant_vertices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function remove_redundant_vertices(P::VPolytope; backend=nothing, solver=nothing
vQ = Polyhedra.vrep(Q)
Polyhedra.setvrep!(Q, Polyhedra.removevredundancy(vQ, solver))
else
Polyhedra.removevredundancy!(Q; ztol=_ztol(N))
_removeredundancy!(Q; N=N)
end
return VPolytope(Q)
end

0 comments on commit 5527533

Please sign in to comment.