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 int set_approx(void *opt
, unsigned val
)
66 struct barvinok_approximation_options
*options
;
67 options
= (struct barvinok_approximation_options
*)opt
;
68 options
->approximation
= val
;
69 if (options
->method
== BV_APPROX_NONE
)
70 options
->method
= BV_APPROX_SCALE
;
74 static int set_method(void *opt
, unsigned val
)
76 struct barvinok_approximation_options
*options
;
77 options
= (struct barvinok_approximation_options
*)opt
;
78 options
->method
= val
;
79 if (options
->approximation
== BV_APPROX_SIGN_NONE
)
80 options
->approximation
= BV_APPROX_SIGN_APPROX
;
84 static struct isl_arg approx_options_arg
[] = {
85 ISL_ARG_USER_OPT_CHOICE(struct barvinok_approximation_options
, approximation
, 0,
86 "polynomial-approximation", approx
, &set_approx
,
87 BV_APPROX_SIGN_NONE
, BV_APPROX_SIGN_APPROX
, NULL
)
88 ISL_ARG_USER_OPT_CHOICE(struct barvinok_approximation_options
, method
, 0,
89 "approximation-method", approx_method
, &set_method
,
90 BV_APPROX_NONE
, BV_APPROX_DROP
,
91 "method to use in polynomial approximation")
92 ISL_ARG_FLAGS(struct barvinok_approximation_options
, scale_flags
, 0,
93 "scale-options", scale_flags
, 0, NULL
)
94 ISL_ARG_CHOICE(struct barvinok_approximation_options
, volume_triangulate
, 0,
95 "volume-triangulation", triangulation
, BV_VOL_VERTEX
,
96 "type of triangulation to perform in volume computation")
100 static int stats_init(void *user
)
102 struct barvinok_stats
**stats
= (struct barvinok_stats
**)user
;
103 *stats
= isl_alloc_type(NULL
, struct barvinok_stats
);
105 barvinok_stats_clear(*stats
);
106 return *stats
? 0 : -1;
108 static void stats_clear(void *user
)
110 struct barvinok_stats
**stats
= (struct barvinok_stats
**)user
;
113 static int maxrays_init(void *user
)
115 unsigned *MaxRays
= (unsigned *)user
;
119 static int int_init_one(void *user
)
124 static int int_init_zero(void *user
)
129 static void print_version(void)
131 printf("%s", barvinok_version());
134 #ifdef USE_INCREMENTAL_BF
135 #define DEFAULT_SPECIALIZATION BV_SPECIALIZATION_BF
136 #elif defined USE_INCREMENTAL_DF
137 #define DEFAULT_SPECIALIZATION BV_SPECIALIZATION_DF
139 #define DEFAULT_SPECIALIZATION BV_SPECIALIZATION_RANDOM
142 static struct isl_arg_choice specialization
[] = {
143 {"bf", BV_SPECIALIZATION_BF
},
144 {"df", BV_SPECIALIZATION_DF
},
145 {"random", BV_SPECIALIZATION_RANDOM
},
146 {"todd", BV_SPECIALIZATION_TODD
},
150 static struct isl_arg_choice gbr
[] = {
152 {"glpk", BV_GBR_GLPK
},
154 #ifdef HAVE_LIBCDDGMP
161 static struct isl_arg_choice lp
[] = {
163 {"glpk", BV_LP_GLPK
},
165 #ifdef HAVE_LIBCDDGMP
167 {"cddf", BV_LP_CDDF
},
169 {"polylib", BV_LP_POLYLIB
},
174 static struct isl_arg_choice summation
[] = {
176 {"euler", BV_SUM_EULER
},
177 {"bernoulli", BV_SUM_BERNOULLI
},
178 {"laurent", BV_SUM_LAURENT
},
179 {"laurent_old", BV_SUM_LAURENT_OLD
},
183 static struct isl_arg_choice chambers
[] = {
184 {"polylib", BV_CHAMBERS_POLYLIB
},
185 #ifdef POINTS2TRIANGS_PATH
186 {"topcom", BV_CHAMBERS_TOPCOM
},
188 {"isl", BV_CHAMBERS_ISL
},
192 static struct isl_arg_choice hull
[] = {
193 {"gbr", BV_HULL_GBR
},
195 {"hilbert", BV_HULL_HILBERT
},
200 struct isl_arg barvinok_options_arg
[] = {
201 ISL_ARG_CHILD(struct barvinok_options
, isl
, "isl", isl_options_arg
, "isl options")
202 ISL_ARG_CHILD(struct barvinok_options
, approx
, NULL
,
203 approx_options_arg
, "polynomial approximation")
204 ISL_ARG_USER(struct barvinok_options
, stats
, &stats_init
, &stats_clear
)
205 ISL_ARG_USER(struct barvinok_options
, MaxRays
, &maxrays_init
, NULL
)
206 ISL_ARG_LONG(struct barvinok_options
, LLL_a
, 0, "lll-reduction-num", 1,
207 "LLL reduction parameter numerator")
208 ISL_ARG_LONG(struct barvinok_options
, LLL_b
, 0, "lll-reduction-den", 1,
209 "LLL reduction parameter denominator")
210 ISL_ARG_CHOICE(struct barvinok_options
, incremental_specialization
,
211 0, "specialization", specialization
, DEFAULT_SPECIALIZATION
, NULL
)
212 ISL_ARG_ULONG(struct barvinok_options
, max_index
, 0, "index", 1,
213 "maximal index of simple cones in decomposition")
214 ISL_ARG_BOOL(struct barvinok_options
, primal
, 0, "primal", 0, NULL
)
215 ISL_ARG_BOOL(struct barvinok_options
, lookup_table
, 0, "table", 0, NULL
)
216 ISL_ARG_USER(struct barvinok_options
, count_sample_infinite
, &int_init_one
, NULL
)
217 ISL_ARG_USER(struct barvinok_options
, try_Delaunay_triangulation
, &int_init_zero
, NULL
)
218 ISL_ARG_CHOICE(struct barvinok_options
, gbr_lp_solver
, 0, "gbr", gbr
,
219 BV_GBR_ISL
, "lp solver to use for basis reduction")
220 ISL_ARG_CHOICE(struct barvinok_options
, lp_solver
, 0, "lp", lp
,
221 BV_LP_ISL
, "lp solver to use")
222 ISL_ARG_CHOICE(struct barvinok_options
, summation
, 0, "summation", summation
,
223 BV_SUM_LAURENT
, NULL
)
224 ISL_ARG_CHOICE(struct barvinok_options
, chambers
, 0, "chamber-decomposition",
225 chambers
, BV_CHAMBERS_POLYLIB
, "tool to use for chamber decomposition")
226 ISL_ARG_CHOICE(struct barvinok_options
, integer_hull
, 0, "integer-hull",
227 hull
, BV_HULL_GBR
, NULL
)
228 ISL_ARG_USER(struct barvinok_options
, gbr_only_first
, &int_init_zero
, NULL
)
229 ISL_ARG_BOOL(struct barvinok_options
, print_stats
, 0, "print-stats", 0, NULL
)
230 ISL_ARG_BOOL(struct barvinok_options
, verbose
, 0, "verbose", 0, NULL
)
231 ISL_ARG_VERSION(print_version
)
235 ISL_ARG_DEF(barvinok_options
, struct barvinok_options
, barvinok_options_arg
)
236 ISL_ARG_CTX_DEF(barvinok_options
, struct barvinok_options
, barvinok_options_arg
)