iscc.c: type_of: drop unused variable
[barvinok.git] / options.c
blob9faa748163683d0c4c3a4a4cd2de198ceb1fcc40
1 #include <assert.h>
2 #include <unistd.h>
3 #include <isl/options.h>
4 #include <barvinok/options.h>
5 #include <barvinok/util.h>
6 #include "config.h"
8 #define ALLOC(type) (type*)malloc(sizeof(type))
9 #define MAXRAYS (POL_NO_DUAL | POL_INTEGER)
11 void barvinok_stats_clear(struct barvinok_stats *stats)
13 memset(stats, 0, sizeof(*stats));
16 void barvinok_stats_print(struct barvinok_stats *stats, FILE *out)
18 fprintf(out, "Base cones: %ld\n", stats->base_cones);
19 if (stats->volume_simplices)
20 fprintf(out, "Volume simplices: %ld\n", stats->volume_simplices);
21 if (stats->topcom_chambers) {
22 fprintf(out, "TOPCOM empty chambers: %ld\n",
23 stats->topcom_empty_chambers);
24 fprintf(out, "TOPCOM chambers: %ld\n", stats->topcom_chambers);
25 fprintf(out, "TOPCOM distinct chambers: %ld\n",
26 stats->topcom_distinct_chambers);
28 if (stats->gbr_solved_lps)
29 fprintf(out, "LPs solved during GBR: %ld\n", stats->gbr_solved_lps);
30 if (stats->bernoulli_sums)
31 fprintf(out, "Bernoulli sums: %ld\n", stats->bernoulli_sums);
34 static struct isl_arg_choice approx[] = {
35 {"lower", BV_APPROX_SIGN_LOWER},
36 {"upper", BV_APPROX_SIGN_UPPER},
37 {0}
40 static struct isl_arg_choice approx_method[] = {
41 {"drop", BV_APPROX_DROP},
42 {"scale", BV_APPROX_SCALE},
43 {"volume", BV_APPROX_VOLUME},
44 {"bernoulli", BV_APPROX_BERNOULLI},
45 {0}
48 static struct isl_arg_flags scale_flags[] = {
49 {"fast", BV_APPROX_SCALE_FAST, BV_APPROX_SCALE_FAST},
50 {"slow", BV_APPROX_SCALE_FAST, 0},
51 {"narrow", BV_APPROX_SCALE_NARROW | BV_APPROX_SCALE_NARROW2,
52 BV_APPROX_SCALE_NARROW},
53 {"narrow2", BV_APPROX_SCALE_NARROW | BV_APPROX_SCALE_NARROW2,
54 BV_APPROX_SCALE_NARROW2},
55 {"chamber", BV_APPROX_SCALE_CHAMBER, BV_APPROX_SCALE_CHAMBER},
56 {0}
59 static struct isl_arg_choice triangulation[] = {
60 {"lift", BV_VOL_LIFT},
61 {"vertex", BV_VOL_VERTEX},
62 {"barycenter", BV_VOL_BARYCENTER},
63 {0}
66 static int set_approx(void *opt, unsigned val)
68 struct barvinok_approximation_options *options;
69 options = (struct barvinok_approximation_options *)opt;
70 options->approximation = val;
71 if (options->method == BV_APPROX_NONE)
72 options->method = BV_APPROX_SCALE;
73 return 0;
76 static int set_method(void *opt, unsigned val)
78 struct barvinok_approximation_options *options;
79 options = (struct barvinok_approximation_options *)opt;
80 options->method = val;
81 if (options->approximation == BV_APPROX_SIGN_NONE)
82 options->approximation = BV_APPROX_SIGN_APPROX;
83 return 0;
86 ISL_ARGS_START(struct barvinok_approximation_options, approx_options_args)
87 ISL_ARG_USER_OPT_CHOICE(struct barvinok_approximation_options, approximation, 0,
88 "polynomial-approximation", approx, &set_approx,
89 BV_APPROX_SIGN_NONE, BV_APPROX_SIGN_APPROX, NULL)
90 ISL_ARG_USER_OPT_CHOICE(struct barvinok_approximation_options, method, 0,
91 "approximation-method", approx_method, &set_method,
92 BV_APPROX_NONE, BV_APPROX_DROP,
93 "method to use in polynomial approximation")
94 ISL_ARG_FLAGS(struct barvinok_approximation_options, scale_flags, 0,
95 "scale-options", scale_flags, 0, NULL)
96 ISL_ARG_CHOICE(struct barvinok_approximation_options, volume_triangulate, 0,
97 "volume-triangulation", triangulation, BV_VOL_VERTEX,
98 "type of triangulation to perform in volume computation")
99 ISL_ARGS_END
101 static int stats_init(void *user)
103 struct barvinok_stats **stats = (struct barvinok_stats **)user;
104 *stats = ALLOC(struct barvinok_stats);
105 if (*stats)
106 barvinok_stats_clear(*stats);
107 return *stats ? 0 : -1;
109 static void stats_clear(void *user)
111 struct barvinok_stats **stats = (struct barvinok_stats **)user;
112 free(*stats);
114 static int maxrays_init(void *user)
116 unsigned *MaxRays = (unsigned *)user;
117 *MaxRays = MAXRAYS;
118 return 0;
120 static int int_init_one(void *user)
122 *((int *)user) = 1;
123 return 0;
125 static int int_init_zero(void *user)
127 *((int *)user) = 0;
128 return 0;
130 static void print_version(void)
132 printf("%s", barvinok_version());
135 #ifdef USE_INCREMENTAL_BF
136 #define DEFAULT_SPECIALIZATION BV_SPECIALIZATION_BF
137 #elif defined USE_INCREMENTAL_DF
138 #define DEFAULT_SPECIALIZATION BV_SPECIALIZATION_DF
139 #else
140 #define DEFAULT_SPECIALIZATION BV_SPECIALIZATION_RANDOM
141 #endif
143 static struct isl_arg_choice specialization[] = {
144 {"bf", BV_SPECIALIZATION_BF},
145 {"df", BV_SPECIALIZATION_DF},
146 {"random", BV_SPECIALIZATION_RANDOM},
147 {"todd", BV_SPECIALIZATION_TODD},
151 static struct isl_arg_choice gbr[] = {
152 #ifdef HAVE_LIBGLPK
153 {"glpk", BV_GBR_GLPK},
154 #endif
155 #ifdef HAVE_LIBCDDGMP
156 {"cdd", BV_GBR_CDD},
157 #endif
158 {"isl", BV_GBR_ISL},
162 static struct isl_arg_choice lp[] = {
163 #ifdef HAVE_LIBGLPK
164 {"glpk", BV_LP_GLPK},
165 #endif
166 #ifdef HAVE_LIBCDDGMP
167 {"cdd", BV_LP_CDD},
168 {"cddf", BV_LP_CDDF},
169 #endif
170 {"polylib", BV_LP_POLYLIB},
171 {"isl", BV_LP_ISL},
175 static struct isl_arg_choice summation[] = {
176 {"box", BV_SUM_BOX},
177 {"euler", BV_SUM_EULER},
178 {"bernoulli", BV_SUM_BERNOULLI},
179 {"laurent", BV_SUM_LAURENT},
180 {"laurent_old", BV_SUM_LAURENT_OLD},
184 static struct isl_arg_choice chambers[] = {
185 {"polylib", BV_CHAMBERS_POLYLIB},
186 #ifdef POINTS2TRIANGS_PATH
187 {"topcom", BV_CHAMBERS_TOPCOM},
188 #endif
189 {"isl", BV_CHAMBERS_ISL},
193 static struct isl_arg_choice hull[] = {
194 {"gbr", BV_HULL_GBR},
195 #ifdef USE_ZSOLVE
196 {"hilbert", BV_HULL_HILBERT},
197 #endif
201 ISL_ARGS_START(struct barvinok_options, barvinok_options_args)
202 ISL_ARG_CHILD(struct barvinok_options, isl, "isl", &isl_options_args,
203 "isl options")
204 ISL_ARG_CHILD(struct barvinok_options, approx, NULL,
205 &approx_options_args, "polynomial approximation")
206 ISL_ARG_USER(struct barvinok_options, stats, &stats_init, &stats_clear)
207 ISL_ARG_USER(struct barvinok_options, MaxRays, &maxrays_init, NULL)
208 ISL_ARG_LONG(struct barvinok_options, LLL_a, 0, "lll-reduction-num", 1,
209 "LLL reduction parameter numerator")
210 ISL_ARG_LONG(struct barvinok_options, LLL_b, 0, "lll-reduction-den", 1,
211 "LLL reduction parameter denominator")
212 ISL_ARG_CHOICE(struct barvinok_options, incremental_specialization,
213 0, "specialization", specialization, DEFAULT_SPECIALIZATION, NULL)
214 ISL_ARG_ULONG(struct barvinok_options, max_index, 0, "index", 1,
215 "maximal index of simple cones in decomposition")
216 ISL_ARG_BOOL(struct barvinok_options, primal, 0, "primal", 0, NULL)
217 ISL_ARG_BOOL(struct barvinok_options, lookup_table, 0, "table", 0, NULL)
218 ISL_ARG_USER(struct barvinok_options, count_sample_infinite, &int_init_one, NULL)
219 ISL_ARG_USER(struct barvinok_options, try_Delaunay_triangulation, &int_init_zero, NULL)
220 ISL_ARG_CHOICE(struct barvinok_options, gbr_lp_solver, 0, "gbr", gbr,
221 BV_GBR_ISL, "lp solver to use for basis reduction")
222 ISL_ARG_CHOICE(struct barvinok_options, lp_solver, 0, "lp", lp,
223 BV_LP_ISL, "lp solver to use")
224 ISL_ARG_CHOICE(struct barvinok_options, summation, 0, "summation", summation,
225 BV_SUM_LAURENT, NULL)
226 ISL_ARG_CHOICE(struct barvinok_options, chambers, 0, "chamber-decomposition",
227 chambers, BV_CHAMBERS_POLYLIB, "tool to use for chamber decomposition")
228 ISL_ARG_CHOICE(struct barvinok_options, integer_hull, 0, "integer-hull",
229 hull, BV_HULL_GBR, NULL)
230 ISL_ARG_USER(struct barvinok_options, gbr_only_first, &int_init_zero, NULL)
231 ISL_ARG_BOOL(struct barvinok_options, print_stats, 0, "print-stats", 0, NULL)
232 ISL_ARG_BOOL(struct barvinok_options, verbose, 0, "verbose", 0, NULL)
233 ISL_ARG_VERSION(print_version)
234 ISL_ARGS_END
236 ISL_ARG_DEF(barvinok_options, struct barvinok_options, barvinok_options_args)
237 ISL_ARG_CTX_DEF(barvinok_options, struct barvinok_options,
238 barvinok_options_args)