1 \section{\texorpdfstring{Usage of the
\protect\ai[\tt]{barvinok
} library
}
2 {Usage of the barvinok library
}}
5 \index{barvinok@
{\tt barvinok
}!availability
}
7 This section describes some application programs
8 provided by the
\barvinok/ library,
9 available from
{\tt http://freshmeat.net/projects/barvinok/.
}
10 For compilation instructions we refer to the
\verb+README+ file
11 included in the distribution.
14 Common option to all programs:\\
16 \ai[\tt]{--version
} &
\ai[\tt]{-V
} & print version
19 \subsection{\texorpdfstring{\protect\ai[\tt]{barvinok
\_count}}{barvinok
\_count}}
21 The program
\ai[\tt]{barvinok
\_count} enumerates a
22 non-parametric polytope. It takes one polytope
23 in
\PolyLib/ notation as input and prints the number
24 of integer points in the polytope.
25 The
\PolyLib/ notation corresponds to the internal
26 representation of
\ai[\tt]{Polyhedron
}s as explained
27 in Section~
\ref{a:existing
}.
28 \index{input format!constraints
}
29 The first line of the input contains the number of rows
30 and the number of columns in the
\ai[\tt]{Constraint
} matrix.
31 The rest of the input is composed of the elements of the matrix.
32 Recall that the number of columns is two more than the number
33 of variables, where the extra first columns is one or zero
34 depending on whether the constraint is an inequality ($
\ge 0$)
35 or an equality ($=
0$). The next columns contain
36 the coefficients of the variables and the final column contains
37 the constant in the constraint.
39 $S =
\lb\, s
\mid s
\geq 0 \wedge 2 s
\leq 13 \,
\rb$
40 from
\citeN[Example~
38 on page~
134]{Verdoolaege2005PhD
}
41 corresponds to the following input and
49 > ./barvinok_count < S
50 POLYHEDRON Dimension:
1
51 Constraints:
2 Equations:
0 Rays:
2 Lines:
0
60 \index{PolyLib@
{\tt PolyLib
}!version
5.22.0 or newer
}
61 Note that if you use
\PolyLib/ version
5.22.0 or newer then the output
62 may look slightly different as the computation of the
\ai[\tt]{Rays
}
63 may have been postponed to a later stage.
64 The program
\ai[\tt]{latte2polylib.pl
} can be used to
65 convert a polytope from
\ai[\tt]{LattE
} \shortcite{latte1.1
}
66 notation to
\PolyLib/ notation.
68 \index{input format!vertices
}
69 As an alternative to the constraints based input, the input polytope
70 may also be specified by its
\ai[\tt]{Ray
} matrix.
71 The first line of the input contains the single word
\ai[\tt]{vertices
}.
72 The second line contains the number of rows
73 and the number of columns in the
\ai[\tt]{Ray
} matrix.
74 The rest of the input is composed of the elements of the matrix.
75 Recall that the number of columns is two more than the number
76 of variables, where the extra first columns is one or zero
77 depending on whether the ray is a line or not.
78 The next columns contain
79 the numerators of the coordinates and the final column contains
80 the denominator of the vertex or $
0$ for a ray.
81 E.g., the above set can also be described as
91 \subsection{\texorpdfstring{\protect\ai[\tt]{barvinok
\_enumerate}}
92 {barvinok
\_enumerate}}
94 The program
\ai[\tt]{barvinok
\_enumerate} enumerates a
95 parametric polytope. It takes two polytopes in
\PolyLib/
96 notation as input, optionally followed by a list of parameter
98 The two polytopes refer to arguments
\verb+P+ and
\verb+C+
99 of the corresponding function. (See Section~
\ref{a:counting:functions
}.)
100 The following example was taken by
\shortciteN{Loechner1999
}
101 from
\shortciteN[Chapter II
.2]{Loechner97phd
}.
104 # Dimension of the matrix:
108 1 1 0 0 0 0 0 #
0 <= i
109 1 -
1 0 0 1 0 0 # i <= P
110 1 0 1 0 0 0 0 #
0 <= j
111 1 1 -
1 0 0 0 0 # j <= i
112 1 0 0 1 0 0 0 #
0 <= k
113 1 1 -
1 -
1 0 0 0 # k <= i-j
114 0 1 1 1 0 -
1 0 # Q = i + j + k
116 #
2 parameters, no constraints.
118 > ./barvinok_enumerate < loechner
119 POLYHEDRON Dimension:
5
120 Constraints:
6 Equations:
1 Rays:
5 Lines:
0
122 Equality:
[ 1 1 1 0 -
1 0 ]
123 Inequality:
[ 0 1 1 1 -
1 0 ]
124 Inequality:
[ 0 1 0 0 0 0 ]
125 Inequality:
[ 0 0 1 0 0 0 ]
126 Inequality:
[ 0 -
2 -
2 0 1 0 ]
127 Inequality:
[ 0 0 0 0 0 1 ]
131 Vertex:
[ 0 0 0 0 0 ]/
1
134 POLYHEDRON Dimension:
2
135 Constraints:
1 Equations:
0 Rays:
3 Lines:
2
137 Inequality:
[ 0 0 1 ]
146 ( -
1/
2 * P^
2 + (
1 * Q +
1/
2 )
147 * P + ( -
3/
8 * Q^
2 + ( -
1/
2 *
{(
1/
2 * Q +
0 )
149 * Q + ( -
5/
4 *
{(
1/
2 * Q +
0 )
157 (
1/
8 * Q^
2 + ( -
1/
2 *
{(
1/
2 * Q +
0 )
159 * Q + ( -
5/
4 *
{(
1/
2 * Q +
0 )
163 The output corresponds to
166 \makebox[0pt
][l
]{$-
\frac 1 2 P^
2 + P Q +
\frac 1 2 P -
\frac 3 8 Q^
2
167 +
\left(
\frac 1 4 -
\frac 1 2 \left\
{ \frac 1 2 Q
\right\
} \right)
169 -
\frac 5 4 \left\
{ \frac 1 2 Q
\right\
}$
} \\
171 \hbox{if $P
\le Q
\le 2 P$
}
174 \left(
\frac 3 4 -
\frac 1 2 \left\
{ \frac 1 2 Q
\right\
} \right)
175 -
\frac 5 4 \left\
{ \frac 1 2 Q
\right\
}
182 \hbox{if $
0 \le Q
\le P-
1$
}
189 \ai[\tt]{--floor
} &
\ai[\tt]{-f
} &
190 convert
\ai[\tt]{fractional
}s to
\ai[\tt]{flooring
}s
192 \ai[\tt]{--convert
} &
\ai[\tt]{-c
} &
193 convert
\ai[\tt]{fractional
}s to
\ai[\tt]{periodic
}s
196 \subsection{\texorpdfstring{\protect\ai[\tt]{barvinok
\_enumerate\_e}}
197 {barvinok
\_enumerate\_e}}
199 The program
\ai[\tt]{barvinok
\_enumerate\_e} enumerates a
200 parametric projected set. It takes a single polytope in
\PolyLib/
201 notation as input, followed by two lines indicating the number
202 or existential variables and the number of parameters and
203 optionally followed by a list of parameter names.
204 The syntax for the line indicating the number of existential
205 variables is the letter
\verb+E+ followed by a space and the actual number.
206 For indicating the number of parameters, the letter
\verb+P+ is used.
207 The following example corresponds to
208 \citeN[Example~
36 on page~
129]{Verdoolaege2005PhD
}.
221 > ./barvinok_enumerate_e <projected
222 POLYHEDRON Dimension:
4
223 Constraints:
5 Equations:
1 Rays:
4 Lines:
0
225 Equality:
[ 1 -
6 -
9 0 7 ]
226 Inequality:
[ 0 1 0 0 -
1 ]
227 Inequality:
[ 0 -
1 0 0 8 ]
228 Inequality:
[ 0 0 1 0 -
1 ]
229 Inequality:
[ 0 0 -
1 1 0 ]
231 Vertex:
[ 50 8 1 1 ]/
1
234 Vertex:
[ 8 1 1 1 ]/
1
247 \begin{tabular
}{llp
{0.7\textwidth}}
248 \ai[\tt]{--floor
} &
\ai[\tt]{-f
} &
249 convert
\ai[\tt]{fractional
}s to
\ai[\tt]{flooring
}s
251 \ai[\tt]{--convert
} &
\ai[\tt]{-c
} &
252 convert
\ai[\tt]{fractional
}s to
\ai[\tt]{periodic
}s
254 \ai[\tt]{--omega
} &
\ai[\tt]{-o
} &
255 use
\Omegalib/ as a preprocessor
257 \ai[\tt]{--pip
} &
\ai[\tt]{-p
} &
259 call
\ai[\tt]{barvinok
\_enumerate\_pip} instead of
\ai[\tt]{barvinok
\_enumerate\_e}
262 \subsection{\texorpdfstring{\protect\ai[\tt]{barvinok
\_series}}
265 The program
\ai[\tt]{barvinok
\_series} enumerates a
266 parametric polytope in the form of a
\rgf/.
267 The input of this program is the same as that of
268 \ai[\tt]{barvinok
\_enumerate}, except that the input polyhedron
269 is assumed to be full-dimensional.
270 The following is an example of Petr Lison
\u{e
}k
\index{Lison
\u{e
}k, P.
}.
281 > ./barvinok_series < petr
282 POLYHEDRON Dimension:
4
283 Constraints:
5 Equations:
0 Rays:
5 Lines:
0
285 Inequality:
[ -
1 -
1 -
1 1 0 ]
286 Inequality:
[ 1 -
1 0 0 0 ]
287 Inequality:
[ 0 1 -
1 0 0 ]
288 Inequality:
[ 0 0 1 0 -
1 ]
289 Inequality:
[ 0 0 0 0 1 ]
295 Vertex:
[ 1 1 1 3 ]/
1
296 POLYHEDRON Dimension:
1
297 Constraints:
1 Equations:
0 Rays:
2 Lines:
1
303 (n^
3)/((
1-n) * (
1-n) * (
1-n^
2) * (
1-n^
3))
307 \begin{tabular
}{llp
{0.7\textwidth}}
308 \ai[\tt]{--explicit
} &
\ai[\tt]{-e
} &
309 convert computed
\rgf/ to a
\psp/
312 \subsection{\texorpdfstring{\protect\ai[\tt]{barvinok
\_union}}
315 The program
\ai[\tt]{barvinok
\_union} enumerates a
\ai{union
} of
316 parametric polytopes. It takes as input the number of parametric
317 polytopes in the union, the polytopes in combined data and
318 parameter space in
\PolyLib/ notation, the context in parameter space
319 in
\PolyLib/ notation and optionally a list of parameter names.
322 \begin{tabular
}{llp
{0.7\textwidth}}
323 \ai[\tt]{--series
} &
\ai[\tt]{-s
} &
324 compute
\rgf/ instead of
\psp/
327 \subsection{\texorpdfstring{\protect\ai[\tt]{barvinok
\_ehrhart}}
330 The program
\ai[\tt]{barvinok
\_ehrhart} computes the
331 \ai{Ehrhart quasi-polynomial
} of a polytope $P$, i.e., a quasi-polynomial
332 in $n$ that evaluates to the number of integer points in the dilation
333 of $P$ by a factor $n$.
334 The input is the same as that of
\ai[\tt]{barvinok
\_count}, except that
335 it may be followed by the variable name.
336 The functionality is the same as running
\ai[\tt]{barvinok
\_enumerate}
337 (or
\ai[\tt]{barvinok
\_series} if the
\ai[\tt]{--series
} option was given)
338 on the cone over $P$ placed at $n=
1$.
341 \begin{tabular
}{llp
{0.7\textwidth}}
342 \ai[\tt]{--floor
} &
\ai[\tt]{-f
} &
343 convert
\ai[\tt]{fractional
}s to
\ai[\tt]{flooring
}s
345 \ai[\tt]{--convert
} &
\ai[\tt]{-c
} &
346 convert
\ai[\tt]{fractional
}s to
\ai[\tt]{periodic
}s
348 \ai[\tt]{--series
} &
\ai[\tt]{-s
} &
349 compute
\ai{Ehrhart series
} instead of
\ai{Ehrhart quasi-polynomial
}