Report on polymake
Heidi Pang
ETH Zurich, Department of Mathematics
December 2, 2014
Abstract
This paper is intended to summarize and wrap up the oral presentation held
by Sonja Meier and me on November 4th, 2014 at ETH Zurich for the seminar
on combinatorics led by Prof. Komei Fukuda. Its main purpose is to present the
software polymake, as well as the mathematical background needed to study convex
polytopes and polyhedra in Rd .
1
Polytopes
Before starting to explore polymake, we need to properly define the mathematical objects
considered.
Definition 1.1 [2, p. 13] Let A ∈ Rm×d and b ∈ Rm , then a convex polyhedron P ⊂ Rd
corresponding to the pair (A, b) is defined as
P := {x ∈ Rd : Ax ≤ b}.
We call P a convex polytope if P is bounded.
A very important property about polyhedron is expressed in the following theorem,
namely that each polyhedron can be represented in two different ways.
Theorem 1.2 (Minkowski-Weyl) [2, Thm. 3.10] The following statements are equivalent:
(i) P ⊂ Rd is a polyhedron in the sense of Def. 1.1
(ii) P can be written as a Minkowski sum, i.e.
P, {rj }lj=1 ⊂ Rd , such that
there exist finite sets {vi }ki=1 ⊂
P = conv({v1 , . . . , vk }) + cone({r1 , . . . , rl }),
where conv denotes the convex hull, i.e.
conv({v1 , . . . , vk }) := {x : x =
k
X
i=1
1
ai vi , kak1 = 1, a ≥ 0}
(1)
and cone denotes the nonnegative hull, i.e.
cone({r1 , . . . , rl }) := {x : x =
l
X
λj rj , λj ≥ 0}.
j=1
Above theorem (Minkowski-Weyl) motivates the definition of V- and H-representations.
Definition 1.3 Let P ⊂ Rd be a polyhedron.
• If P is given by a tuple (A, b), where A ∈ Rm×n , b ∈ Rm as in Def. 1.1, then (A, b)
is called the H-representation (half-space representation) of P .
• If P is given by a Minkowski sum as in (1), then (1) is called the V-representation
(vertex representation) of P .
2
Homogeneous Coordinates
Homogeneous coordinates were first introduced by August Ferdinand Möbius in 1827. The
motivation was to be able to represent different points at infinity. Also, various formulas
can be simplified when using homogeneous coordinates instead of Cartesian coordinates.
Since homogeneous coordinates can be used to describe points at infinity, they require
one more coordinate than the dimension of the projective space that is being considered.
For easier understanding, we will only describe the construction of homogeneous
coordinates in R2 as in [4].
(i): Let x = (x1 , x2 ) ∈ R2 be a point in the Euclidean plane. For Z ∈ R \ {0},
(Z, x1 Z, x2 Z) is defined as the set of homogeneous coordinates of x.
Note that from this definition, it follows that the homogeneous coordinates of a
point are not unique. Moreover, two points are identical ⇔ their homogeneous coordinates differ by a multiple.
However, the homogeneous coordinates of the origin are uniquely specified by (1, 0, 0).
(ii): In order to describe the points at infinity, let us consider the equation of a line
through the origin (0, 0):
r1 x + r2 y = 0 for (r1 , r2 ) ∈ R2 \ {0, 0}.
(2)
(
x = r2 t
The parametric form of (2) is given by
y = r1 t.
1
1
Using the substitution Z := t ⇔ t = Z , we obtain the Euclidian coordinates of a
point on the line to be given as
r2 −r1
P =
,
.
Z Z
2
Following (i), the homogeneous coordinates of P are given by (Z, r2 , −r1 ) .
Taking the limit t → ∞ ⇔ Z → 0 (i.e. we follow along the line given by (2) from
point P to a point P∞ in infinity), the homogeneous coordinates of P∞ are defined
as (0, r2 , −r1 ).
The leading 0 is helpful to distinguish between points in Rd and points at infinity.
Note that we can do this construction analogously in Rd for d > 2, where the homogeneous coordinates will be given (d + 1)-tuples.
For the implementation in polymake, it should also be taken care of the fact that only
non-negative values for Z are allowed. This is however not a real restriction, as we can
still represent every point.
3
General Overview of polymake
The polymake software was developed 1996 by Ewgenij Gawrilow & Michael Joswig from
TU Berlin.
The main and original purpose is to study convex polyhedra geometrically and algorithmically, but over the years, polymake has grown and more features have been added.
It can now be used to describe graphs, simplicial complexes, matroids, tropicals and many
other objects and also serves as a programmable calculator via the GMP interface. [3]
Unlike most software tools, polymake does not have a proprietary language, but is
programed in perl & C++. The interactive shell executes commands written in a slight
extension of perl. [3]
3.1
Structure of polymake
polymake is basically a large collection of different interfaces, partially self-implemented
but mostly implemented by third party research groups.
A schematic overview is shown in Fig. 1. In the following subsubsections, which are
mainly based on [1] and [3], we will take a closer look at how polymake works.
3.1.1
Input
The input for polymake is a description of a polyhedron. polymake can work with Vand H-representations, but also provides various tools (so-called generators) to quickly
produce different polyhedra, such as rand sphere, n gon, cube. Generators are not only
useful to quickly construct new polytopes, they also automatically store information about
the polyhedra generated. This knowledge is taken advantage of when the user inquires
information about the polyhedra, so that e.g. the number of facets does not have to be
recalculated, but can just be read and outputted from the information file.
3.1.2
Computation and Output
The input is read into the polymake server. This server consists of engine and rule base.
• The rule base practically contains all mathematical and computational knowledge
of polymake. There are three different types of rules:
– Simple rules typically consist of very few lines of code. These are written in
Perl. An easy example for a simple rule is a function to count the length of a
given coordinate vector.
3
Figure 1: Schematic overview of polymake’s structure, [1].
– Client rules are written in C++. They are slightly more difficult than simple
rules, but still manage to compute all information needed inside polymake.
– Interface rules are the most complex rules. Their main task is to pick and call
the correct external program to answer the user’s question about a polytope.
Therefore, the interface rule first converts the input data given in polymake
format into a valid input for the chosen interfaced program. Then, the thirdparty software or package is called. Finally, the output of the interfaced program needs to be converted back into polymake format.
As an example: If the user requests to visualize a polytope, polymake server
calls an additional program such as geomview, graphlet or jreality to process the visualization (as shown in the upper part of Fig. 1).
• The engine is written in perl. It reads what the rule base has computed and outputs
the result for the user.
The strength of polymake is not that it can compute complex tasks on its own, but that it
can assign the right program out of a collection of many interfaced programs to compute
complex tasks.
3.1.3
Applications
When working in polymake, we are always situated in a special type of environment
called application. Each of the eight applications contains a main object type and various
tools such as functions or properties to describe this object. The eight applications of
polymake are polytope - which is the default and most extensive application, common,
graph, matroid, topaz, tropical, fan and group.
4
Figure 2: Icosahedron generated using generators and clients
It is possible to use the functions of one application in another application, therefore
it is not necessary to always switch between applications. But if the user mainly works
with e.g. matroids, he or she may switch to the application matroid in the beginning of
his work session.
4
Implementations in polymake
After installing polymake, the program can be run straight from the terminal by typing
polymake.
4.1
Producing Polytopes
Polytopes can be produced in two ways:
• by typing in V- or H-representations
• generated using already exiting polytopes, such as pyramid, n gon or rand sphere.
Those polytopes can then be manipulated using commands such as translate,
transform.
Example 4.1 Let us look at a polymake code, which constructs an icosahedron with
edges of length 1 as in [3].
1:
2:
3:
4:
$pentagon=n gon(5,1/10*sqrt(50+10*sqrt(5)));
$bottom=pyramid($pentagon,-1/10*sqrt(50-10*sqrt(5)));
$top=pyramid($pentagon,1/10*sqrt(50-10*sqrt(5)));
$translated bottom=translate($bottom,newVector<Rational>
(0,0,-1/4*sqrt(10+2*sqrt(5))+1/10*sqrt(50-10*sqrt(5))));
5:
$translated top=translate($top,newVector<Rational>
(0,0,1/4*sqrt(10+2*sqrt(5))-1/10*sqrt(50-10*sqrt(5))));
6:
$pi=Math::Trig::pi;
7:
$m=new Matrix<Rational>([[1,0,0,0],
5
Figure 3: polymake’s visualization of the positive orthant of R3
[0,cos($pi/5),-sin($pi/5),0],[0,sin($pi/5),cos($pi/5),0],[0,0,0,1]]);
8:
$rotated top=transform($translated top, $m);
9:
$icosahedron=conv($translated bottom,$rotated top);
10: $icosahedron->VISUAL;
The idea is as follows: We first generate a pentagon using n gon (line 1). The first
argument of n gon is the number of vertices, the second argument is the radius of the
circumscribed circle. Using this pentagon, we can produce the bottom (line 2, with
negative height) and top (line 3, with positive height) of the icosahedron using the client
pyramid. Now both pyramids share the same base. To create the side facets for the
icosahedron, we translate top and bottom pyramid using the client translate (lines 4
and 5). The first argument of translate is the polytope which we want to translate,
the second argument is a vector which gives the direction and length of the translation.
Finally, we need to rotate one of the pyramids (here: the top pyramid) by an angle of
π/5 using a rotation matrix and the client transform (lines 6, 7 and 8). The icosahedron
is now the convex hull of the two pyramids we constructed (line 9). It can be visualized
using the command VISUAL (line 10), see Fig. 2.
4.2
Visualization
Visualizations in polymake are not restricted to simple polytopes. We can also visualize
more abstract polyhedra, as is described in [3].
Example 4.2 We can describe and visualize the positive orthant of R3 as an unbounded
polyhedron in polymake.
1:
2:
$p=new Polytope(POINTS=>[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]]);
$p->VISUAL;
We first define the 3-dimensional polyhedron by homogeneous vertices (line 1). The
first coordinate (1,0,0,0) represents the origin. The other coordinates represent the infinite
rays along the three coordinate axes. Then, we visualize the positive orthant (line 2), see
6
Fig. 3. If we visualize unbounded polyhedra, polymake automatically chooses a bounding
box (red facets).
After having defined a polytope or polyhedron, we can start exploring it. Using the
Boolean function BOUNDED, we can e.g. check whether a given polytope is bounded.
Obviously, in this case print $p->BOUNDED; will output 0 (false).
4.3
Polymake as Programmable Calculator
As mentioned before, we can take advantage of the C++ packages such as GMP and use
polymake as a programmable calculator.
Example 4.3 As an easy example, we will calculate 100! [3]
1:
2:
3:
4:
$f=new Integer(1);
$i=new Integer(100);
for (; $i>0; --$i) $f*=$i;
print $f;
Above code correctly calculates and outputs
100! = 933262154439441526816992388562667004907159682643816214685929
638952175999932299156089414639761565182862536979208272237582
51185210916864000000000000000000000000.
References
[1] Michael Joswig Ewgenij Gawrilow. polymake: a framework for analyzing convex
polytopes. In Gil Kalai and Günter M. Ziegler, editors, Polytopes — Combinatorics
and Computation, pages 43–74. Birkhäuser, 2000.
[2] Komei Fukuda. Lecture: Polyhedral Computation, Spring 2014. 2014.
[3] Polymake. Polymake — Official website, 2014. [Online; accessed Dec. 1, 2014].
[4] Wikipedia. Homogeneous coordinates — Wikipedia, the free encyclopedia, 2004. [Online; accessed Nov. 30, 2014].
7
© Copyright 2026 Paperzz