4 #include <isl/options.h>
5 #include <barvinok/options.h>
6 #include <barvinok/util.h>
9 #define ALLOC(type) (type*)malloc(sizeof(type))
10 #define MAXRAYS (POL_NO_DUAL | POL_INTEGER)
12 void barvinok_stats_clear(struct barvinok_stats
*stats
)
14 memset(stats
, 0, sizeof(*stats
));
17 void barvinok_stats_print(struct barvinok_stats
*stats
, FILE *out
)
19 fprintf(out
, "Base cones: %ld\n", stats
->base_cones
);
20 if (stats
->volume_simplices
)
21 fprintf(out
, "Volume simplices: %ld\n", stats
->volume_simplices
);
22 if (stats
->topcom_chambers
) {
23 fprintf(out
, "TOPCOM empty chambers: %ld\n",
24 stats
->topcom_empty_chambers
);
25 fprintf(out
, "TOPCOM chambers: %ld\n", stats
->topcom_chambers
);
26 fprintf(out
, "TOPCOM distinct chambers: %ld\n",
27 stats
->topcom_distinct_chambers
);
29 if (stats
->gbr_solved_lps
)
30 fprintf(out
, "LPs solved during GBR: %ld\n", stats
->gbr_solved_lps
);
31 if (stats
->bernoulli_sums
)
32 fprintf(out
, "Bernoulli sums: %ld\n", stats
->bernoulli_sums
);
35 static struct isl_arg_choice approx
[] = {
36 {"lower", BV_APPROX_SIGN_LOWER
},
37 {"upper", BV_APPROX_SIGN_UPPER
},
41 static struct isl_arg_choice approx_method
[] = {
42 {"drop", BV_APPROX_DROP
},
43 {"scale", BV_APPROX_SCALE
},
44 {"volume", BV_APPROX_VOLUME
},
45 {"bernoulli", BV_APPROX_BERNOULLI
},
49 static struct isl_arg_flags scale_flags
[] = {
50 {"fast", BV_APPROX_SCALE_FAST
, BV_APPROX_SCALE_FAST
},
51 {"slow", BV_APPROX_SCALE_FAST
, 0},
52 {"narrow", BV_APPROX_SCALE_NARROW
| BV_APPROX_SCALE_NARROW2
,
53 BV_APPROX_SCALE_NARROW
},
54 {"narrow2", BV_APPROX_SCALE_NARROW
| BV_APPROX_SCALE_NARROW2
,
55 BV_APPROX_SCALE_NARROW2
},
56 {"chamber", BV_APPROX_SCALE_CHAMBER
, BV_APPROX_SCALE_CHAMBER
},
60 static struct isl_arg_choice triangulation
[] = {
61 {"lift", BV_VOL_LIFT
},
62 {"vertex", BV_VOL_VERTEX
},
63 {"barycenter", BV_VOL_BARYCENTER
},
67 static int set_approx(void *opt
, unsigned val
)
69 struct barvinok_approximation_options
*options
;
70 options
= (struct barvinok_approximation_options
*)opt
;
71 options
->approximation
= val
;
72 if (options
->method
== BV_APPROX_NONE
)
73 options
->method
= BV_APPROX_SCALE
;
77 static int set_method(void *opt
, unsigned val
)
79 struct barvinok_approximation_options
*options
;
80 options
= (struct barvinok_approximation_options
*)opt
;
81 options
->method
= val
;
82 if (options
->approximation
== BV_APPROX_SIGN_NONE
)
83 options
->approximation
= BV_APPROX_SIGN_APPROX
;
87 ISL_ARGS_START(struct barvinok_approximation_options
, approx_options_args
)
88 ISL_ARG_USER_OPT_CHOICE(struct barvinok_approximation_options
, approximation
, 0,
89 "polynomial-approximation", approx
, &set_approx
,
90 BV_APPROX_SIGN_NONE
, BV_APPROX_SIGN_APPROX
, NULL
)
91 ISL_ARG_USER_OPT_CHOICE(struct barvinok_approximation_options
, method
, 0,
92 "approximation-method", approx_method
, &set_method
,
93 BV_APPROX_NONE
, BV_APPROX_DROP
,
94 "method to use in polynomial approximation")
95 ISL_ARG_FLAGS(struct barvinok_approximation_options
, scale_flags
, 0,
96 "scale-options", scale_flags
, 0, NULL
)
97 ISL_ARG_CHOICE(struct barvinok_approximation_options
, volume_triangulate
, 0,
98 "volume-triangulation", triangulation
, BV_VOL_VERTEX
,
99 "type of triangulation to perform in volume computation")
102 static int stats_init(void *user
)
104 struct barvinok_stats
**stats
= (struct barvinok_stats
**)user
;
105 *stats
= ALLOC(struct barvinok_stats
);
107 barvinok_stats_clear(*stats
);
108 return *stats
? 0 : -1;
110 static void stats_clear(void *user
)
112 struct barvinok_stats
**stats
= (struct barvinok_stats
**)user
;
115 static int maxrays_init(void *user
)
117 unsigned *MaxRays
= (unsigned *)user
;
121 static int int_init_one(void *user
)
126 static int int_init_zero(void *user
)
131 static void print_version(void)
133 printf("%s", barvinok_version());
136 #ifdef USE_INCREMENTAL_BF
137 #define DEFAULT_SPECIALIZATION BV_SPECIALIZATION_BF
138 #elif defined USE_INCREMENTAL_DF
139 #define DEFAULT_SPECIALIZATION BV_SPECIALIZATION_DF
141 #define DEFAULT_SPECIALIZATION BV_SPECIALIZATION_RANDOM
144 static struct isl_arg_choice specialization
[] = {
145 {"bf", BV_SPECIALIZATION_BF
},
146 {"df", BV_SPECIALIZATION_DF
},
147 {"random", BV_SPECIALIZATION_RANDOM
},
148 {"todd", BV_SPECIALIZATION_TODD
},
152 static struct isl_arg_choice gbr
[] = {
154 {"glpk", BV_GBR_GLPK
},
156 #ifdef HAVE_LIBCDDGMP
163 static struct isl_arg_choice lp
[] = {
165 {"glpk", BV_LP_GLPK
},
167 #ifdef HAVE_LIBCDDGMP
169 {"cddf", BV_LP_CDDF
},
171 {"polylib", BV_LP_POLYLIB
},
176 static struct isl_arg_choice summation
[] = {
178 {"euler", BV_SUM_EULER
},
179 {"bernoulli", BV_SUM_BERNOULLI
},
180 {"laurent", BV_SUM_LAURENT
},
181 {"laurent_old", BV_SUM_LAURENT_OLD
},
185 static struct isl_arg_choice chambers
[] = {
186 {"polylib", BV_CHAMBERS_POLYLIB
},
187 #ifdef POINTS2TRIANGS_PATH
188 {"topcom", BV_CHAMBERS_TOPCOM
},
190 {"isl", BV_CHAMBERS_ISL
},
194 static struct isl_arg_choice hull
[] = {
195 {"gbr", BV_HULL_GBR
},
197 {"hilbert", BV_HULL_HILBERT
},
202 ISL_ARGS_START(struct barvinok_options
, barvinok_options_args
)
203 ISL_ARG_CHILD(struct barvinok_options
, isl
, "isl", &isl_options_args
,
205 ISL_ARG_CHILD(struct barvinok_options
, approx
, NULL
,
206 &approx_options_args
, "polynomial approximation")
207 ISL_ARG_USER(struct barvinok_options
, stats
, &stats_init
, &stats_clear
)
208 ISL_ARG_USER(struct barvinok_options
, MaxRays
, &maxrays_init
, NULL
)
209 ISL_ARG_LONG(struct barvinok_options
, LLL_a
, 0, "lll-reduction-num", 1,
210 "LLL reduction parameter numerator")
211 ISL_ARG_LONG(struct barvinok_options
, LLL_b
, 0, "lll-reduction-den", 1,
212 "LLL reduction parameter denominator")
213 ISL_ARG_CHOICE(struct barvinok_options
, incremental_specialization
,
214 0, "specialization", specialization
, DEFAULT_SPECIALIZATION
, NULL
)
215 ISL_ARG_ULONG(struct barvinok_options
, max_index
, 0, "index", 1,
216 "maximal index of simple cones in decomposition")
217 ISL_ARG_BOOL(struct barvinok_options
, primal
, 0, "primal", 0, NULL
)
218 ISL_ARG_BOOL(struct barvinok_options
, lookup_table
, 0, "table", 0, NULL
)
219 ISL_ARG_USER(struct barvinok_options
, count_sample_infinite
, &int_init_one
, NULL
)
220 ISL_ARG_USER(struct barvinok_options
, try_Delaunay_triangulation
, &int_init_zero
, NULL
)
221 ISL_ARG_CHOICE(struct barvinok_options
, gbr_lp_solver
, 0, "gbr", gbr
,
222 BV_GBR_ISL
, "lp solver to use for basis reduction")
223 ISL_ARG_CHOICE(struct barvinok_options
, lp_solver
, 0, "lp", lp
,
224 BV_LP_ISL
, "lp solver to use")
225 ISL_ARG_CHOICE(struct barvinok_options
, summation
, 0, "summation", summation
,
226 BV_SUM_LAURENT
, NULL
)
227 ISL_ARG_CHOICE(struct barvinok_options
, chambers
, 0, "chamber-decomposition",
228 chambers
, BV_CHAMBERS_POLYLIB
, "tool to use for chamber decomposition")
229 ISL_ARG_CHOICE(struct barvinok_options
, integer_hull
, 0, "integer-hull",
230 hull
, BV_HULL_GBR
, NULL
)
231 ISL_ARG_USER(struct barvinok_options
, gbr_only_first
, &int_init_zero
, NULL
)
232 ISL_ARG_BOOL(struct barvinok_options
, print_stats
, 0, "print-stats", 0, NULL
)
233 ISL_ARG_BOOL(struct barvinok_options
, verbose
, 0, "verbose", 0, NULL
)
234 ISL_ARG_VERSION(print_version
)
237 ISL_ARG_DEF(barvinok_options
, struct barvinok_options
, barvinok_options_args
)
238 ISL_ARG_CTX_DEF(barvinok_options
, struct barvinok_options
,
239 barvinok_options_args
)