more partial ray removal (largely untested
[barvinok.git] / barvinok_enumerate_e.c
blob007dd5e665485cbb1b42dc3303678c584bcd97ba
1 #include <unistd.h>
2 #include <sys/times.h>
3 #include <getopt.h>
4 #include <polylib/polylibgmp.h>
5 #include "ev_operations.h"
6 #include <util.h>
7 #include <barvinok.h>
9 /* The input of this example program is a polytope in combined
10 * data and parameter space followed by two lines indicating
11 * the number of existential variables and parameters respectively.
12 * The first lines starts with "E ", followed by a number.
13 * The second lines starts with "P ", followed by a number.
14 * These two lines are (optionally) followed by the names of the parameters.
15 * The polytope is in PolyLib notation.
18 struct option options[] = {
19 { "range", no_argument, 0, 'r' },
20 { 0, 0, 0, 0 }
23 int main(int argc, char **argv)
25 Polyhedron *A;
26 Matrix *M;
27 char **param_name;
28 int exist, nparam;
29 char s[128];
30 evalue *EP;
31 int c, ind = 0;
32 int range = 0;
34 while ((c = getopt_long(argc, argv, "r", options, &ind)) != -1) {
35 switch (c) {
36 case 'r':
37 range = 1;
38 break;
42 M = Matrix_Read();
43 A = Constraints2Polyhedron(M, 600);
44 Matrix_Free(M);
46 fgets(s, 128, stdin);
47 while ((*s=='#') || (sscanf(s, "E %d", &exist)<1))
48 fgets(s, 128, stdin);
50 fgets(s, 128, stdin);
51 while ((*s=='#') || (sscanf(s, "P %d", &nparam)<1))
52 fgets(s, 128, stdin);
54 Polyhedron_Print(stdout, P_VALUE_FMT, A);
55 printf("exist: %d, nparam: %d\n", exist, nparam);
56 param_name = Read_ParamNames(stdin, nparam);
57 EP = barvinok_enumerate_e(A, exist, nparam, 600);
58 if (range)
59 evalue_range_reduction(EP);
60 print_evalue(stdout, EP, param_name);
61 free_evalue_refs(EP);
62 free(EP);
63 Free_ParamNames(param_name, nparam);
64 Polyhedron_Free(A);
65 return 0;