dpoly: add some documentation
[barvinok.git] / options.c
blob0a7a28e05008f61b2b2f8e6a5fcf0c15fe036fe8
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 return options;
75 struct argp_option barvinok_argp_options[] = {
76 { "primal", BV_OPT_PRIMAL, 0, 0 },
77 { "table", BV_OPT_TABLE, 0, 0 },
78 { "specialization", BV_OPT_SPECIALIZATION, "[bf|df|random]", 0 },
79 { "gbr", BV_OPT_GBR, "[cdd]", 0,
80 "solver to use for basis reduction" },
81 { "version", 'V', 0, 0 },
82 { 0 }
85 error_t barvinok_parse_opt(int key, char *arg, struct argp_state *state)
87 struct barvinok_options *options = state->input;
89 switch (key) {
90 case 'V':
91 printf(barvinok_version());
92 exit(0);
93 case BV_OPT_SPECIALIZATION:
94 if (!strcmp(arg, "bf"))
95 options->incremental_specialization = BV_SPECIALIZATION_BF;
96 else if (!strcmp(arg, "df"))
97 options->incremental_specialization = BV_SPECIALIZATION_DF;
98 else if (!strcmp(arg, "random"))
99 options->incremental_specialization = BV_SPECIALIZATION_RANDOM;
100 break;
101 case BV_OPT_PRIMAL:
102 options->primal = 1;
103 break;
104 case BV_OPT_TABLE:
105 options->lookup_table = 1;
106 break;
107 case BV_OPT_GBR:
108 if (!strcmp(arg, "cdd"))
109 options->gbr_lp_solver = BV_GBR_CDD;
110 break;
111 default:
112 return ARGP_ERR_UNKNOWN;
114 return 0;
117 struct argp barvinok_argp = {
118 barvinok_argp_options, barvinok_parse_opt, 0, 0