introduce signed_cone struct
[barvinok.git] / options.c
blob7202c5e062586e9344aceed42198c9eafe128754
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
46 #ifdef HAVE_LIBGLPK
47 options->gbr_lp_solver = BV_GBR_GLPK;
48 #elif defined HAVE_LIBCDDGMP
49 options->gbr_lp_solver = BV_GBR_CDD;
50 #else
51 options->gbr_lp_solver = BV_GBR_NONE;
52 #endif
54 options->lexmin_emptiness_check = BV_LEXMIN_EMPTINESS_CHECK_SAMPLE;
55 options->lexmin_reduce = 1;
56 options->lexmin_polysign = BV_LEXMIN_POLYSIGN_POLYLIB;
58 return options;
61 struct argp_option barvinok_argp_options[] = {
62 { "specialization", BV_OPT_SPECIALIZATION, "[bf|df|random]", 0 },
63 { "version", 'V', 0, 0 },
64 { 0 }
67 error_t barvinok_parse_opt(int key, char *arg, struct argp_state *state)
69 struct barvinok_options *options = state->input;
71 switch (key) {
72 case 'V':
73 printf(barvinok_version());
74 exit(0);
75 case BV_OPT_SPECIALIZATION:
76 if (!strcmp(arg, "bf"))
77 options->incremental_specialization = BV_SPECIALIZATION_BF;
78 else if (!strcmp(arg, "df"))
79 options->incremental_specialization = BV_SPECIALIZATION_DF;
80 else if (!strcmp(arg, "random"))
81 options->incremental_specialization = BV_SPECIALIZATION_RANDOM;
82 break;
83 default:
84 return ARGP_ERR_UNKNOWN;
86 return 0;
89 struct argp barvinok_argp = {
90 barvinok_argp_options, barvinok_parse_opt, 0, 0