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

Vertices_list for HPolytope #189

Merged
merged 9 commits into from
Jan 26, 2018
Merged
Changes from 1 commit
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
38 changes: 32 additions & 6 deletions src/HPolytope.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ using MathProgBase, GLPKMathProgInterface
export HPolytope,
addconstraint!,
constraints_list,
tosimplehrep,
cartesian_product
tosimplehrep

"""
HPolytope{N<:Real} <: AbstractPolytope{N}
Expand Down Expand Up @@ -202,14 +201,15 @@ end
@require Polyhedra begin

using CDDLib # default backend
import Polyhedra:polyhedron, SimpleHRepresentation, HRep,
removehredundancy!,
hreps,
import Polyhedra:polyhedron, SimpleHRepresentation, SimpleHRepresentation,
HRep, VRep,
removehredundancy!, removevredundancy!,
hreps, vreps,
intersect,
convexhull,
hcartesianproduct

export intersect, convex_hull
export intersect, convex_hull, cartesian_product, vertices_list

# HPolytope from an HRep
function HPolytope(P::HRep{N, T}, backend=CDDLib.CDDLibrary()) where {N, T}
Expand Down Expand Up @@ -313,4 +313,30 @@ function cartesian_product(P1::HPolytope, P2::HPolytope; backend=CDDLib.CDDLibra
return HPolytope(Pcp)
end

"""
vertices_list(P::HPolytope{N})::Vector{Vector{N}} where {N<:Real}
Copy link
Member

Choose a reason for hiding this comment

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

arguments missing (put in brackets)


Return the list of vertices of a polytope in constraint representation.

### Input

- `P` -- polytope in constraint representation
- `backend` -- (optional, default: `CDDLib.CDDLibrary()`) the polyhedral
computations backend, see Polyhedra's documentation
for further information
- `prunefunc` -- (optional, default: `removevredundancy!`) function to post-process
the output of `vreps`

### Output

List of vertices.
"""
function vertices_list(P::HPolytope{N};
backend=CDDLib.CDDLibrary(),
prunefunc=removevredundancy!)::Vector{Vector{N}} where {N<:Real}
P = polyhedron(P, backend)
prunefunc(P)
return [vi for vi in vreps(P)]
end

end