Example of CDDLib usage: H-representation and V-representation

Hello,

I’m trying to use CDDLib but I’m lost.

Given a set of inequalities represented as a matrix and a vector, how to get the H-representation of the corresponding polyhedron? Then, how to get its V-representation, and vice-versa?

I looked at the tests and the issues but to no avail.

Ah I have a working example:

using Polyhedra
A = [-1//1 0//1; 0//1 -1//1; 1//1 1//1]
b = [1//1; -1//1; 5//1]
h = hrep(A, b)
p = polyhedron(h)
points(p)

The V-representation: p.vrep.

We can retrieve it as follows:

pts = collect(points(p))
lns = collect(lines(p))
rys = collect(rays(p))
vrep(pts, lns, rys)

Still investigating…

Now I’ve found how to go from the V-rep to the H-rep:

V = vrep(pts, lns, rys)
P2 = polyhedron(V)
H2 = hrep(P2).halfspaces
A = map(x -> x.a, H2)
b = map(x -> x.β, H2)

To use CCDLib, it suffices to do polyhedron(V, CDDLib.Library(:exact)).