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:
0 Lines:
0
61 \index{PolyLib@
{\tt PolyLib
}!version
5.22.0 or newer
}
62 Note that if you use
\PolyLib/ version
5.22.0 or newer then the output
63 may look slightly different as the computation of the
\ai[\tt]{Rays
}
64 may have been postponed to a later stage.
65 The program
\ai[\tt]{latte2polylib.pl
} can be used to
66 convert a polytope from
\ai[\tt]{LattE
} \shortcite{latte1.1
}
67 notation to
\PolyLib/ notation.
69 \index{input format!vertices
}
70 As an alternative to the constraints based input, the input polytope
71 may also be specified by its
\ai[\tt]{Ray
} matrix.
72 The first line of the input contains the single word
\ai[\tt]{vertices
}.
73 The second line contains the number of rows
74 and the number of columns in the
\ai[\tt]{Ray
} matrix.
75 The rest of the input is composed of the elements of the matrix.
76 Recall that the number of columns is two more than the number
77 of variables, where the extra first columns is one or zero
78 depending on whether the ray is a line or not.
79 The next columns contain
80 the numerators of the coordinates and the final column contains
81 the denominator of the vertex or $
0$ for a ray.
82 E.g., the above set can also be described as
92 \subsection{\texorpdfstring{\protect\ai[\tt]{barvinok
\_enumerate}}
93 {barvinok
\_enumerate}}
95 The program
\ai[\tt]{barvinok
\_enumerate} enumerates a
96 parametric polytope as a
\psp/ or
\rgf/. It takes two polytopes in
\PolyLib/
97 notation as input, optionally followed by a list of parameter
99 The two polytopes refer to arguments
\verb+P+ and
\verb+C+
100 of the corresponding function. (See Section~
\ref{a:counting:functions
}.)
101 The following example was taken by
\shortciteN{Loechner1999
}
102 from
\shortciteN[Chapter II
.2]{Loechner97phd
}.
105 # Dimension of the matrix:
109 1 1 0 0 0 0 0 #
0 <= i
110 1 -
1 0 0 1 0 0 # i <= P
111 1 0 1 0 0 0 0 #
0 <= j
112 1 1 -
1 0 0 0 0 # j <= i
113 1 0 0 1 0 0 0 #
0 <= k
114 1 1 -
1 -
1 0 0 0 # k <= i-j
115 0 1 1 1 0 -
1 0 # Q = i + j + k
117 #
2 parameters, no constraints.
119 > ./barvinok_enumerate < loechner
124 (
1/
8 * Q^
2 + ( -
1/
2 *
{(
1/
2 * Q +
0 )
126 * Q + ( -
5/
4 *
{(
1/
2 * Q +
0 )
133 ( -
1/
2 * P^
2 + (
1 * Q +
1/
2 )
134 * P + ( -
3/
8 * Q^
2 + ( -
1/
2 *
{(
1/
2 * Q +
0 )
136 * Q + ( -
5/
4 *
{(
1/
2 * Q +
0 )
141 The output corresponds to
144 \makebox[0pt
][l
]{$-
\frac 1 2 P^
2 + P Q +
\frac 1 2 P -
\frac 3 8 Q^
2
145 +
\left(
\frac 1 4 -
\frac 1 2 \left\
{ \frac 1 2 Q
\right\
} \right)
147 -
\frac 5 4 \left\
{ \frac 1 2 Q
\right\
}$
} \\
149 \hbox{if $P
\le Q
\le 2 P$
}
152 \left(
\frac 3 4 -
\frac 1 2 \left\
{ \frac 1 2 Q
\right\
} \right)
153 -
\frac 5 4 \left\
{ \frac 1 2 Q
\right\
}
160 \hbox{if $
0 \le Q
\le P-
1$
}
164 The following is an example of Petr Lison
\u{e
}k
\index{Lison
\u{e
}k, P.
}.
175 > ./barvinok_enumerate --series < petr
176 (n^
3)/((
1-n) * (
1-n) * (
1-n^
2) * (
1-n^
3))
180 \begin{tabular
}{llp
{0.7\textwidth}}
181 \ai[\tt]{--floor
} &
\ai[\tt]{-f
} &
182 convert
\ai[\tt]{fractional
}s to
\ai[\tt]{flooring
}s
184 \ai[\tt]{--convert
} &
\ai[\tt]{-c
} &
185 convert
\ai[\tt]{fractional
}s to
\ai[\tt]{periodic
}s
187 \ai[\tt]{--series
} &
\ai[\tt]{-s
} &
188 compute
\rgf/ instead of
\psp/
190 \ai[\tt]{--explicit
} &
\ai[\tt]{-e
} &
191 convert computed
\rgf/ to a
\psp/
194 \subsection{\texorpdfstring{\protect\ai[\tt]{barvinok
\_enumerate\_e}}
195 {barvinok
\_enumerate\_e}}
197 The program
\ai[\tt]{barvinok
\_enumerate\_e} enumerates a
198 parametric projected set. It takes a single polytope in
\PolyLib/
199 notation as input, followed by two lines indicating the number
200 or existential variables and the number of parameters and
201 optionally followed by a list of parameter names.
202 The syntax for the line indicating the number of existential
203 variables is the letter
\verb+E+ followed by a space and the actual number.
204 For indicating the number of parameters, the letter
\verb+P+ is used.
205 The following example corresponds to
206 \citeN[Example~
36 on page~
129]{Verdoolaege2005PhD
}.
219 > ./barvinok_enumerate_e <projected
231 \begin{tabular
}{llp
{0.7\textwidth}}
232 \ai[\tt]{--floor
} &
\ai[\tt]{-f
} &
233 convert
\ai[\tt]{fractional
}s to
\ai[\tt]{flooring
}s
235 \ai[\tt]{--convert
} &
\ai[\tt]{-c
} &
236 convert
\ai[\tt]{fractional
}s to
\ai[\tt]{periodic
}s
238 \ai[\tt]{--isl
} &
\ai[\tt]{-i
} &
240 call
\ai[\tt]{barvinok
\_enumerate\_isl} instead of
\ai[\tt]{barvinok
\_enumerate\_e}
243 \subsection{\texorpdfstring{\protect\ai[\tt]{barvinok
\_union}}
246 The program
\ai[\tt]{barvinok
\_union} enumerates a
\ai{union
} of
247 parametric polytopes. It takes as input the number of parametric
248 polytopes in the union, the polytopes in combined data and
249 parameter space in
\PolyLib/ notation, the context in parameter space
250 in
\PolyLib/ notation and optionally a list of parameter names.
253 \begin{tabular
}{llp
{0.7\textwidth}}
254 \ai[\tt]{--series
} &
\ai[\tt]{-s
} &
255 compute
\rgf/ instead of
\psp/
258 \subsection{\texorpdfstring{\protect\ai[\tt]{barvinok
\_ehrhart}}
261 \sindex{Ehrhart
}{quasi-polynomial
}
262 The program
\ai[\tt]{barvinok
\_ehrhart} computes the
263 \ai{Ehrhart quasi-polynomial
} of a polytope $P$, i.e., a quasi-polynomial
264 in $n$ that evaluates to the number of integer points in the dilation
265 of $P$ by a factor $n$.
266 The input is the same as that of
\ai[\tt]{barvinok
\_count}, except that
267 it may be followed by the variable name.
268 The functionality is the same as running
\ai[\tt]{barvinok
\_enumerate}
269 on the cone over $P$ placed at $n=
1$.
272 \begin{tabular
}{llp
{0.7\textwidth}}
273 \ai[\tt]{--floor
} &
\ai[\tt]{-f
} &
274 convert
\ai[\tt]{fractional
}s to
\ai[\tt]{flooring
}s
276 \ai[\tt]{--convert
} &
\ai[\tt]{-c
} &
277 convert
\ai[\tt]{fractional
}s to
\ai[\tt]{periodic
}s
279 \ai[\tt]{--series
} &
\ai[\tt]{-s
} &
280 compute
\ai{Ehrhart series
} instead of
\ai{Ehrhart quasi-polynomial
}
283 \subsection{\texorpdfstring{\protect\ai[\tt]{polyhedron
\_sample}}
284 {polyhedron
\_sample}}
286 The program
\ai[\tt]{polyhedron
\_sample} takes a polytope
287 in
\PolyLib/ notation and prints an integer point in the polytope
288 if there is one. The point is computed using
289 \ai[\tt]{Polyhedron
\_Sample}.
291 \subsection{\texorpdfstring{\protect\ai[\tt]{polytope
\_scan}}
294 The program
\ai[\tt]{polytope
\_scan} takes a polytope in
295 \PolyLib/ notation and prints a list of all integer points in the polytope.
296 Unless the
\ai[\tt]{--direct
} options is given, the order is based
297 on the
\ai{reduced basis
} computed with
298 \ai[\tt]{Polyhedron
\_Reduced\_Basis}.
301 \begin{tabular
}{llp
{0.7\textwidth}}
302 \ai[\tt]{--direct
} &
\ai[\tt]{-d
} &
303 list the points in the lexicographical order
306 \subsection{\texorpdfstring{\protect\ai[\tt]{lexmin
}}{lexmin
}}
308 The program
\ai[\tt]{lexmin
} implements an algorithm for performing
309 \indac{PIP
} based on
\rgf/s and provides an alternative for the
310 technique of
\shortciteN{Feautrier88parametric
}, which is based
311 on
\ai{cutting plane
}s
\shortcite{Gomory1963
}.
312 The input is the same as that of the
\ai[\tt]{example
} program
313 from
\piplib/
\cite{Feautrier:PIP
}, except that the value
314 for the ``
\ai{big parameter
}'' needs to be $-
1$, since there is
315 no need for big parameters, and it does not read any options
318 \subsection{\texorpdfstring{\protect\ai[\tt]{barvinok
\_summate}}
321 Given a
\psp/ in
\isl/ format,
322 the program
\ai[\tt]{barvinok
\_summate} computes the
\ai{sum
} of
323 the piecewise quasi-polynomial evaluated in all (integer) values of
324 the variables. The result is an expression in the parameters.
325 Note that
\ai[\tt]{barvinok
\_enumerate} and
\ai[\tt]{barvinok
\_enumerate\_e}
326 can produce
\psp/s when given the
\ai[\tt]{-I
} option, but they will
327 have only parameters and no variables.
332 [n
] ->
{ [x, y
] -> x * y :
333 n >= -
9 +
3x and x >=
2 and y >=
4 and y <=
5 }
334 > ./barvinok_summate < square_p3.pwqp
335 [n
] ->
{ (
45 +
63/
2 * floor((n)/
3) +
9/
2 * floor((n)/
3)^
2) : n >= -
3 }
339 \begin{tabular
}{llp
{0.7\textwidth}}
340 \ai[\tt]{--summation
} & &
341 specifies which summation method to use;
342 \ai[\tt]{box
} refers to the method of
343 \shortciteN[Section~
4.5.4]{Verdoolaege2005PhD
},
344 \ai[\tt]{bernoulli
} refers to the method of
345 \autoref{s:nested:exact
},
346 \ai[\tt]{euler
} refers to the method of
348 and
\ai[\tt]{laurent
} refers to the method of
352 \subsection{\texorpdfstring{\protect\ai[\tt]{barvinok
\_bound}}
355 Given a
\psp/ in
\isl/ format,
356 the program
\ai[\tt]{barvinok
\_bound} computes an
\ai{upper bound
}
357 (or
\ai{lower bound
}) for
358 the values attained by the piecewise quasi-polynomial
359 over all (integer) values of the variables.
360 The result is an expression in the parameters.
361 Note that
\ai[\tt]{barvinok
\_enumerate} and
\ai[\tt]{barvinok
\_enumerate\_e}
362 can produce
\psp/s when given the
\ai[\tt]{-I
} option, but they will
363 have only parameters and no variables.
367 [U
] ->
{ [V
] -> ((
1/
3 * U +
2/
3 * V) -
[(U +
2V)/
3]) :
368 2V >= -
3 - U and
2V <= -U and U >=
0 and U <=
10 }
369 > ./barvinok_bound < devos.pwqp
370 [U
] ->
{ max(
2/
3) :
0 <= U <=
10 }
374 \begin{tabular
}{llp
{0.7\textwidth}}
375 \ai[\tt]{--lower
} & &
376 compute lower bound instead of upper bound
379 \subsection{\texorpdfstring{\protect\ai[\tt]{polytope
\_minimize}}
380 {polytope
\_minimize}}
382 The program
\ai[\tt]{polytope
\_minimize} has been superseded
383 by
\isl/'s
\ai[\tt]{isl
\_polyhedron\_minimize}.
385 \subsection{\texorpdfstring{\protect\ai[\tt]{polyhedron
\_integer\_hull}}
386 {polyhedron
\_integer\_hull}}
388 The program
\ai[\tt]{polyhedron
\_integer\_hull} takes a polyhedron
389 in
\PolyLib/ notation and
390 prints its
\ai{integer hull
}.
391 The integer hull is computed as explained in
\autoref{s:integer:hull
}.
393 \subsection{\texorpdfstring{\protect\ai[\tt]{polytope
\_lattice\_width}}
394 {polytope
\_lattice\_width}}
396 The program
\ai[\tt]{polytope
\_lattice\_width} computes
397 the
\ai{lattice width
} of a parametric polytope.
398 The input is the same as that of
\ai[\tt]{barvinok
\_enumerate}.
399 The lattice width is computed as explained
400 in
\autoref{s:width
}.
403 \begin{tabular
}{llp
{0.7\textwidth}}
404 \ai[\tt]{--direction
} &
\ai[\tt]{-d
} &
405 print the lattice width directions