/usr/share/polymake/demo/coordinates.ipynb is in polymake-common 3.2r2-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | {
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# Coordinates for Polyhedra\n",
"\n",
"\n",
"* This page explains how the coordinates for objects of type `Polytope<Coord> in application `polytope` work.\n",
"\n",
"Each polyhedron can be written as the Minkowski sum of a convex polytope (spanned by points *a,b,c,...*) and a cone (generated by the rays *r,s,t,...*). If the polyhedron is bounded, i.e. it is a polytope, then the cone is empty.\n",
"\n",
"Suppose our polyhedron lives in a *d*-space *V*.\n",
"\n",
"In order to obtain a unified view on the polytope and the cone section of a polyhedron, we embed V as an affine subspace of a (//d//+1)-space *W* such that the image of *V* contains the point *(1,0,0,...,0)* and it is parallel to the subspace spanned by the last *d* unit vectors.\n",
"\n",
"Points from both sections can now be identified with infinite rays through the origin in *W*. Facets are identified with the a hyperplane containing the image of the facet in *V* and the origin in *W*. This hyperplane is represented by a normal vector.\n",
"\n",
"Note that a facet defining hyperplane is not uniquely determined if the polyhedron is not full-dimensional. {{ tutorial:coord.gif?326|}}\n",
"\n",
"A vertex is incident with a facet if and only if the scalar product of their representatives in *W* is zero.\n",
"\n",
"\n",
"The polytope point *a=(ay,az)* is modelled as the infinite ray from the origin *(0,0,0)* through the point *(1,ay,az)*, i.e. the set of all non-negative multiples of *(1,ay,az)*. The cone point *r=(ry,rz)* becomes the ray through *(0,ry,rz)*.\n",
"\n",
"The facet containing the points *a* and *c* is represented by an (oriented) normal vector of the (hyper-)plane spanned by *a*, *c*, and the origin. If *d=2*, as in the picture, the normal vector can be computed as the cross product of *a* and *c*. The normal vector will be oriented such that it points towards the interior of the polyhedron.\n",
"\n",
"According to this model two points in *W* are identical to polymake if they differ by a positive multiple. In particular, for a polytope point in the input data it is not required that the first coordinate is *1*; it just has to be some positive number.\n",
"\n",
"Up to and including version 2.9.9 polymake was not able to handle unbounded polyhedra which contain an affine line. Starting from version 2.10 this is possible. Notice, however, that **by definition** the combinatorics (encoded as VERTICES_IN_FACETS) of an arbitrary polyhedron is the combinatorics of a polytope which is projectively equivalent to quotient of the orginal polyhedron modulo its lineality space.\n",
"\n",
"## An example\n",
"\n",
"The following defines the positive orthant in 3-space. It has only one vertex, the origin, and three rays pointing into the three coordinate directions. The distinction between these comes from our choice of the homogenizing coordinate.\n",
"\n",
" \n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"$p=new Polytope(POINTS=>[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]]);"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"\n",
"This lists the facet coordinates.\n",
"\n",
" \n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1 0 0 0\n",
"0 1 0 0\n",
"0 0 1 0\n",
"0 0 0 1\n",
"\n"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"print $p->FACETS;"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"Each line describes one linear inequality. The encoding is as follows: (a_0,a_1,...,a_d) is the inequality a_0 + a_1 x_1 + ... + a_d x_d >= 0. This way a point in (oriented) homogeneous coordinates satisfies an inequality if and only if the scalar product of the point with the inequality gives a non-negative value. (Use the command `print_constraints($m)` to display the inequalities of the matrix `$m` in a nice way.)\n",
"\n",
"Clearly, the polyhedron is unbounded.\n",
"\n",
" \n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0\n",
"\n"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"print $p->BOUNDED;"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"Yet, the combinatorial data describe a 3-simplex.\n",
"\n",
" \n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{1 2 3}\n",
"{0 2 3}\n",
"{0 1 3}\n",
"{0 1 2}\n",
"\n"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"print $p->VERTICES_IN_FACETS;"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"The rays span the *face at infinity*.\n",
"\n",
" \n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{1 2 3}\n",
"\n"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"print $p->FAR_FACE; "
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"By the way, unbounded polyhedra can be visualized just like bounded ones. `polymake` automatically chooses a bounding box.\n",
"\n",
" \n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"$p->VISUAL;"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"## Internal treatment of polytope generators\n",
"\n",
"As described above polyhedra in `polymake` are modelled as the intersection of a cone with the affine hyperplane defined by *x<sub>0</sub>=1*. Hence, infinitely many cones give rise to the same polytope. The algorithms in `polymake` usually work with the *homogenized cone* `homog(P)` of a polyhedron. Hence, `polymake` takes care about the correct canonicalization of user input of polytope generators in the following way:\n",
"\n",
" In order to construct `homog(P)`, the cone defining the polyhedron is intersected with the hyperplane *H<sub>0</sub>: x<sub>0</sub>=0*. The rays defining the bounded part (R<sub>b</sub>) and rays with *x<sub>0</sub>=0* (R<sub>0</sub>) are just inherited. To obtain the rest of the generators for the unbounded part, it is necessary to carry out a \"dual Fourier-Motzkin procedure\": Any two rays with different signs are linearly combined to a new ray that is contained in *H<sub>0</sub>*. All these rays together with the rays in R<sub>b</sub> and R<sub>0</sub> then define the *homogenized cone* `homog(P)`. \n",
"\n",
"Until version 2.9.9 input generators with a negative first coordinate are just multiplied by -1. \n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "polymake",
"language": "polymake",
"name": "polymake"
},
"language_info": {
"codemirror_mode": "perl",
"file_extension": ".pm",
"mimetype": "text/x-polymake",
"name": "polymake"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
|