barvinok_enumerate_e: extract out verification options
[barvinok.git] / options.c
blob2dad028473948787fe37b22ecfb7dfed9969165a
1 #include <unistd.h>
2 #include <barvinok/options.h>
3 #include <barvinok/util.h>
4 #include "argp.h"
5 #include "config.h"
7 #ifdef HAVE_GROWING_CHERNIKOVA
8 #define MAXRAYS (POL_NO_DUAL | POL_INTEGER)
9 #else
10 #define MAXRAYS 600
11 #endif
13 #define ALLOC(type) (type*)malloc(sizeof(type))
15 void barvinok_stats_clear(struct barvinok_stats *stats)
17 stats->unimodular_cones = 0;
20 void barvinok_stats_print(struct barvinok_stats *stats, FILE *out)
22 fprintf(out, "Unimodular cones: %d\n", stats->unimodular_cones);
25 struct barvinok_options *barvinok_options_new_with_defaults()
27 struct barvinok_options *options = ALLOC(struct barvinok_options);
28 if (!options)
29 return NULL;
31 barvinok_stats_clear(&options->stats);
33 options->LLL_a = 1;
34 options->LLL_b = 1;
36 options->MaxRays = MAXRAYS;
38 #ifdef USE_INCREMENTAL_BF
39 options->incremental_specialization = 2;
40 #elif defined USE_INCREMENTAL_DF
41 options->incremental_specialization = 1;
42 #else
43 options->incremental_specialization = 0;
44 #endif
45 options->primal = 0;
46 #ifdef USE_MODULO
47 options->lookup_table = 0;
48 #else
49 options->lookup_table = 1;
50 #endif
52 #ifdef HAVE_LIBGLPK
53 options->gbr_lp_solver = BV_GBR_GLPK;
54 #elif defined HAVE_LIBCDDGMP
55 options->gbr_lp_solver = BV_GBR_CDD;
56 #else
57 options->gbr_lp_solver = BV_GBR_NONE;
58 #endif
60 options->lexmin_emptiness_check = BV_LEXMIN_EMPTINESS_CHECK_SAMPLE;
61 options->lexmin_reduce = 1;
62 options->lexmin_polysign = BV_LEXMIN_POLYSIGN_POLYLIB;
64 return options;
67 struct argp_option barvinok_argp_options[] = {
68 { "primal", BV_OPT_PRIMAL, 0, 0 },
69 { "table", BV_OPT_TABLE, 0, 0 },
70 { "specialization", BV_OPT_SPECIALIZATION, "[bf|df|random]", 0 },
71 { "version", 'V', 0, 0 },
72 { 0 }
75 error_t barvinok_parse_opt(int key, char *arg, struct argp_state *state)
77 struct barvinok_options *options = state->input;
79 switch (key) {
80 case 'V':
81 printf(barvinok_version());
82 exit(0);
83 case BV_OPT_SPECIALIZATION:
84 if (!strcmp(arg, "bf"))
85 options->incremental_specialization = BV_SPECIALIZATION_BF;
86 else if (!strcmp(arg, "df"))
87 options->incremental_specialization = BV_SPECIALIZATION_DF;
88 else if (!strcmp(arg, "random"))
89 options->incremental_specialization = BV_SPECIALIZATION_RANDOM;
90 break;
91 case BV_OPT_PRIMAL:
92 options->primal = 1;
93 break;
94 default:
95 return ARGP_ERR_UNKNOWN;
97 return 0;
100 struct argp barvinok_argp = {
101 barvinok_argp_options, barvinok_parse_opt, 0, 0