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

AbstractPolyhedron: fix isbounded necessary check #3774

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
10 changes: 7 additions & 3 deletions src/Interfaces/AbstractPolyhedron_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -683,8 +683,9 @@ Check whether a polyhedron is bounded.

### Algorithm

We first check if the polyhedron has more than `dim(P)` constraints, which is a
necessary condition for boundedness.
We first check whether the polyhedron has more than `dim(P)` constraints and, if
so, whether the constraints are feasible, which is a necessary condition for
boundedness.

If so, we check boundedness via `_isbounded_stiemke`.
"""
Expand All @@ -697,7 +698,10 @@ function isbounded(constraints::AbstractVector{<:HalfSpace{N}};
if isempty(constraints)
return false
elseif length(constraints) <= dim(first(constraints))
return false # need at least n+1 constraints to be bounded
# need at least n+1 constraints to be bounded unless infeasible
if isfeasible(constraints; solver=solver)
return false
end
end
return _isbounded_stiemke(constraints; solver=solver)
end
Expand Down
6 changes: 3 additions & 3 deletions test/LazyOperations/UnionSet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ for N in [Float64, Rational{Int}, Float32]
Uarr = UnionSetArray([EmptySet{N}(2), B1])
@test an_element(Uarr) ∈ Uarr

# boundedness of unbounded unions
@test !isbounded(UXY) && !isboundedtype(typeof(UXY))
# boundedness of unions with unbounded type
@test isbounded(UXY) && !isboundedtype(typeof(UXY))
Uarr = UnionSetArray([X, B1])
@test !isbounded(Uarr) && !isboundedtype(typeof(Uarr))
@test isbounded(Uarr) && !isboundedtype(typeof(Uarr))

# ispolyhedral
@test ispolyhedral(UXY)
Expand Down
5 changes: 5 additions & 0 deletions test/Sets/Polyhedron.jl
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ for N in [Float64, Float32]
@test _isbounded_unit_dimensions(p_univ)
@test _isbounded_unit_dimensions(p)
@test !_isbounded_unit_dimensions(HPolyhedron([HalfSpace(N[1, 0], N(1))]))
# quick tests with low number of constraints
P = HPolyhedron([HalfSpace(N[1, 0, 0], N(0)), HalfSpace(N[-1, 0, 0], N(-1))])
@test isbounded(P)
P = HPolyhedron([HalfSpace(N[1, 0, 0], N(0)), HalfSpace(N[0, 1, 0], N(0))])
@test !isbounded(P)
end

# Polyhedra tests that only work with Float64
Expand Down
Loading