Revert "bernstein/configure.in: remove redundant change to LD_LIBRARY_PATH"
[barvinok.git] / options.c
blob7a8e433744e88633593dc0db5d26b201566aef27
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 #ifndef HAVE_LIBGLPK
14 Vector *Polyhedron_Sample(Polyhedron *P, struct barvinok_options *options)
16 assert(0);
18 #endif
20 #define ALLOC(type) (type*)malloc(sizeof(type))
22 void barvinok_stats_clear(struct barvinok_stats *stats)
24 stats->unimodular_cones = 0;
27 void barvinok_stats_print(struct barvinok_stats *stats, FILE *out)
29 fprintf(out, "Unimodular cones: %d\n", stats->unimodular_cones);
32 struct barvinok_options *barvinok_options_new_with_defaults()
34 struct barvinok_options *options = ALLOC(struct barvinok_options);
35 if (!options)
36 return NULL;
38 barvinok_stats_clear(&options->stats);
40 options->LLL_a = 1;
41 options->LLL_b = 1;
43 options->MaxRays = MAXRAYS;
45 #ifdef USE_INCREMENTAL_BF
46 options->incremental_specialization = 2;
47 #elif defined USE_INCREMENTAL_DF
48 options->incremental_specialization = 1;
49 #else
50 options->incremental_specialization = 0;
51 #endif
52 options->primal = 0;
53 #ifdef USE_MODULO
54 options->lookup_table = 0;
55 #else
56 options->lookup_table = 1;
57 #endif
58 #ifdef HAVE_LIBGLPK
59 options->count_sample_infinite = 1;
60 #else
61 options->count_sample_infinite = 0;
62 #endif
64 #ifdef HAVE_LIBGLPK
65 options->gbr_lp_solver = BV_GBR_GLPK;
66 #elif defined HAVE_LIBCDDGMP
67 options->gbr_lp_solver = BV_GBR_CDD;
68 #else
69 options->gbr_lp_solver = BV_GBR_NONE;
70 #endif
72 options->lexmin_emptiness_check = BV_LEXMIN_EMPTINESS_CHECK_SAMPLE;
73 options->lexmin_reduce = 1;
74 options->lexmin_polysign = BV_LEXMIN_POLYSIGN_POLYLIB;
76 return options;
79 struct argp_option barvinok_argp_options[] = {
80 { "primal", BV_OPT_PRIMAL, 0, 0 },
81 { "table", BV_OPT_TABLE, 0, 0 },
82 { "specialization", BV_OPT_SPECIALIZATION, "[bf|df|random]", 0 },
83 { "gbr", BV_OPT_GBR, "[cdd]", 0,
84 "solver to use for basis reduction" },
85 { "version", 'V', 0, 0 },
86 { 0 }
89 error_t barvinok_parse_opt(int key, char *arg, struct argp_state *state)
91 struct barvinok_options *options = state->input;
93 switch (key) {
94 case 'V':
95 printf(barvinok_version());
96 exit(0);
97 case BV_OPT_SPECIALIZATION:
98 if (!strcmp(arg, "bf"))
99 options->incremental_specialization = BV_SPECIALIZATION_BF;
100 else if (!strcmp(arg, "df"))
101 options->incremental_specialization = BV_SPECIALIZATION_DF;
102 else if (!strcmp(arg, "random"))
103 options->incremental_specialization = BV_SPECIALIZATION_RANDOM;
104 break;
105 case BV_OPT_PRIMAL:
106 options->primal = 1;
107 break;
108 case BV_OPT_TABLE:
109 options->lookup_table = 1;
110 break;
111 case BV_OPT_GBR:
112 if (!strcmp(arg, "cdd"))
113 options->gbr_lp_solver = BV_GBR_CDD;
114 break;
115 default:
116 return ARGP_ERR_UNKNOWN;
118 return 0;
121 struct argp barvinok_argp = {
122 barvinok_argp_options, barvinok_parse_opt, 0, 0