问题
I'm trying to use the Parma Polyhedra Library [1] to enumerate the vertices of a (convex) polytope, e.g., I have a rectangle specified by four constraints:
Constraint_System cs;
cs.insert(x >= 0);
cs.insert(x <= 3);
cs.insert(y >= 0);
cs.insert(y <= 3);
C_Polyhedron ph(cs);
How do I generate the vertices?
回答1:
Each shape in PPL has dual representations: 1) Constraint_System, 2) Generator_System. For a convex-polyhedra, the generator system will contain the set of generators which can either be 1) Point, 2) Line, 3) Rays. For the convex polytope, the set of generators would be all points. you can get the generator representation as follows:
Generator_System gs = ph.generators(); // Use ph.minimized_generators() to minimal set of points for the polytope
for(Generator_System::const_iterator it = gs.begin(); it != gs.end(); it++) {
const Generator& g = *it;
assert(g.is_point()); // Assertions will fail for unbounded polyhedra
std::cout << g;
}
来源:https://stackoverflow.com/questions/30018766/parma-polyhedra-library-vertex-enumeration