2 #include <barvinok/options.h>
5 /* RANGE : normal range for evalutations (-RANGE -> RANGE) */
8 /* SRANGE : small range for evalutations */
11 /* if dimension >= BIDDIM, use SRANGE */
14 /* VSRANGE : very small range for evalutations */
17 /* if dimension >= VBIDDIM, use VSRANGE */
20 static struct argp_option argp_options
[] = {
21 { "verify", 'T', 0, 0 },
22 { "print-all", 'A', 0, 0 },
23 { "continue-on-error", 'C', 0, 0 },
24 { "min", 'm', "int", 0 },
25 { "max", 'M', "int", 0 },
26 { "range", 'r', "int", 0 },
30 static error_t
parse_opt(int key
, char *arg
, struct argp_state
*state
)
32 struct verify_options
*options
= state
->input
;
37 options
->print_all
= 0;
38 options
->continue_on_error
= 0;
48 options
->print_all
= 1;
51 options
->continue_on_error
= 1;
54 options
->m
= atoi(arg
);
58 options
->M
= atoi(arg
);
62 options
->M
= atoi(arg
);
63 options
->m
= -options
->M
;
67 return ARGP_ERR_UNKNOWN
;
72 void verify_options_set_range(struct verify_options
*options
, int dim
)
78 else if (dim
>= BIGDIM
)
82 if (options
->M
== INT_MIN
)
84 if (options
->m
== INT_MAX
)
87 if (options
->verify
&& options
->m
> options
->M
) {
88 fprintf(stderr
,"Nothing to do: min > max !\n");
93 struct argp verify_argp
= {
94 argp_options
, parse_opt
, 0, 0
97 Polyhedron
*check_poly_context_scan(Polyhedron
*C
,
98 const struct verify_options
*options
)
102 Polyhedron
*CC
, *CS
, *U
;
103 unsigned MaxRays
= options
->barvinok
->MaxRays
;
105 if (C
->Dimension
<= 0)
108 /* Intersect context with range */
109 MM
= Matrix_Alloc(2*C
->Dimension
, C
->Dimension
+2);
110 for (i
= 0; i
< C
->Dimension
; ++i
) {
111 value_set_si(MM
->p
[2*i
][0], 1);
112 value_set_si(MM
->p
[2*i
][1+i
], 1);
113 value_set_si(MM
->p
[2*i
][1+C
->Dimension
], -options
->m
);
114 value_set_si(MM
->p
[2*i
+1][0], 1);
115 value_set_si(MM
->p
[2*i
+1][1+i
], -1);
116 value_set_si(MM
->p
[2*i
+1][1+C
->Dimension
], options
->M
);
118 CC
= AddConstraints(MM
->p
[0], 2*C
->Dimension
, C
, options
->barvinok
->MaxRays
);
119 U
= Universe_Polyhedron(0);
120 CS
= Polyhedron_Scan(CC
, U
, MaxRays
& POL_NO_DUAL
? 0 : MaxRays
);
127 void check_poly_init(Polyhedron
*C
, struct verify_options
*options
)
131 if (options
->print_all
)
133 if (C
->Dimension
<= 0)
136 d
= options
->M
- options
->m
;
138 options
->st
= 1+d
/80;
141 for (i
= options
->m
; i
<= options
->M
; i
+= options
->st
)
147 /****************************************************/
148 /* function check_poly : */
149 /* scans the parameter space from Min to Max (all */
150 /* directions). Computes the number of points in */
151 /* the polytope using both methods, and compare them*/
152 /* returns 1 on success */
153 /****************************************************/
155 int check_poly(Polyhedron
*CS
, const struct check_poly_data
*data
,
156 int nparam
, int pos
, Value
*z
,
157 const struct verify_options
*options
)
160 if (!data
->check(data
, nparam
, z
, options
) && !options
->continue_on_error
)
167 ok
= !(lower_upper_bounds(1+pos
, CS
, z
-1, &LB
, &UB
));
169 for (; value_le(LB
, UB
); value_increment(LB
, LB
)) {
170 if (!options
->print_all
) {
171 int k
= VALUE_TO_INT(LB
);
172 if (!pos
&& !(k
% options
->st
)) {
178 value_assign(z
[pos
], LB
);
179 if (!check_poly(CS
->next
, data
, nparam
, pos
+1, z
, options
)) {
185 value_set_si(z
[pos
], 0);