TestCppsoftpkgDeps::TestCppsoftpkgDeps(const char *uuid, const char *label) : Resource_impl(uuid, label), testCallbackResults() { std::string retval = retFunction(1); addProperty(prop_long, 0, "DCE:9d1e3621-27ca-4cd0-909d-90b7448b8f71", "prop_long", "readwrite", "null", "external", "configure"); addProperty(prop_str, "DCE:4e7c1977-5f53-4061-bae7-cb8c1072f4b7", "prop_str", "readwrite", "null", "external", "configure"); addProperty(seq_oct, "DCE:f877b9ee-a682-43a6-ba21-5ea980167f55", "seq_oct", "readwrite", "null", "external", "configure"); seq_oct.resize(4); addProperty(seq_foo, "DCE:e415de60-68cb-403e-812e-76f114731bb4", "prop_foo", "readwrite", "", "", "configure"); seq_foo.resize(2); seq_foo[0].item_bool = false; seq_foo[0].item_string = "First"; seq_foo[1].item_bool = true; seq_foo[1].item_string = "Second"; }
static int compute_prob(void) /* this is the function that implements the compute_prob predicate used in pp.pl */ { YAP_Term out,arg1,arg2,arg3,arg4; variables vars; expr expression; DdNode * function; DdManager * mgr; int nBVar,i,intBits,create_dot; FILE * file; DdNode * array[1]; double prob; char * onames[1]; char inames[1000][20]; char * names[1000]; tablerow * nodes; arg1=YAP_ARG1; arg2=YAP_ARG2; arg3=YAP_ARG3; arg4=YAP_ARG4; mgr=Cudd_Init(0,0,CUDD_UNIQUE_SLOTS,CUDD_CACHE_SLOTS,0); create_dot=YAP_IntOfTerm(arg4); vars=createVars(arg1,mgr,create_dot,inames); //Cudd_PrintInfo(mgr,stderr); /* automatic variable reordering, default method CUDD_REORDER_SIFT used */ //printf("status %d\n",Cudd_ReorderingStatus(mgr,&order)); //printf("order %d\n",order); Cudd_AutodynEnable(mgr,CUDD_REORDER_SAME); /* Cudd_AutodynEnable(mgr, CUDD_REORDER_RANDOM_PIVOT); printf("status %d\n",Cudd_ReorderingStatus(mgr,&order)); printf("order %d\n",order); printf("%d",CUDD_REORDER_RANDOM_PIVOT); */ expression=createExpression(arg2); function=retFunction(mgr,expression,vars); /* the BDD build by retFunction is converted to an ADD (algebraic decision diagram) because it is easier to interpret and to print */ //add=Cudd_BddToAdd(mgr,function); //Cudd_PrintInfo(mgr,stderr); if (create_dot) /* if specified by the user, a dot file for the BDD is written to cpl.dot */ { nBVar=vars.nBVar; for(i=0; i<nBVar; i++) names[i]=inames[i]; array[0]=function; onames[0]="Out"; file = open_file("cpl.dot", "w"); Cudd_DumpDot(mgr,1,array,names,onames,file); fclose(file); } nodes=init_table(vars.nBVar); intBits=sizeof(unsigned int)*8; prob=Prob(function,vars,nodes); out=YAP_MkFloatTerm(prob); destroy_table(nodes,vars.nBVar); Cudd_Quit(mgr); for(i=0; i<vars.nVar; i++) { free(vars.varar[i].probabilities); free(vars.varar[i].booleanVars); } free(vars.varar); free(vars.bVar2mVar); for(i=0; i<expression.nTerms; i++) { free(expression.terms[i].factors); } free(expression.terms); return(YAP_Unify(out,arg3)); }
static int compute_prob(void) /* this is the function that implements the compute_prob predicate used in pp.pl */ { YAP_Term out,arg1,arg2,arg3,arg4; array_t * variables,* expression, * bVar2mVar; DdNode * function, * add; DdManager * mgr; int nBVar,i,j,intBits,create_dot; FILE * file; DdNode * array[1]; char * onames[1]; char inames[1000][20]; char * names[1000]; GHashTable * nodes; /* hash table that associates nodes with their probability if already computed, it is defined in glib */ Cudd_ReorderingType order; arg1=YAP_ARG1; arg2=YAP_ARG2; arg3=YAP_ARG3; arg4=YAP_ARG4; mgr=Cudd_Init(0,0,CUDD_UNIQUE_SLOTS,CUDD_CACHE_SLOTS,0); variables=array_alloc(variable,0); bVar2mVar=array_alloc(int,0); create_dot=YAP_IntOfTerm(arg4); createVars(variables,arg1,mgr,bVar2mVar,create_dot,inames); //Cudd_PrintInfo(mgr,stderr); /* automatic variable reordering, default method CUDD_REORDER_SIFT used */ //printf("status %d\n",Cudd_ReorderingStatus(mgr,&order)); //printf("order %d\n",order); Cudd_AutodynEnable(mgr,CUDD_REORDER_SAME); /* Cudd_AutodynEnable(mgr, CUDD_REORDER_RANDOM_PIVOT); printf("status %d\n",Cudd_ReorderingStatus(mgr,&order)); printf("order %d\n",order); printf("%d",CUDD_REORDER_RANDOM_PIVOT); */ expression=array_alloc(array_t *,0); createExpression(expression,arg2); function=retFunction(mgr,expression,variables); /* the BDD build by retFunction is converted to an ADD (algebraic decision diagram) because it is easier to interpret and to print */ add=Cudd_BddToAdd(mgr,function); //Cudd_PrintInfo(mgr,stderr); if (create_dot) /* if specified by the user, a dot file for the BDD is written to cpl.dot */ { nBVar=array_n(bVar2mVar); for(i=0;i<nBVar;i++) names[i]=inames[i]; array[0]=add; onames[0]="Out"; file = open_file("cpl.dot", "w"); Cudd_DumpDot(mgr,1,array,names,onames,file); fclose(file); } nodes=g_hash_table_new(my_hash,my_equal); intBits=sizeof(unsigned int)*8; /* dividend is a global variable used by my_hash it is equal to an unsigned int with binary representation 11..1 */ dividend=1; for(j=1;j<intBits;j++) { dividend=(dividend<<1)+1; } out=YAP_MkFloatTerm(Prob(add,variables,bVar2mVar,nodes)); g_hash_table_foreach (nodes,dealloc,NULL); g_hash_table_destroy(nodes); Cudd_Quit(mgr); array_free(variables); array_free(bVar2mVar); array_free(expression); return(YAP_Unify(out,arg3)); }