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
\url{https://barvinok.sourceforge.io/
}.
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]{--isl
} &
\ai[\tt]{-i
} &
303 call
\ai[\tt]{barvinok
\_enumerate\_isl} instead of
\ai[\tt]{barvinok
\_enumerate\_e}
306 \subsection{\texorpdfstring{\protect\ai[\tt]{barvinok
\_union}}
309 The program
\ai[\tt]{barvinok
\_union} enumerates a
\ai{union
} of
310 parametric polytopes. It takes as input the number of parametric
311 polytopes in the union, the polytopes in combined data and
312 parameter space in
\PolyLib/ notation, the context in parameter space
313 in
\PolyLib/ notation and optionally a list of parameter names.
316 \begin{tabular
}{llp
{0.7\textwidth}}
317 \ai[\tt]{--series
} &
\ai[\tt]{-s
} &
318 compute
\rgf/ instead of
\psp/
321 \subsection{\texorpdfstring{\protect\ai[\tt]{barvinok
\_ehrhart}}
324 \sindex{Ehrhart
}{quasi-polynomial
}
325 The program
\ai[\tt]{barvinok
\_ehrhart} computes the
326 \ai{Ehrhart quasi-polynomial
} of a polytope $P$, i.e., a quasi-polynomial
327 in $n$ that evaluates to the number of integer points in the dilation
328 of $P$ by a factor $n$.
329 The input is the same as that of
\ai[\tt]{barvinok
\_count}, except that
330 it may be followed by the variable name.
331 The functionality is the same as running
\ai[\tt]{barvinok
\_enumerate}
332 on the cone over $P$ placed at $n=
1$.
335 \begin{tabular
}{llp
{0.7\textwidth}}
336 \ai[\tt]{--floor
} &
\ai[\tt]{-f
} &
337 convert
\ai[\tt]{fractional
}s to
\ai[\tt]{flooring
}s
339 \ai[\tt]{--convert
} &
\ai[\tt]{-c
} &
340 convert
\ai[\tt]{fractional
}s to
\ai[\tt]{periodic
}s
342 \ai[\tt]{--series
} &
\ai[\tt]{-s
} &
343 compute
\ai{Ehrhart series
} instead of
\ai{Ehrhart quasi-polynomial
}
346 \subsection{\texorpdfstring{\protect\ai[\tt]{polyhedron
\_sample}}
347 {polyhedron
\_sample}}
349 The program
\ai[\tt]{polyhedron
\_sample} takes a polytope
350 in
\PolyLib/ notation and prints an integer point in the polytope
351 if there is one. The point is computed using
352 \ai[\tt]{Polyhedron
\_Sample}.
354 \subsection{\texorpdfstring{\protect\ai[\tt]{polytope
\_scan}}
357 The program
\ai[\tt]{polytope
\_scan} takes a polytope in
358 \PolyLib/ notation and prints a list of all integer points in the polytope.
359 Unless the
\ai[\tt]{--direct
} options is given, the order is based
360 on the
\ai{reduced basis
} computed with
361 \ai[\tt]{Polyhedron
\_Reduced\_Basis}.
364 \begin{tabular
}{llp
{0.7\textwidth}}
365 \ai[\tt]{--direct
} &
\ai[\tt]{-d
} &
366 list the points in the lexicographical order
369 \subsection{\texorpdfstring{\protect\ai[\tt]{lexmin
}}{lexmin
}}
371 The program
\ai[\tt]{lexmin
} implements an algorithm for performing
372 \indac{PIP
} based on
\rgf/s and provides an alternative for the
373 technique of
\shortciteN{Feautrier88parametric
}, which is based
374 on
\ai{cutting plane
}s
\shortcite{Gomory1963
}.
375 The input is the same as that of the
\ai[\tt]{example
} program
376 from
\piplib/
\cite{Feautrier:PIP
}, except that the value
377 for the ``
\ai{big parameter
}'' needs to be $-
1$, since there is
378 no need for big parameters, and it does not read any options
381 \subsection{\texorpdfstring{\protect\ai[\tt]{barvinok
\_summate}}
384 Given a
\psp/ in
\isl/ format,
385 the program
\ai[\tt]{barvinok
\_summate} computes the
\ai{sum
} of
386 the piecewise quasi-polynomial evaluated in all (integer) values of
387 the variables. The result is an expression in the parameters.
388 Note that
\ai[\tt]{barvinok
\_enumerate} and
\ai[\tt]{barvinok
\_enumerate\_e}
389 can produce
\psp/s when given the
\ai[\tt]{-I
} option, but they will
390 have only parameters and no variables.
395 [n
] ->
{ [x, y
] -> x * y :
396 n >= -
9 +
3x and x >=
2 and y >=
4 and y <=
5 }
397 > ./barvinok_summate < square_p3.pwqp
398 [n
] ->
{ (
45 +
63/
2 *
[(n)/
3] +
9/
2 *
[(n)/
3]^
2) : n >= -
3 }
402 \begin{tabular
}{llp
{0.7\textwidth}}
403 \ai[\tt]{--summation
} & &
404 specifies which summation method to use;
405 \ai[\tt]{box
} refers to the method of
406 \shortciteN[Section~
4.5.4]{Verdoolaege2005PhD
},
407 \ai[\tt]{bernoulli
} refers to the method of
408 \autoref{s:nested:exact
},
409 \ai[\tt]{euler
} refers to the method of
411 and
\ai[\tt]{laurent
} refers to the method of
415 \subsection{\texorpdfstring{\protect\ai[\tt]{barvinok
\_bound}}
418 Given a
\psp/ in
\isl/ format,
419 the program
\ai[\tt]{barvinok
\_bound} computes an
\ai{upper bound
}
420 (or
\ai{lower bound
}) for
421 the values attained by the piecewise quasi-polynomial
422 over all (integer) values of the variables.
423 The result is an expression in the parameters.
424 Note that
\ai[\tt]{barvinok
\_enumerate} and
\ai[\tt]{barvinok
\_enumerate\_e}
425 can produce
\psp/s when given the
\ai[\tt]{-I
} option, but they will
426 have only parameters and no variables.
430 [U
] ->
{ [V
] -> ((
1/
3 * U +
2/
3 * V) -
[(U +
2V)/
3]) :
431 2V >= -
3 - U and
2V <= -U and U >=
0 and U <=
10 }
432 > ./barvinok_bound < devos.pwqp
433 [U
] ->
{ max(
2/
3) : U <=
10 and U >=
0 }
437 \begin{tabular
}{llp
{0.7\textwidth}}
438 \ai[\tt]{--lower
} & &
439 compute lower bound instead of upper bound
442 \subsection{\texorpdfstring{\protect\ai[\tt]{polytope
\_minimize}}
443 {polytope
\_minimize}}
445 The program
\ai[\tt]{polytope
\_minimize} has been superseded
446 by
\isl/'s
\ai[\tt]{isl
\_polyhedron\_minimize}.
448 \subsection{\texorpdfstring{\protect\ai[\tt]{polyhedron
\_integer\_hull}}
449 {polyhedron
\_integer\_hull}}
451 The program
\ai[\tt]{polyhedron
\_integer\_hull} takes a polyhedron
452 in
\PolyLib/ notation and
453 prints its
\ai{integer hull
}.
454 The integer hull is computed as explained in
\autoref{s:integer:hull
}.
456 \subsection{\texorpdfstring{\protect\ai[\tt]{polytope
\_lattice\_width}}
457 {polytope
\_lattice\_width}}
459 The program
\ai[\tt]{polytope
\_lattice\_width} computes
460 the
\ai{lattice width
} of a parametric polytope.
461 The input is the same as that of
\ai[\tt]{barvinok
\_enumerate}.
462 The lattice width is computed as explained
463 in
\autoref{s:width
}.
466 \begin{tabular
}{llp
{0.7\textwidth}}
467 \ai[\tt]{--direction
} &
\ai[\tt]{-d
} &
468 print the lattice width directions