Navigation

In this module, a polyhedron is a convex (possibly unbounded) set in
Euclidean space cut out by a finite set of linear inequalities and
linear equations. Note that the dimension of the polyhedron can be
less than the dimension of the ambient space. There are two
complementary representations of the same data:

H(alf-space/Hyperplane)-representation

This describes a polyhedron as the common solution set of a
finite number of

linear inequalities\(A \vec{x} + b \geq 0\), and

linear equations\(C \vec{x} + d = 0\).

V(ertex)-representation

The other representation is as the convex hull of vertices (and
rays and lines to all for unbounded polyhedra) as generators. The
polyhedron is then the Minkowski sum

vertices\(v_1\), \(\dots\), \(v_k\) are a finite number of
points. Each vertex is specified by an arbitrary vector, and two
points are equal if and only if the vector is the same.

rays\(r_1\), \(\dots\), \(r_m\) are a finite number of directions
(directions of infinity). Each ray is specified by a non-zero
vector, and two rays are equal if and only if the vectors are
the same up to rescaling with a positive constant.

lines\(\ell_1\), \(\dots\), \(\ell_n\) are a finite number of
unoriented directions. In other words, a line is equivalent to
the set \(\{r, -r\}\) for a ray \(r\). Each line is specified by a
non-zero vector, and two lines are equivalent if and only if the
vectors are the same up to rescaling with a non-zero (possibly
negative) constant.

When specifying a polyhedron, you can input a non-minimal set of
inequalities/equations or generating vertices/rays/lines. The
non-minimal generators are usually called points, non-extremal rays,
and non-extremal lines, but for our purposes it is more convenient to
always talk about vertices/rays/lines. Sage will remove any
superfluous representation objects and always return a minimal
representation. For example, \((0,0)\) is a superfluous vertex here:

A polytope is defined as a bounded polyhedron. In this case, the
minimal representation is unique and a vertex of the minimal
representation is equivalent to a 0-dimensional face of the
polytope. This is why one generally does not distinguish vertices and
0-dimensional faces. But for non-bounded polyhedra we have to allow
for a more general notion of “vertex” in order to make sense of the
Minkowsi sum presentation:

Note how we need a point in the above example to anchor the ray and
line. But any point on the boundary of the half-plane would serve the
purpose just as well. Sage picked the origin here, but this choice is
not unique. Similarly, the choice of ray is arbitrary but necessary to
generate the half-plane.

Finally, note that while rays and lines generate unbounded edges of
the polyhedron they are not in a one-to-one correspondence with
them. For example, the infinite strip has two infinite edges (1-faces)
but only one generating line:

The base ring of the polyhedron can be specified by the base_ring
optional keyword argument. If not specified, a suitable common base
ring for all coordinates/coefficients will be chosen
automatically. Important cases are:

base_ring=QQ uses a fast implementation for exact rational
numbers.

base_ring=ZZ is similar to QQ, but the resulting polyhedron
object will have extra methods for lattice polyhedra.

base_ring=RDF uses floating point numbers, this is fast but
susceptible to numerical errors.

Polyhedra with symmetries often are defined over some algebraic field
extension of the rationals. As a simple example, consider the
equilateral triangle whose vertex coordinates involve \(\sqrt{3}\). An
exact way to work with roots in Sage is the AlgebraicRealField

You may either define it with vertex/ray/line or
inequalities/equations data, but not both. Redundant data will
automatically be removed (unless minimize=False), and the
complementary representation will be computed.

INPUT:

vertices – list of point. Each point can be specified as
any iterable container of base_ring elements. If rays or
lines are specified but no vertices, the origin is
taken to be the single vertex.

rays – list of rays. Each ray can be specified as any
iterable container of base_ring elements.

lines – list of lines. Each line can be specified as any
iterable container of base_ring elements.

ieqs – list of inequalities. Each line can be specified as any
iterable container of base_ring elements. An entry equal to
[-1,7,3,4] represents the inequality \(7x_1+3x_2+4x_3\geq 1\).

eqns – list of equalities. Each line can be specified as
any iterable container of base_ring elements. An entry equal to
[-1,7,3,4] represents the equality \(7x_1+3x_2+4x_3= 1\).

base_ring – a sub-field of the reals implemented in
Sage. The field over which the polyhedron will be defined. For
QQ and algebraic extensions, exact arithmetic will be
used. For RDF, floating point numbers will be used. Floating
point arithmetic is faster but might give the wrong result for
degenerate input.

ambient_dim – integer. The ambient space dimension. Usually
can be figured out automatically from the H/Vrepresentation
dimensions.

backend – string or None (default). The backend to use. Valid choices are

'cdd': use cdd
(backend_cdd) with \(\QQ\) or
\(\RDF\) coefficients depending on base_ring.

'ppl': use ppl
(backend_ppl) with \(\ZZ\) or
\(\QQ\) coefficients depending on base_ring.