3 #include <barvinok/options.h>
4 #include <barvinok/util.h>
7 #define MAXRAYS (POL_NO_DUAL | POL_INTEGER)
9 void barvinok_stats_clear(struct barvinok_stats
*stats
)
11 memset(stats
, 0, sizeof(*stats
));
14 void barvinok_stats_print(struct barvinok_stats
*stats
, FILE *out
)
16 fprintf(out
, "Base cones: %ld\n", stats
->base_cones
);
17 if (stats
->volume_simplices
)
18 fprintf(out
, "Volume simplices: %ld\n", stats
->volume_simplices
);
19 if (stats
->topcom_chambers
) {
20 fprintf(out
, "TOPCOM empty chambers: %ld\n",
21 stats
->topcom_empty_chambers
);
22 fprintf(out
, "TOPCOM chambers: %ld\n", stats
->topcom_chambers
);
23 fprintf(out
, "TOPCOM distinct chambers: %ld\n",
24 stats
->topcom_distinct_chambers
);
26 if (stats
->gbr_solved_lps
)
27 fprintf(out
, "LPs solved during GBR: %ld\n", stats
->gbr_solved_lps
);
28 if (stats
->bernoulli_sums
)
29 fprintf(out
, "Bernoulli sums: %ld\n", stats
->bernoulli_sums
);
32 static struct isl_arg_choice approx
[] = {
33 {"lower", BV_APPROX_SIGN_LOWER
},
34 {"upper", BV_APPROX_SIGN_UPPER
},
38 static struct isl_arg_choice approx_method
[] = {
39 {"drop", BV_APPROX_DROP
},
40 {"scale", BV_APPROX_SCALE
},
41 {"volume", BV_APPROX_VOLUME
},
42 {"bernoulli", BV_APPROX_BERNOULLI
},
46 static struct isl_arg_flags scale_flags
[] = {
47 {"fast", BV_APPROX_SCALE_FAST
, BV_APPROX_SCALE_FAST
},
48 {"slow", BV_APPROX_SCALE_FAST
, 0},
49 {"narrow", BV_APPROX_SCALE_NARROW
| BV_APPROX_SCALE_NARROW2
,
50 BV_APPROX_SCALE_NARROW
},
51 {"narrow2", BV_APPROX_SCALE_NARROW
| BV_APPROX_SCALE_NARROW2
,
52 BV_APPROX_SCALE_NARROW2
},
53 {"chamber", BV_APPROX_SCALE_CHAMBER
, BV_APPROX_SCALE_CHAMBER
},
57 static struct isl_arg_choice triangulation
[] = {
58 {"lift", BV_VOL_LIFT
},
59 {"vertex", BV_VOL_VERTEX
},
60 {"barycenter", BV_VOL_BARYCENTER
},
64 static struct isl_arg approx_options_arg
[] = {
65 ISL_ARG_OPT_CHOICE(struct barvinok_approximation_options
, approximation
, 0, \
66 "polynomial-approximation", approx
,
67 BV_APPROX_SIGN_NONE
, BV_APPROX_SIGN_APPROX
, NULL
)
68 ISL_ARG_OPT_CHOICE(struct barvinok_approximation_options
, method
, 0,
69 "approximation-method", approx_method
, BV_APPROX_NONE
, BV_APPROX_DROP
,
70 "method to use in polynomial approximation")
71 ISL_ARG_FLAGS(struct barvinok_approximation_options
, scale_flags
, 0,
72 "scale-options", scale_flags
, 0, NULL
)
73 ISL_ARG_CHOICE(struct barvinok_approximation_options
, volume_triangulate
, 0,
74 "volume-triangulation", triangulation
, BV_VOL_VERTEX
,
75 "type of triangulation to perform in volume computation")
79 static int stats_init(void *user
)
81 struct barvinok_stats
**stats
= (struct barvinok_stats
**)user
;
82 *stats
= isl_alloc_type(NULL
, struct barvinok_stats
);
84 barvinok_stats_clear(*stats
);
85 return *stats
? 0 : -1;
87 static void stats_clear(void *user
)
89 struct barvinok_stats
**stats
= (struct barvinok_stats
**)user
;
92 static int maxrays_init(void *user
)
94 unsigned *MaxRays
= (unsigned *)user
;
98 static int int_init_one(void *user
)
103 static int int_init_zero(void *user
)
108 static void print_version(void)
110 printf("%s", barvinok_version());
113 #ifdef USE_INCREMENTAL_BF
114 #define DEFAULT_SPECIALIZATION BV_SPECIALIZATION_BF
115 #elif defined USE_INCREMENTAL_DF
116 #define DEFAULT_SPECIALIZATION BV_SPECIALIZATION_DF
118 #define DEFAULT_SPECIALIZATION BV_SPECIALIZATION_RANDOM
121 static struct isl_arg_choice specialization
[] = {
122 {"bf", BV_SPECIALIZATION_BF
},
123 {"df", BV_SPECIALIZATION_DF
},
124 {"random", BV_SPECIALIZATION_RANDOM
},
125 {"todd", BV_SPECIALIZATION_TODD
},
130 #define DEFAULT_GBR BV_GBR_GLPK
131 #elif defined HAVE_LIBCDDGMP
132 #define DEFAULT_GBR BV_GBR_CDD
134 #define DEFAULT_GBR BV_GBR_PIP
137 static struct isl_arg_choice gbr
[] = {
139 {"glpk", BV_GBR_GLPK
},
141 #ifdef HAVE_LIBCDDGMP
145 {"pip-dual", BV_GBR_PIP_DUAL
},
150 #define DEFAULT_LP BV_LP_GLPK
151 #elif defined HAVE_LIBCDDGMP
152 #define DEFAULT_LP BV_LP_CDD
154 #define DEFAULT_LP BV_LP_PIP
157 static struct isl_arg_choice lp
[] = {
159 {"glpk", BV_LP_GLPK
},
161 #ifdef HAVE_LIBCDDGMP
163 {"cddf", BV_LP_CDDF
},
166 {"polylib", BV_LP_POLYLIB
},
170 static struct isl_arg_choice summation
[] = {
172 {"euler", BV_SUM_EULER
},
173 {"bernoulli", BV_SUM_BERNOULLI
},
174 {"laurent", BV_SUM_LAURENT
},
175 {"laurent_old", BV_SUM_LAURENT_OLD
},
179 static struct isl_arg_choice chambers
[] = {
180 {"polylib", BV_CHAMBERS_POLYLIB
},
181 #ifdef POINTS2TRIANGS_PATH
182 {"topcom", BV_CHAMBERS_TOPCOM
},
184 {"isl", BV_CHAMBERS_ISL
},
188 static struct isl_arg_choice hull
[] = {
189 {"gbr", BV_HULL_GBR
},
191 {"hilbert", BV_HULL_HILBERT
},
196 struct isl_arg barvinok_options_arg
[] = {
197 ISL_ARG_CHILD(struct barvinok_options
, isl
, "isl", isl_options_arg
, "isl options")
198 ISL_ARG_CHILD(struct barvinok_options
, approx
, NULL
,
199 approx_options_arg
, "polynomial approximation")
200 ISL_ARG_USER(struct barvinok_options
, stats
, &stats_init
, &stats_clear
)
201 ISL_ARG_USER(struct barvinok_options
, MaxRays
, &maxrays_init
, NULL
)
202 ISL_ARG_LONG(struct barvinok_options
, LLL_a
, 0, "lll-reduction-num", 1,
203 "LLL reduction parameter numerator")
204 ISL_ARG_LONG(struct barvinok_options
, LLL_b
, 0, "lll-reduction-den", 1,
205 "LLL reduction parameter denominator")
206 ISL_ARG_CHOICE(struct barvinok_options
, incremental_specialization
,
207 0, "specialization", specialization
, DEFAULT_SPECIALIZATION
, NULL
)
208 ISL_ARG_ULONG(struct barvinok_options
, max_index
, 0, "index", 1,
209 "maximal index of simple cones in decomposition")
210 ISL_ARG_BOOL(struct barvinok_options
, primal
, 0, "primal", 0, NULL
)
211 ISL_ARG_BOOL(struct barvinok_options
, lookup_table
, 0, "table", 0, NULL
)
212 ISL_ARG_USER(struct barvinok_options
, count_sample_infinite
, &int_init_one
, NULL
)
213 ISL_ARG_USER(struct barvinok_options
, try_Delaunay_triangulation
, &int_init_zero
, NULL
)
214 ISL_ARG_CHOICE(struct barvinok_options
, gbr_lp_solver
, 0, "gbr", gbr
,
215 DEFAULT_GBR
, "lp solver to use for basis reduction")
216 ISL_ARG_CHOICE(struct barvinok_options
, lp_solver
, 0, "lp", lp
,
217 DEFAULT_LP
, "lp solver to use")
218 ISL_ARG_CHOICE(struct barvinok_options
, summation
, 0, "summation", summation
,
219 BV_SUM_LAURENT
, NULL
)
220 ISL_ARG_CHOICE(struct barvinok_options
, chambers
, 0, "chamber-decomposition",
221 chambers
, BV_CHAMBERS_POLYLIB
, "tool to use for chamber decomposition")
222 ISL_ARG_CHOICE(struct barvinok_options
, integer_hull
, 0, "integer-hull",
223 hull
, BV_HULL_GBR
, NULL
)
224 ISL_ARG_USER(struct barvinok_options
, gbr_only_first
, &int_init_zero
, NULL
)
225 ISL_ARG_BOOL(struct barvinok_options
, print_stats
, 0, "print-stats", 0, NULL
)
226 ISL_ARG_BOOL(struct barvinok_options
, verbose
, 0, "verbose", 0, NULL
)
227 ISL_ARG_VERSION(print_version
)
231 ISL_ARG_DEF(barvinok_options
, struct barvinok_options
, barvinok_options_arg
)
232 ISL_ARG_CTX_DEF(barvinok_options
, struct barvinok_options
, barvinok_options_arg
)