2 #include <barvinok/options.h>
3 #include <barvinok/util.h>
7 #ifdef HAVE_GROWING_CHERNIKOVA
8 #define MAXRAYS (POL_NO_DUAL | POL_INTEGER)
14 Vector
*Polyhedron_Sample(Polyhedron
*P
, struct barvinok_options
*options
)
20 #define ALLOC(type) (type*)malloc(sizeof(type))
22 void barvinok_stats_clear(struct barvinok_stats
*stats
)
24 stats
->base_cones
= 0;
27 void barvinok_stats_print(struct barvinok_stats
*stats
, FILE *out
)
29 fprintf(out
, "Base cones: %d\n", stats
->base_cones
);
32 struct barvinok_options
*barvinok_options_new_with_defaults()
34 struct barvinok_options
*options
= ALLOC(struct barvinok_options
);
38 options
->stats
= ALLOC(struct barvinok_stats
);
39 if (!options
->stats
) {
44 barvinok_stats_clear(options
->stats
);
49 options
->MaxRays
= MAXRAYS
;
51 #ifdef USE_INCREMENTAL_BF
52 options
->incremental_specialization
= 2;
53 #elif defined USE_INCREMENTAL_DF
54 options
->incremental_specialization
= 1;
56 options
->incremental_specialization
= 0;
58 options
->max_index
= 1;
61 options
->lookup_table
= 0;
63 options
->lookup_table
= 1;
66 options
->count_sample_infinite
= 1;
68 options
->count_sample_infinite
= 0;
71 options
->polynomial_approximation
= BV_POLAPPROX_NONE
;
74 options
->gbr_lp_solver
= BV_GBR_GLPK
;
75 #elif defined HAVE_LIBCDDGMP
76 options
->gbr_lp_solver
= BV_GBR_CDD
;
78 options
->gbr_lp_solver
= BV_GBR_NONE
;
84 void barvinok_options_free(struct barvinok_options
*options
)
90 struct argp_option barvinok_argp_options
[] = {
91 { "index", BV_OPT_MAXINDEX
, "int", 0,
92 "maximal index of simple cones in decomposition" },
93 { "primal", BV_OPT_PRIMAL
, 0, 0 },
94 { "table", BV_OPT_TABLE
, 0, 0 },
95 { "specialization", BV_OPT_SPECIALIZATION
, "[bf|df|random]", 0 },
96 { "polynomial-approximation",
98 "lower|upper|pre-lower|pre-upper|pre-approx", 0 },
99 { "gbr", BV_OPT_GBR
, "[cdd]", 0,
100 "solver to use for basis reduction" },
101 { "version", 'V', 0, 0 },
105 error_t
barvinok_parse_opt(int key
, char *arg
, struct argp_state
*state
)
107 struct barvinok_options
*options
= state
->input
;
111 printf(barvinok_version());
113 case BV_OPT_SPECIALIZATION
:
114 if (!strcmp(arg
, "bf"))
115 options
->incremental_specialization
= BV_SPECIALIZATION_BF
;
116 else if (!strcmp(arg
, "df"))
117 options
->incremental_specialization
= BV_SPECIALIZATION_DF
;
118 else if (!strcmp(arg
, "random"))
119 options
->incremental_specialization
= BV_SPECIALIZATION_RANDOM
;
125 options
->lookup_table
= 1;
128 if (!strcmp(arg
, "cdd"))
129 options
->gbr_lp_solver
= BV_GBR_CDD
;
131 case BV_OPT_MAXINDEX
:
132 options
->max_index
= strtoul(arg
, NULL
, 0);
134 case BV_OPT_POLAPPROX
:
135 if (!strcmp(arg
, "pre-lower"))
136 options
->polynomial_approximation
= BV_POLAPPROX_PRE_LOWER
;
137 else if (!strcmp(arg
, "pre-upper"))
138 options
->polynomial_approximation
= BV_POLAPPROX_PRE_UPPER
;
139 else if (!strcmp(arg
, "pre-approx"))
140 options
->polynomial_approximation
= BV_POLAPPROX_PRE_APPROX
;
141 else if (!strcmp(arg
, "lower"))
142 options
->polynomial_approximation
= BV_POLAPPROX_LOWER
;
143 else if (!strcmp(arg
, "upper"))
144 options
->polynomial_approximation
= BV_POLAPPROX_UPPER
;
147 return ARGP_ERR_UNKNOWN
;
152 struct argp barvinok_argp
= {
153 barvinok_argp_options
, barvinok_parse_opt
, 0, 0