2 #include <barvinok/options.h>
3 #include <barvinok/util.h>
6 /* RANGE : normal range for evalutations (-RANGE -> RANGE) */
9 /* SRANGE : small range for evalutations */
12 /* if dimension >= BIDDIM, use SRANGE */
15 /* VSRANGE : very small range for evalutations */
18 /* if dimension >= VBIDDIM, use VSRANGE */
21 static struct argp_option argp_options
[] = {
22 { "verify", 'T', 0, 0 },
23 { "exact", 'E', 0, 0 },
24 { "print-all", 'A', 0, 0 },
25 { "continue-on-error", 'C', 0, 0 },
26 { "min", 'm', "int", 0 },
27 { "max", 'M', "int", 0 },
28 { "range", 'r', "int", 0 },
32 static error_t
parse_opt(int key
, char *arg
, struct argp_state
*state
)
34 struct verify_options
*options
= state
->input
;
40 options
->print_all
= 0;
41 options
->continue_on_error
= 0;
54 options
->print_all
= 1;
57 options
->continue_on_error
= 1;
60 options
->m
= atoi(arg
);
64 options
->M
= atoi(arg
);
68 options
->M
= atoi(arg
);
69 options
->m
= -options
->M
;
73 return ARGP_ERR_UNKNOWN
;
78 void verify_options_set_range(struct verify_options
*options
, int dim
)
84 else if (dim
>= BIGDIM
)
88 if (options
->M
== INT_MIN
)
90 if (options
->m
== INT_MAX
)
93 if (options
->verify
&& options
->m
> options
->M
) {
94 fprintf(stderr
,"Nothing to do: min > max !\n");
99 struct argp verify_argp
= {
100 argp_options
, parse_opt
, 0, 0
103 Polyhedron
*check_poly_context_scan(Polyhedron
*P
, Polyhedron
**C
,
105 const struct verify_options
*options
)
109 Polyhedron
*CC
, *CC2
, *CS
, *U
;
110 unsigned MaxRays
= options
->barvinok
->MaxRays
;
118 CC
= Polyhedron_Project(P
, nparam
);
120 CC2
= DomainIntersection(*C
, CC
, MaxRays
);
126 /* Intersect context with range */
127 MM
= Matrix_Alloc(2*nparam
, nparam
+2);
128 for (i
= 0; i
< nparam
; ++i
) {
129 value_set_si(MM
->p
[2*i
][0], 1);
130 value_set_si(MM
->p
[2*i
][1+i
], 1);
131 value_set_si(MM
->p
[2*i
][1+nparam
], -options
->m
);
132 value_set_si(MM
->p
[2*i
+1][0], 1);
133 value_set_si(MM
->p
[2*i
+1][1+i
], -1);
134 value_set_si(MM
->p
[2*i
+1][1+nparam
], options
->M
);
136 CC2
= AddConstraints(MM
->p
[0], 2*nparam
, CC
, options
->barvinok
->MaxRays
);
140 U
= Universe_Polyhedron(0);
141 CS
= Polyhedron_Scan(CC
, U
, MaxRays
& POL_NO_DUAL
? 0 : MaxRays
);
148 void check_poly_init(Polyhedron
*C
, struct verify_options
*options
)
152 if (options
->print_all
)
154 if (C
->Dimension
<= 0)
157 d
= options
->M
- options
->m
;
159 options
->st
= 1+d
/80;
162 for (i
= options
->m
; i
<= options
->M
; i
+= options
->st
)
168 /****************************************************/
169 /* function check_poly : */
170 /* scans the parameter space from Min to Max (all */
171 /* directions). Computes the number of points in */
172 /* the polytope using both methods, and compare them*/
173 /* returns 1 on success */
174 /****************************************************/
176 int check_poly(Polyhedron
*CS
, const struct check_poly_data
*data
,
177 int nparam
, int pos
, Value
*z
,
178 const struct verify_options
*options
)
181 if (!data
->check(data
, nparam
, z
, options
) && !options
->continue_on_error
)
188 ok
= !(lower_upper_bounds(1+pos
, CS
, z
-1, &LB
, &UB
));
190 for (; value_le(LB
, UB
); value_increment(LB
, LB
)) {
191 if (!options
->print_all
) {
192 int k
= VALUE_TO_INT(LB
);
193 if (!pos
&& !(k
% options
->st
)) {
199 value_assign(z
[pos
], LB
);
200 if (!check_poly(CS
->next
, data
, nparam
, pos
+1, z
, options
)) {
206 value_set_si(z
[pos
], 0);