1 \section{\texorpdfstring{Applications included
2 in the
\protect\ai[\tt]{barvinok
} distribution
}
3 {Applications included in the barvinok distribution
}}
6 \index{barvinok@
{\tt barvinok
}!availability
}
8 This section describes some application programs
9 provided by the
\barvinok/ library,
10 available from
{\tt http://freshmeat.net/projects/barvinok/.
}
11 For compilation instructions we refer to the
\verb+README+ file
12 included in the distribution.
15 Common option to all programs:\\
17 \ai[\tt]{--version
} &
\ai[\tt]{-V
} & print version
19 \ai[\tt]{--help
} &
\ai[\tt]{-?
} & list available options
22 \subsection{\texorpdfstring{\protect\ai[\tt]{barvinok
\_count}}{barvinok
\_count}}
24 The program
\ai[\tt]{barvinok
\_count} enumerates a
25 non-parametric polytope. It takes one polytope
26 in
\PolyLib/ notation as input and prints the number
27 of integer points in the polytope.
28 The
\PolyLib/ notation corresponds to the internal
29 representation of
\ai[\tt]{Polyhedron
}s as explained
30 in Section~
\ref{a:existing
}.
31 \index{input format!constraints
}
32 The first line of the input contains the number of rows
33 and the number of columns in the
\ai[\tt]{Constraint
} matrix.
34 The rest of the input is composed of the elements of the matrix.
35 Recall that the number of columns is two more than the number
36 of variables, where the extra first columns is one or zero
37 depending on whether the constraint is an inequality ($
\ge 0$)
38 or an equality ($=
0$). The next columns contain
39 the coefficients of the variables and the final column contains
40 the constant in the constraint.
42 $S =
\lb\, s
\mid s
\geq 0 \wedge 2 s
\leq 13 \,
\rb$
43 from
\citeN[Example~
38 on page~
134]{Verdoolaege2005PhD
}
44 corresponds to the following input and
52 > ./barvinok_count < S
53 POLYHEDRON Dimension:
1
54 Constraints:
2 Equations:
0 Rays:
2 Lines:
0
63 \index{PolyLib@
{\tt PolyLib
}!version
5.22.0 or newer
}
64 Note that if you use
\PolyLib/ version
5.22.0 or newer then the output
65 may look slightly different as the computation of the
\ai[\tt]{Rays
}
66 may have been postponed to a later stage.
67 The program
\ai[\tt]{latte2polylib.pl
} can be used to
68 convert a polytope from
\ai[\tt]{LattE
} \shortcite{latte1.1
}
69 notation to
\PolyLib/ notation.
71 \index{input format!vertices
}
72 As an alternative to the constraints based input, the input polytope
73 may also be specified by its
\ai[\tt]{Ray
} matrix.
74 The first line of the input contains the single word
\ai[\tt]{vertices
}.
75 The second line contains the number of rows
76 and the number of columns in the
\ai[\tt]{Ray
} matrix.
77 The rest of the input is composed of the elements of the matrix.
78 Recall that the number of columns is two more than the number
79 of variables, where the extra first columns is one or zero
80 depending on whether the ray is a line or not.
81 The next columns contain
82 the numerators of the coordinates and the final column contains
83 the denominator of the vertex or $
0$ for a ray.
84 E.g., the above set can also be described as
94 \subsection{\texorpdfstring{\protect\ai[\tt]{barvinok
\_enumerate}}
95 {barvinok
\_enumerate}}
97 The program
\ai[\tt]{barvinok
\_enumerate} enumerates a
98 parametric polytope as a
\psp/ or
\rgf/. It takes two polytopes in
\PolyLib/
99 notation as input, optionally followed by a list of parameter
101 The two polytopes refer to arguments
\verb+P+ and
\verb+C+
102 of the corresponding function. (See Section~
\ref{a:counting:functions
}.)
103 The following example was taken by
\shortciteN{Loechner1999
}
104 from
\shortciteN[Chapter II
.2]{Loechner97phd
}.
107 # Dimension of the matrix:
111 1 1 0 0 0 0 0 #
0 <= i
112 1 -
1 0 0 1 0 0 # i <= P
113 1 0 1 0 0 0 0 #
0 <= j
114 1 1 -
1 0 0 0 0 # j <= i
115 1 0 0 1 0 0 0 #
0 <= k
116 1 1 -
1 -
1 0 0 0 # k <= i-j
117 0 1 1 1 0 -
1 0 # Q = i + j + k
119 #
2 parameters, no constraints.
121 > ./barvinok_enumerate < loechner
122 POLYHEDRON Dimension:
5
123 Constraints:
6 Equations:
1 Rays:
5 Lines:
0
125 Equality:
[ 1 1 1 0 -
1 0 ]
126 Inequality:
[ 0 1 1 1 -
1 0 ]
127 Inequality:
[ 0 1 0 0 0 0 ]
128 Inequality:
[ 0 0 1 0 0 0 ]
129 Inequality:
[ 0 -
2 -
2 0 1 0 ]
130 Inequality:
[ 0 0 0 0 0 1 ]
134 Vertex:
[ 0 0 0 0 0 ]/
1
137 POLYHEDRON Dimension:
2
138 Constraints:
1 Equations:
0 Rays:
3 Lines:
2
140 Inequality:
[ 0 0 1 ]
149 ( -
1/
2 * P^
2 + (
1 * Q +
1/
2 )
150 * P + ( -
3/
8 * Q^
2 + ( -
1/
2 *
{(
1/
2 * Q +
0 )
152 * Q + ( -
5/
4 *
{(
1/
2 * Q +
0 )
160 (
1/
8 * Q^
2 + ( -
1/
2 *
{(
1/
2 * Q +
0 )
162 * Q + ( -
5/
4 *
{(
1/
2 * Q +
0 )
166 The output corresponds to
169 \makebox[0pt
][l
]{$-
\frac 1 2 P^
2 + P Q +
\frac 1 2 P -
\frac 3 8 Q^
2
170 +
\left(
\frac 1 4 -
\frac 1 2 \left\
{ \frac 1 2 Q
\right\
} \right)
172 -
\frac 5 4 \left\
{ \frac 1 2 Q
\right\
}$
} \\
174 \hbox{if $P
\le Q
\le 2 P$
}
177 \left(
\frac 3 4 -
\frac 1 2 \left\
{ \frac 1 2 Q
\right\
} \right)
178 -
\frac 5 4 \left\
{ \frac 1 2 Q
\right\
}
185 \hbox{if $
0 \le Q
\le P-
1$
}
189 The following is an example of Petr Lison
\u{e
}k
\index{Lison
\u{e
}k, P.
}.
200 > ./barvinok_enumerate --series < petr
201 POLYHEDRON Dimension:
4
202 Constraints:
5 Equations:
0 Rays:
5 Lines:
0
204 Inequality:
[ -
1 -
1 -
1 1 0 ]
205 Inequality:
[ 1 -
1 0 0 0 ]
206 Inequality:
[ 0 1 -
1 0 0 ]
207 Inequality:
[ 0 0 1 0 -
1 ]
208 Inequality:
[ 0 0 0 0 1 ]
214 Vertex:
[ 1 1 1 3 ]/
1
215 POLYHEDRON Dimension:
1
216 Constraints:
1 Equations:
0 Rays:
2 Lines:
1
222 (n^
3)/((
1-n) * (
1-n) * (
1-n^
2) * (
1-n^
3))
226 \begin{tabular
}{llp
{0.7\textwidth}}
227 \ai[\tt]{--floor
} &
\ai[\tt]{-f
} &
228 convert
\ai[\tt]{fractional
}s to
\ai[\tt]{flooring
}s
230 \ai[\tt]{--convert
} &
\ai[\tt]{-c
} &
231 convert
\ai[\tt]{fractional
}s to
\ai[\tt]{periodic
}s
233 \ai[\tt]{--series
} &
\ai[\tt]{-s
} &
234 compute
\rgf/ instead of
\psp/
236 \ai[\tt]{--explicit
} &
\ai[\tt]{-e
} &
237 convert computed
\rgf/ to a
\psp/
240 \subsection{\texorpdfstring{\protect\ai[\tt]{barvinok
\_enumerate\_e}}
241 {barvinok
\_enumerate\_e}}
243 The program
\ai[\tt]{barvinok
\_enumerate\_e} enumerates a
244 parametric projected set. It takes a single polytope in
\PolyLib/
245 notation as input, followed by two lines indicating the number
246 or existential variables and the number of parameters and
247 optionally followed by a list of parameter names.
248 The syntax for the line indicating the number of existential
249 variables is the letter
\verb+E+ followed by a space and the actual number.
250 For indicating the number of parameters, the letter
\verb+P+ is used.
251 The following example corresponds to
252 \citeN[Example~
36 on page~
129]{Verdoolaege2005PhD
}.
265 > ./barvinok_enumerate_e <projected
266 POLYHEDRON Dimension:
4
267 Constraints:
5 Equations:
1 Rays:
4 Lines:
0
269 Equality:
[ 1 -
6 -
9 0 7 ]
270 Inequality:
[ 0 1 0 0 -
1 ]
271 Inequality:
[ 0 -
1 0 0 8 ]
272 Inequality:
[ 0 0 1 0 -
1 ]
273 Inequality:
[ 0 0 -
1 1 0 ]
275 Vertex:
[ 50 8 1 1 ]/
1
278 Vertex:
[ 8 1 1 1 ]/
1
291 \begin{tabular
}{llp
{0.7\textwidth}}
292 \ai[\tt]{--floor
} &
\ai[\tt]{-f
} &
293 convert
\ai[\tt]{fractional
}s to
\ai[\tt]{flooring
}s
295 \ai[\tt]{--convert
} &
\ai[\tt]{-c
} &
296 convert
\ai[\tt]{fractional
}s to
\ai[\tt]{periodic
}s
298 \ai[\tt]{--omega
} &
\ai[\tt]{-o
} &
299 use
\Omegalib/ as a preprocessor
301 \ai[\tt]{--pip
} &
\ai[\tt]{-p
} &
302 \begin{minipage
}[t
]{0.7\textwidth}
304 call
\ai[\tt]{barvinok
\_enumerate\_pip} instead of
\ai[\tt]{barvinok
\_enumerate\_e}
307 \ai[\tt]{--isl
} &
\ai[\tt]{-i
} &
309 call
\ai[\tt]{barvinok
\_enumerate\_isl} instead of
\ai[\tt]{barvinok
\_enumerate\_e}
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 \sindex{Ehrhart
}{quasi-polynomial
}
331 The program
\ai[\tt]{barvinok
\_ehrhart} computes the
332 \ai{Ehrhart quasi-polynomial
} of a polytope $P$, i.e., a quasi-polynomial
333 in $n$ that evaluates to the number of integer points in the dilation
334 of $P$ by a factor $n$.
335 The input is the same as that of
\ai[\tt]{barvinok
\_count}, except that
336 it may be followed by the variable name.
337 The functionality is the same as running
\ai[\tt]{barvinok
\_enumerate}
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
}
352 \subsection{\texorpdfstring{\protect\ai[\tt]{polyhedron
\_sample}}
353 {polyhedron
\_sample}}
355 The program
\ai[\tt]{polyhedron
\_sample} takes a polytope
356 in
\PolyLib/ notation and prints an integer point in the polytope
357 if there is one. The point is computed using
358 \ai[\tt]{Polyhedron
\_Sample}.
360 \subsection{\texorpdfstring{\protect\ai[\tt]{polytope
\_scan}}
363 The program
\ai[\tt]{polytope
\_scan} takes a polytope in
364 \PolyLib/ notation and prints a list of all integer points in the polytope.
365 Unless the
\ai[\tt]{--direct
} options is given, the order is based
366 on the
\ai{reduced basis
} computed with
367 \ai[\tt]{Polyhedron
\_Reduced\_Basis}.
370 \begin{tabular
}{llp
{0.7\textwidth}}
371 \ai[\tt]{--direct
} &
\ai[\tt]{-d
} &
372 list the points in the lexicographical order
375 \subsection{\texorpdfstring{\protect\ai[\tt]{lexmin
}}{lexmin
}}
377 The program
\ai[\tt]{lexmin
} implements an algorithm for performing
378 \indac{PIP
} based on
\rgf/s and provides an alternative for the
379 technique of
\shortciteN{Feautrier88parametric
}, which is based
380 on
\ai{cutting plane
}s
\shortcite{Gomory1963
}.
381 The input is the same as that of the
\ai[\tt]{example
} program
382 from
\piplib/
\cite{Feautrier:PIP
}, except that the value
383 for the ``
\ai{big parameter
}'' needs to be $-
1$, since there is
384 no need for big parameters, and it does not read any options
387 \subsection{\texorpdfstring{\protect\ai[\tt]{barvinok
\_summate}}
390 Given a
\psp/ in
\isl/ format,
391 the program
\ai[\tt]{barvinok
\_summate} computes the
\ai{sum
} of
392 the piecewise quasi-polynomial evaluated in all (integer) values of
393 the variables. The result is an expression in the parameters.
394 Note that
\ai[\tt]{barvinok
\_enumerate} and
\ai[\tt]{barvinok
\_enumerate\_e}
395 can produce
\psp/s when given the
\ai[\tt]{-I
} option, but they will
396 have only parameters and no variables.
401 [n
] ->
{ [x, y
] -> x * y :
402 n >= -
9 +
3x and x >=
2 and y >=
4 and y <=
5 }
403 > ./barvinok_summate < square_p3.pwqp
404 [n
] ->
{ (
45 +
63/
2 *
[(n)/
3] +
9/
2 *
[(n)/
3]^
2) : n >= -
3 }
408 \begin{tabular
}{llp
{0.7\textwidth}}
409 \ai[\tt]{--summation
} & &
410 specifies which summation method to use;
411 \ai[\tt]{box
} refers to the method of
412 \shortciteN[Section~
4.5.4]{Verdoolaege2005PhD
},
413 \ai[\tt]{bernoulli
} refers to the method of
414 \autoref{s:nested:exact
},
415 \ai[\tt]{euler
} refers to the method of
417 and
\ai[\tt]{laurent
} refers to the method of
421 \subsection{\texorpdfstring{\protect\ai[\tt]{barvinok
\_bound}}
424 Given a
\psp/ in
\isl/ format,
425 the program
\ai[\tt]{barvinok
\_bound} computes an
\ai{upper bound
}
426 (or
\ai{lower bound
}) for
427 the values attained by the piecewise quasi-polynomial
428 over all (integer) values of the variables.
429 The result is an expression in the parameters.
430 Note that
\ai[\tt]{barvinok
\_enumerate} and
\ai[\tt]{barvinok
\_enumerate\_e}
431 can produce
\psp/s when given the
\ai[\tt]{-I
} option, but they will
432 have only parameters and no variables.
436 [U
] ->
{ [V
] -> ((
1/
3 * U +
2/
3 * V) -
[(U +
2V)/
3]) :
437 2V >= -
3 - U and
2V <= -U and U >=
0 and U <=
10 }
438 > ./barvinok_bound < devos.pwqp
439 [U
] ->
{ max(
2/
3) : U <=
10 and U >=
0 }
443 \begin{tabular
}{llp
{0.7\textwidth}}
444 \ai[\tt]{--lower
} & &
445 compute lower bound instead of upper bound
448 \subsection{\texorpdfstring{\protect\ai[\tt]{polytope
\_minimize}}
449 {polytope
\_minimize}}
451 The program
\ai[\tt]{polytope
\_minimize} has been superseded
452 by
\isl/'s
\ai[\tt]{isl
\_polyhedron\_minimize}.
454 \subsection{\texorpdfstring{\protect\ai[\tt]{polyhedron
\_integer\_hull}}
455 {polyhedron
\_integer\_hull}}
457 The program
\ai[\tt]{polyhedron
\_integer\_hull} takes a polyhedron
458 in
\PolyLib/ notation and
459 prints its
\ai{integer hull
}.
460 The integer hull is computed as explained in
\autoref{s:integer:hull
}.
462 \subsection{\texorpdfstring{\protect\ai[\tt]{polytope
\_lattice\_width}}
463 {polytope
\_lattice\_width}}
465 The program
\ai[\tt]{polytope
\_lattice\_width} computes
466 the
\ai{lattice width
} of a parametric polytope.
467 The input is the same as that of
\ai[\tt]{barvinok
\_enumerate}.
468 The lattice width is computed as explained
469 in
\autoref{s:width
}.
472 \begin{tabular
}{llp
{0.7\textwidth}}
473 \ai[\tt]{--direction
} &
\ai[\tt]{-d
} &
474 print the lattice width directions