Polymake Mini-Reference

Created especially for The minicourse "Actually Doing It!: A Hands-On Approach to Computational Polyhedral Geometry".

Starting POLYMAKE

Starting with version 2.9, from the Linux prompt, type polymake and press Enter. You should see
polytope >
and then you're in the polymake system. To exit, type "exit;" (without the quotes, but don't forget the semi-colon).

Construct new polytope by points

To construct a new polytope $p as the convex hull of some points
polytope > $p=new Polytope;

polytope > $p->POINTS=<<".";
polytope (2)> 1 0 0 0
polytope (3)> 1 2 0 0
polytope (4)> 1 8 1 0
polytope (5)> 1 1 1 0
polytope (6)> 1 0 -1 1
polytope (7)> .
NOTE: the "1" in front is a part of polymake's internal representation that we promise to explain later. The polytope defined by inputting the above is the convex hull of the points (0,0,0), (2,0,0), (8,1,0), (1,1,0), and (0,-1,1).

Construct new polytope by equations and inequalities

Here is a quick explanation of the order in which you must enter the coefficients of your normal vector and the constant term. Note, the constant term goes in front:
$p=new Polytope;

$p->INEQUALITIES=<<".";
0 1 0 0 0 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0 0 0 0
0 0 0 1 0 0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0 0 0
0 0 0 0 0 0 1 0 0 0 0 0 0
0 0 0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 0 0 0 0 0 1
.

$p->EQUATIONS=<<".";
-4 1 0 0 1 0 0 1 0 0 1 0 0
-4 0 1 0 0 1 0 0 1 0 0 1 0
-4 0 0 1 0 0 1 0 0 1 0 0 1
-3 1 1 1 0 0 0 0 0 0 0 0 0
.

Example of a for-loop

for ($i=0; $i<50; $i++) { print rand_sphere(4,10)->N_FACETS; }

Affine hull

Gives a minimal list of equalities satisfied by all points in the polytope.
print $p->AFFINE_HULL;
See also FACETS.

Ambient Dimension

To see the ambient (description) dimension of polytope $p,
print $p->AMBIENT_DIM;
See also
Dimension.

Birkhoff polytope

To construct the n by n Birkhoff polytope, run birkhoff(n). For example, the 4 by 4 Birkhoff polytope is assigned to the variable $p by
$p = birkhoff(4);

Bounded

Test to see if a polyhedron is bounded (i.e., is a polytope). An output of 1 means the polyhedron is bounded. An output of 0 means it is an unbounded polyhedron.
print $p->BOUNDED;

Cube

Constructs a d-dimensional cube. For example, the 3-cube:
$c=cube(3);

Cross Polytope

Constructs a d-dimensional cross polytope (this is dual to the d-cube). For example,
$p=cross(3);

Cyclic polytopes

For n > d ≥ 2, cyclic(d,n) constructs a d-dimensional cyclic polytope with n vertices. See example:
$p=cyclic(3,6);

Diameter

Graph theoretical diameter of GRAPH. The minimal number which guarantees that between any two vertices x and y, there is a path from x to y using no more than this many edges.
print $p->DIAMETER;

Dimension

print $p->DIM;
See also
Ambient Dimension.

Exit

To quit the program polymake, type
exit;

Facets

Print a list of the facets. This is one part of the H-representation. See also FACETS.
print $p->FACETS;

f-vector

print $p->F_VECTOR;

Hypersimplex

For n > d ≥ 2, constructs a hypersimplex:
$p=hypersimplex(d,n);

Intersection

To assign $c as the intersection of two polytopes $a and $b that have been previously defined, run
$c = intersection($a,$b);

Lattice points

To see the number of lattice points, run
print $p->N_LATTICE_POINTS;

To see the coordinates of the lattice points of polytope $p, run
print $p->LATTICE_POINTS;

Minkowski Sum

To build the Minkowski sum of polytopes $a and $b, and store the result as $c, run
$c = minkowski_sum($a,$b);

Number of facets

print $p->N_FACETS;

Number of vertices

print $p->N_VERTICES;
To see the actual vertices, see
VERTICES.

Permutahedron

Constructs a d-dimensional permutahedron. For example,
$p=permutahedron(3);

Polarization

To construct the dual of a polytope $r, first center it, then run polarize:
$thedual = polarize(center($r));

Random 0/1 polytope

To construct a random d-dimensional 0/1 polytope (the coordinates of all vertices are 0 or 1) with n vertices, run
$r=rand_sphere(d,n);
NOTE: n > d required!

Random polytope

To construct a random 3-dimensional polytope as the convex hull of 10 random points on a sphere, run
$r=rand_sphere(3,10);

Simplex

Constructs a d-dimensional simplex. For example,
$p=simplex(3);

Simple

Test to see if a polytope is simple (every vertex is contained in dimension-many facets). An output of 1 means the polytope is simple. An output of 0 means it is not simple.
print $p->SIMPLE;

Simplicial

Test to see if a polytope is simplicial (every facet is a simplex of one dimension lower). An output of 1 means the polytope is simplicial. An output of 0 means it is not simplicial.
print $p->SIMPLICIAL;

Vertices

Print a list of the vertices.
print $p->VERTICES;

Vertices in Facets

For each facet in the polytope, print a list of which vertices belong to that facet. The rows correspond to the facets (one facet per row). The numbers present in each space-separated list give the number identifying which vertex.)
print $p->VERTICES_IN_FACETS;

Visualization

Provides a picture of a 3-dimensional polytope and a Schlegel diagram for a 4-dimensional polytope.
$p->VISUAL;

To see the lattice points colored in, type
$p->VISUAL->LATTICE_COLORED;

Visualize Graph

Provides a picture of the graph of a polytope.
$p->VISUAL_GRAPH;

Visualize Face Lattice

Gives picture of the Hasse diagram of the face poset.
$p->VISUAL_FACE_LATTICE;

Volume

For a full-dimensional polytope, computes the volume.
$p->VOLUME;

For more help, see
Polymake's web page or the Polymake wiki.