decomposer.cc: short_vector: negate lambda if z is negated
[barvinok.git] / options.c
blob43e4cd86ce846794efdd8524522ac68f0c8d0ea1
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;
47 #ifdef HAVE_LIBGLPK
48 options->gbr_lp_solver = BV_GBR_GLPK;
49 #elif defined HAVE_LIBCDDGMP
50 options->gbr_lp_solver = BV_GBR_CDD;
51 #else
52 options->gbr_lp_solver = BV_GBR_NONE;
53 #endif
55 options->lexmin_emptiness_check = BV_LEXMIN_EMPTINESS_CHECK_SAMPLE;
56 options->lexmin_reduce = 1;
57 options->lexmin_polysign = BV_LEXMIN_POLYSIGN_POLYLIB;
59 return options;
62 struct argp_option barvinok_argp_options[] = {
63 { "primal", BV_OPT_PRIMAL, 0, 0 },
64 { "specialization", BV_OPT_SPECIALIZATION, "[bf|df|random]", 0 },
65 { "version", 'V', 0, 0 },
66 { 0 }
69 error_t barvinok_parse_opt(int key, char *arg, struct argp_state *state)
71 struct barvinok_options *options = state->input;
73 switch (key) {
74 case 'V':
75 printf(barvinok_version());
76 exit(0);
77 case BV_OPT_SPECIALIZATION:
78 if (!strcmp(arg, "bf"))
79 options->incremental_specialization = BV_SPECIALIZATION_BF;
80 else if (!strcmp(arg, "df"))
81 options->incremental_specialization = BV_SPECIALIZATION_DF;
82 else if (!strcmp(arg, "random"))
83 options->incremental_specialization = BV_SPECIALIZATION_RANDOM;
84 break;
85 case BV_OPT_PRIMAL:
86 options->primal = 1;
87 break;
88 default:
89 return ARGP_ERR_UNKNOWN;
91 return 0;
94 struct argp barvinok_argp = {
95 barvinok_argp_options, barvinok_parse_opt, 0, 0