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

#619 Is intersection empty for polytopes #624

Merged
merged 9 commits into from
Sep 18, 2018
Merged

#619 Is intersection empty for polytopes #624

merged 9 commits into from
Sep 18, 2018

Conversation

mforets
Copy link
Member

@mforets mforets commented Sep 13, 2018

Closes #619.

@mforets mforets changed the title #619 Is intersection empty for polytopes #619 WIP Is intersection empty for polytopes Sep 13, 2018
@mforets mforets changed the title #619 WIP Is intersection empty for polytopes #619 Is intersection empty for polytopes Sep 15, 2018
"""
function isempty(P::AbstractPolytope{N})::Bool where {N<:Real}
return isempty(vertices_list(P))
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if this is the correct interpretation. To me, an HPolytope/HPolygon with no constraints is either not defined or universal (because each new constraint removes parts of the set).

Also, add a new line at the end of the file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that the HPolytope with no constraints is particular case that could be treated separately as being "universal", the whole R^n.

For VPolytope, i think it is reasonable to say that if it has no vertices then it only contains the empty set, V = convex_hull{{}}.

I was concerned with the case where the set is defined by a set of constraints with empty intersection. For instance consider the pair of constraints x <= -1 && x >= 1:

julia> P = HPolytope([LazySets.HalfSpace([1.0, 0.0], -1.0), LazySets.HalfSpace([-1.0, 0.0], -1.0)])
LazySets.HPolytope{Float64}(LazySets.HalfSpace{Float64}[LazySets.HalfSpace{Float64}([1.0, 0.0], -1.0), LazySets.HalfSpace{Float64}([-1.0, 0.0], -1.0)])

julia> isempty(P)
true

julia> vertices_list(P)
0-element Array{Array{Float64,1},1}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than finding workarounds, we could accept that our algorithms are generally not correct for invalid polytope inputs, like unbounded or contradicting constraints 😉

For VPolytope, i think it is reasonable to say that if it has no vertices then it only contains the empty set, V = convex_hull{{}}.

Sure.

If HPolytope and HPolygon are problematic, should we replace AbstractPolytope by Union{VPolygon, VPolytope} then? Our other polytopic sets can never be empty by definition anyway.

witness::Bool=false
)::Union{Bool, Tuple{Bool, Vector{N}}} where {N<:Real}

Check whether a pair of polytopes do not intersect, and otherwise optionally
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"a pair of" → "two"

@schillic
Copy link
Member

LazySets.binary_operations:Test Failed
  Expression: check_method_ambiguity_binary(is_intersection_empty)

@mforets
Copy link
Member Author

mforets commented Sep 17, 2018

i have no clue about the failing doctest in 0.7

witness::Bool=false
)::Union{Bool, Tuple{Bool, Vector{N}}} where {N<:Real}
return is_intersection_empty(point, set, witness)
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new line 😃

Copy link
Member Author

@mforets mforets Sep 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agghhh there is some obscure setting in my editor (atom) which removes the empty lines

@schillic
Copy link
Member

schillic commented Sep 17, 2018

i have no clue about the failing doctest in 0.7

You have to add the type parameter in interfaces.md:
isempty(::AbstractPolytope{N}) where {N<:Real}

Funny that it worked in one of the builds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants