00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <stdio.h>
00021 #include <string.h>
00022 #include <stdlib.h>
00023
00024 #include <polylib/polylib.h>
00025 #include <polylib/ranking.h>
00026
00027 int main( int argc, char **argv)
00028 {
00029 int i;
00030 const char **param_name = NULL;
00031 Matrix *M;
00032 Polyhedron *P, *D, *C;
00033 Enumeration *e, *en;
00034
00035 int nb_parms;
00036
00037 #ifdef EP_EVALUATION
00038 Value *p, *tmp;
00039 int k;
00040 #endif
00041
00042 M = Matrix_Read();
00043 P = Constraints2Polyhedron(M, POL_NO_DUAL);
00044 Matrix_Free(M);
00045 M = Matrix_Read();
00046 D = Constraints2Polyhedron(M, POL_NO_DUAL);
00047 Matrix_Free(M);
00048 M = Matrix_Read();
00049 C = Constraints2Polyhedron(M, POL_NO_DUAL);
00050 Matrix_Free(M);
00051
00052 nb_parms = D->Dimension;
00053
00054
00055 param_name = Read_ParamNames(stdin,nb_parms);
00056
00057
00058 printf("============ Ranking function ============\n");
00059 e = Polyhedron_LexSmallerEnumerate(P, D, D->Dimension-C->Dimension,
00060 C, POL_NO_DUAL);
00061
00062 Polyhedron_Free(P);
00063 Polyhedron_Free(D);
00064 Polyhedron_Free(C);
00065
00066 for (en=e; en; en=en->next) {
00067 Print_Domain(stdout,en->ValidityDomain, param_name);
00068 print_evalue(stdout,&en->EP, param_name);
00069 printf( "\n-----------------------------------\n" );
00070 }
00071
00072
00073 #ifdef EP_EVALUATION
00074 if( isatty(0) && nb_parms != 0)
00075 {
00076 printf("Evaluation of the Ehrhart polynomial :\n");
00077 p = (Value *)malloc(sizeof(Value) * (nb_parms));
00078 for(i=0;i<nb_parms;i++)
00079 value_init(p[i]);
00080 FOREVER {
00081 fflush(stdin);
00082 printf("Enter %d parameters : ",nb_parms);
00083 for(k=0;k<nb_parms;++k) {
00084 scanf("%s",str);
00085 value_read(p[k],str);
00086 }
00087 fprintf(stdout,"EP( ");
00088 value_print(stdout,VALUE_FMT,p[0]);
00089 for(k=1;k<nb_parms;++k) {
00090 fprintf(stdout,",");
00091 value_print(stdout,VALUE_FMT,p[k]);
00092 }
00093 fprintf(stdout," ) = ");
00094 value_print(stdout,VALUE_FMT,*(tmp=compute_poly(en,p)));
00095 free(tmp);
00096 fprintf(stdout,"\n");
00097 }
00098 }
00099 #endif
00100
00101 while( e )
00102 {
00103 free_evalue_refs( &(e->EP) );
00104 Polyhedron_Free( e->ValidityDomain );
00105 en = e ->next;
00106 free( e );
00107 e = en;
00108 }
00109 Free_ParamNames(param_name, nb_parms);
00110 return 0;
00111 }