<div dir="ltr">Hello,<div><br></div><div>For a project I am working on with a collaborator, I have the extreme points and the rays of a polyhedron. I have to obtain the facetious representation of this polyhedron. That is, I want a simple V to H conversion.</div><div><br></div><div>I have been working with polymake so far. My working code is:</div><div><br></div><div><div style="color:rgb(0,0,0);background-color:rgb(255,255,254);font-family:Consolas,"Liberation Mono",Courier,monospace,Consolas,"Courier New",monospace;font-size:14px;line-height:19px;white-space:pre-wrap"><div><span style="color:rgb(0,0,255)">#include</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">polymake/Main.h</span><span style="color:rgb(0,0,255)">></span></div><div><span style="color:rgb(0,0,255)">#include</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">polymake/Matrix.h</span><span style="color:rgb(0,0,255)">></span></div><div><span style="color:rgb(0,0,255)">#include</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">polymake/SparseMatrix.h</span><span style="color:rgb(0,0,255)">></span></div><div><span style="color:rgb(0,0,255)">#include</span> <span style="color:rgb(0,0,255)"><</span><span style="color:rgb(163,21,21)">polymake/Rational.h</span><span style="color:rgb(0,0,255)">></span></div><div><span style="color:rgb(0,0,255)">using</span> <span style="color:rgb(0,0,255)">namespace</span> polymake;</div><div><span style="color:rgb(0,0,255)">int</span> main(<span style="color:rgb(0,0,255)">int</span> argc, <span style="color:rgb(0,0,255)">const</span> <span style="color:rgb(0,0,255)">char</span>* argv[]) {</div><div>  <span style="color:rgb(0,0,255)">try</span> {</div><div>    Main pm;</div><div>    pm.set_application(<span style="color:rgb(163,21,21)">"polytope"</span>);</div><div>    BigObject p(<span style="color:rgb(163,21,21)">"Polytope<Rational>"</span>);</div><div>    std::vector<std::string> CoordinateLabels = { <span style="color:rgb(163,21,21)">"extravar"</span>, <span style="color:rgb(163,21,21)">"x1"</span>, <span style="color:rgb(163,21,21)">"x2"</span>, <span style="color:rgb(163,21,21)">"x3"</span>, <span style="color:rgb(163,21,21)">"x4"</span>, <span style="color:rgb(163,21,21)">"x5"</span>, <span style="color:rgb(163,21,21)">"x6"</span>};</div><div>    std::vector<std::vector<Int>> Points;</div><div>    std::vector<Int> point;</div><div>    point = { <span style="color:rgb(9,134,88)">1</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">1</span>,<span style="color:rgb(9,134,88)">1</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">1</span> }; Points.push_back(point);</div><div>    point = { <span style="color:rgb(9,134,88)">1</span>,<span style="color:rgb(9,134,88)">1</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">1</span>,<span style="color:rgb(9,134,88)">1</span>,<span style="color:rgb(9,134,88)">0</span> }; Points.push_back(point);</div><div>    point = { <span style="color:rgb(9,134,88)">1</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">1</span>,<span style="color:rgb(9,134,88)">1</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">1</span> }; Points.push_back(point);</div><div>    point = { <span style="color:rgb(9,134,88)">1</span>,<span style="color:rgb(9,134,88)">1</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">1</span>,<span style="color:rgb(9,134,88)">1</span>,<span style="color:rgb(9,134,88)">0</span> }; Points.push_back(point);</div><div>    point = { <span style="color:rgb(9,134,88)">1</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">1</span>,<span style="color:rgb(9,134,88)">1</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">1</span> }; Points.push_back(point);</div><div>    point = { <span style="color:rgb(9,134,88)">1</span>,<span style="color:rgb(9,134,88)">1</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">1</span>,<span style="color:rgb(9,134,88)">1</span>,<span style="color:rgb(9,134,88)">0</span> }; Points.push_back(point);</div><div>    point = { <span style="color:rgb(9,134,88)">1</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">1</span>,<span style="color:rgb(9,134,88)">1</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">1</span> }; Points.push_back(point);</div><div>    point = { <span style="color:rgb(9,134,88)">1</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">1</span>,<span style="color:rgb(9,134,88)">1</span>,<span style="color:rgb(9,134,88)">1</span> }; Points.push_back(point);</div><div>    point = { <span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">1</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span> }; Points.push_back(point);</div><div>    point = { <span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">1</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span> }; Points.push_back(point);</div><div>    point = { <span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">1</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span> }; Points.push_back(point);</div><div>    point = { <span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">1</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span> }; Points.push_back(point);</div><div>    point = { <span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">1</span>,<span style="color:rgb(9,134,88)">0</span> }; Points.push_back(point);</div><div>    point = { <span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">0</span>,<span style="color:rgb(9,134,88)">1</span> }; Points.push_back(point);</div><div>    p.take(<span style="color:rgb(163,21,21)">"VERTICES"</span>) << Points;</div><div>    <span style="color:rgb(0,0,255)">const</span> Matrix<Rational> f = p.give(<span style="color:rgb(163,21,21)">"FACETS"</span>);</div><div>    cout << <span style="color:rgb(163,21,21)">"facets"</span> << endl << f << endl;</div><div>    cout << <span style="color:rgb(163,21,21)">"Dimension of the facets matrix are "</span> << f.rows() << <span style="color:rgb(163,21,21)">" and "</span> << f.cols() << endl;</div><div>    cout << <span style="color:rgb(163,21,21)">"Printing the facets for easy reading"</span> << endl;</div><div>    <span style="color:rgb(0,0,255)">for</span> (<span style="color:rgb(0,0,255)">int</span> i = <span style="color:rgb(9,134,88)">0</span>; i < f.rows(); i++) {</div><div>      cout << <span style="color:rgb(163,21,21)">" Facet "</span> << i << <span style="color:rgb(163,21,21)">": "</span>;</div><div>      Rational rhs = f(i, <span style="color:rgb(9,134,88)">0</span>);</div><div>      <span style="color:rgb(0,0,255)">for</span> (<span style="color:rgb(0,0,255)">int</span> j = <span style="color:rgb(9,134,88)">1</span>; j < f.cols(); j++) {</div><div>        Rational coef = f(i, j);</div><div>        <span style="color:rgb(0,0,255)">if</span> (coef.is_zero() == <span style="color:rgb(0,0,255)">false</span>) {</div><div>          cout << <span style="color:rgb(163,21,21)">" + ("</span> << coef << <span style="color:rgb(163,21,21)">" "</span> << CoordinateLabels[j] << <span style="color:rgb(163,21,21)">") "</span>;</div><div>        }</div><div>      }</div><div>      cout << <span style="color:rgb(163,21,21)">" >= - ("</span> << rhs << <span style="color:rgb(163,21,21)">")"</span> << endl;</div><div>    }</div><div>    <span style="color:rgb(0,0,255)">const</span> Matrix<Rational> affine_hull = p.give(<span style="color:rgb(163,21,21)">"AFFINE_HULL"</span>);</div><div>    cout << <span style="color:rgb(163,21,21)">"affine hull"</span> << endl << affine_hull << endl;</div><div>    cout << <span style="color:rgb(163,21,21)">"Dimension of the affine hull matrix are "</span> << affine_hull.rows() << <span style="color:rgb(163,21,21)">" and "</span> << affine_hull.cols() << endl;</div><div>    cout << <span style="color:rgb(163,21,21)">"Printing the affine hull for easy reading"</span> << endl;</div><div>    <span style="color:rgb(0,0,255)">for</span> (<span style="color:rgb(0,0,255)">int</span> i = <span style="color:rgb(9,134,88)">0</span>; i < affine_hull.rows(); i++) {</div><div>      printf(<span style="color:rgb(163,21,21)">"AffineHull %d: "</span>, i);</div><div>      Rational rhs = affine_hull(i, <span style="color:rgb(9,134,88)">0</span>);</div><div>      <span style="color:rgb(0,0,255)">for</span> (<span style="color:rgb(0,0,255)">int</span> j = <span style="color:rgb(9,134,88)">1</span>; j < affine_hull.cols(); j++) {</div><div>        Rational coef = affine_hull(i, j);</div><div>        <span style="color:rgb(0,0,255)">if</span> (coef.is_zero() == <span style="color:rgb(0,0,255)">false</span>) {</div><div>          cout << <span style="color:rgb(163,21,21)">" + ("</span> << coef << <span style="color:rgb(163,21,21)">" "</span> << CoordinateLabels[j] << <span style="color:rgb(163,21,21)">") "</span>;</div><div>        }</div><div>      }</div><div>      cout << <span style="color:rgb(163,21,21)">" = - ("</span> << rhs << <span style="color:rgb(163,21,21)">")"</span> << endl;</div><div>    }</div><div>  }</div><div>  <span style="color:rgb(0,0,255)">catch</span> (<span style="color:rgb(0,0,255)">const</span> std::exception& ex) {</div><div>    std::cerr << <span style="color:rgb(163,21,21)">"ERROR: "</span> << ex.what() << endl; <span style="color:rgb(0,0,255)">return</span> <span style="color:rgb(9,134,88)">1</span>;</div><div>  }</div><div>  <span style="color:rgb(0,0,255)">return</span> <span style="color:rgb(9,134,88)">0</span>;</div><div>}</div><div><br></div><div>The code can also be seen on godbolt at : <a href="https://godbolt.org/z/Ko7zq4z64" target="_blank">https://godbolt.org/z/Ko7zq4z64</a></div><div><br></div><div>The output of the above program is:</div><div><br></div><div>polymake: used package ppl<br>  The Parma Polyhedra Library ([[wiki:external_software#PPL]]): A C++ library for convex polyhedra<br>  and other numerical abstractions.<br>  <a href="http://www.cs.unipr.it/ppl/">http://www.cs.unipr.it/ppl/</a><br><br>facets<br>-1 0 0 1 0 1 0<br>0 0 0 1 0 0 0<br>0 0 1 0 0 0 0<br>-1 0 1 0 1 0 0<br>-1 0 0 1 1 0 0<br>0 0 0 0 1 0 0<br>0 0 0 0 0 1 0<br>0 1 0 0 0 0 0<br>-1 1 0 0 0 0 1<br>0 0 0 0 0 0 1<br>-1 0 0 0 1 0 1<br>-1 0 0 0 0 1 1<br>1 0 0 0 0 0 0<br><br>Dimension of the facets matrix are 13 and 7<br>Printing the facets for easy reading<br> Facet 0:  + (1 x3)  + (1 x5)  >= - (-1)<br> Facet 1:  + (1 x3)  >= - (0)<br> Facet 2:  + (1 x2)  >= - (0)<br> Facet 3:  + (1 x2)  + (1 x4)  >= - (-1)<br> Facet 4:  + (1 x3)  + (1 x4)  >= - (-1)<br> Facet 5:  + (1 x4)  >= - (0)<br> Facet 6:  + (1 x5)  >= - (0)<br> Facet 7:  + (1 x1)  >= - (0)<br> Facet 8:  + (1 x1)  + (1 x6)  >= - (-1)<br> Facet 9:  + (1 x6)  >= - (0)<br> Facet 10:  + (1 x4)  + (1 x6)  >= - (-1)<br> Facet 11:  + (1 x5)  + (1 x6)  >= - (-1)<br> Facet 12:  >= - (1)<br>affine hull<br><br>Dimension of the affine hull matrix are 0 and 7<br>Printing the affine hull for easy reading</div>
</div></div><div style="color:rgb(0,0,0);background-color:rgb(255,255,254);font-family:Consolas,"Liberation Mono",Courier,monospace,Consolas,"Courier New",monospace;font-size:14px;line-height:19px;white-space:pre-wrap">I have two queries:</div><div style="color:rgb(0,0,0);background-color:rgb(255,255,254);font-family:Consolas,"Liberation Mono",Courier,monospace,Consolas,"Courier New",monospace;font-size:14px;line-height:19px;white-space:pre-wrap"><br></div><div style="color:rgb(0,0,0);background-color:rgb(255,255,254);font-family:Consolas,"Liberation Mono",Courier,monospace,Consolas,"Courier New",monospace;font-size:14px;line-height:19px;white-space:pre-wrap">(1) Is there a simple example that shows how the equivalent of the above functionality can be obtained in PPL via C/C+ code? I have looked at the PPL user manual, but I have to admit that it is quite forbidding in its size and details and it is not fully clear where in the document complete C/C++ examples are. I admit that this is possibly my lack of delving too deep into the manual.</div><div style="color:rgb(0,0,0);background-color:rgb(255,255,254);font-family:Consolas,"Liberation Mono",Courier,monospace,Consolas,"Courier New",monospace;font-size:14px;line-height:19px;white-space:pre-wrap"><br></div><div style="color:rgb(0,0,0);background-color:rgb(255,255,254);font-family:Consolas,"Liberation Mono",Courier,monospace,Consolas,"Courier New",monospace;font-size:14px;line-height:19px;white-space:pre-wrap">I also notice that Polymake has solved this problem by calling PPL behind the scenes.<br></div><div style="color:rgb(0,0,0);background-color:rgb(255,255,254);font-family:Consolas,"Liberation Mono",Courier,monospace,Consolas,"Courier New",monospace;font-size:14px;line-height:19px;white-space:pre-wrap"><br></div><div style="color:rgb(0,0,0);background-color:rgb(255,255,254);font-family:Consolas,"Liberation Mono",Courier,monospace,Consolas,"Courier New",monospace;font-size:14px;line-height:19px;white-space:pre-wrap">(2) Can the PPL code I write on Linux/WSL be used on a Windows Machine as well? I ask this because this is not a possibility in Polymake. Indeed, I was guided towards PPL as a result of my query on the Polymake forum. Polymake code cannot run on a Windows machine. I was wondering if PPL has this capability as suggested there. Please see that discussion at:</div><div style="color:rgb(0,0,0);background-color:rgb(255,255,254);font-family:Consolas,"Liberation Mono",Courier,monospace,Consolas,"Courier New",monospace;font-size:14px;line-height:19px;white-space:pre-wrap"><br></div><div style="color:rgb(0,0,0);background-color:rgb(255,255,254);font-family:Consolas,"Liberation Mono",Courier,monospace,Consolas,"Courier New",monospace;font-size:14px;line-height:19px;white-space:pre-wrap"><a href="https://forum.polymake.org/viewtopic.php?f=8&p=3919" target="_blank">https://forum.polymake.org/viewtopic.php?f=8&p=3919</a><br></div><div style="color:rgb(0,0,0);background-color:rgb(255,255,254);font-family:Consolas,"Liberation Mono",Courier,monospace,Consolas,"Courier New",monospace;font-size:14px;line-height:19px;white-space:pre-wrap"><br></div><div>Thanks.</div><div>Tryer</div></div>