1 /* Program for testing the ranking function. */
3 This file is part of PolyLib.
5 PolyLib is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 PolyLib is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with PolyLib. If not, see <http://www.gnu.org/licenses/>.
24 #include <polylib/polylib.h>
25 #include <polylib/ranking.h>
27 int main( int argc
, char **argv
)
30 const char **param_name
= NULL
;
32 Polyhedron
*P
, *D
, *C
;
43 P
= Constraints2Polyhedron(M
, POL_NO_DUAL
);
46 D
= Constraints2Polyhedron(M
, POL_NO_DUAL
);
49 C
= Constraints2Polyhedron(M
, POL_NO_DUAL
);
52 nb_parms
= D
->Dimension
;
54 /* Read the name of the parameters */
55 param_name
= Read_ParamNames(stdin
,nb_parms
);
57 /* compute a polynomial approximation of the Ehrhart polynomial */
58 printf("============ Ranking function ============\n");
59 e
= Polyhedron_LexSmallerEnumerate(P
, D
, D
->Dimension
-C
->Dimension
,
66 for (en
=e
; en
; en
=en
->next
) {
67 Print_Domain(stdout
,en
->ValidityDomain
, param_name
);
68 print_evalue(stdout
,&en
->EP
, param_name
);
69 printf( "\n-----------------------------------\n" );
74 if( isatty(0) && nb_parms
!= 0)
75 { /* no tty input or no polyhedron -> no evaluation. */
76 printf("Evaluation of the Ehrhart polynomial :\n");
77 p
= (Value
*)malloc(sizeof(Value
) * (nb_parms
));
78 for(i
=0;i
<nb_parms
;i
++)
82 printf("Enter %d parameters : ",nb_parms
);
83 for(k
=0;k
<nb_parms
;++k
) {
87 fprintf(stdout
,"EP( ");
88 value_print(stdout
,VALUE_FMT
,p
[0]);
89 for(k
=1;k
<nb_parms
;++k
) {
91 value_print(stdout
,VALUE_FMT
,p
[k
]);
93 fprintf(stdout
," ) = ");
94 value_print(stdout
,VALUE_FMT
,*(tmp
=compute_poly(en
,p
)));
99 #endif /* EP_EVALUATION */
103 free_evalue_refs( &(e
->EP
) );
104 Polyhedron_Free( e
->ValidityDomain
);
109 Free_ParamNames(param_name
, nb_parms
);