join cud packages

This commit is contained in:
Vítor Santos Costa 2015-06-19 01:00:18 +01:00
parent 5746edafaf
commit e8e33e405a
18 changed files with 23 additions and 23 deletions

View File

@ -15,7 +15,7 @@
/* ----------- Headers */
#include "apt.h"
#include "apt.h"
/* ----------- Exported Function Prototypes */

View File

@ -180,7 +180,7 @@ Queue q;
** QueueDispose
**
*/
PUBLIC
PUBLIC
#ifdef __ANSI_C__
void QueueDispose(Queue q, DisposeFunction f)
#else
@ -577,20 +577,20 @@ ComparisonFunction f;
QueueItem item;
item = QueueNewItem(element,type);
//fprintf(stderr,"searching for location using %p.\n",f);
if (f == NULL){
if (f == NULL){
//fprintf(stderr,"comparing function is null %f \n",f);
exit(1);
QueuePutItem(q,item);
}else {
if (q->head == NULL) QueuePutItem(q,item);
else {
QueueItem p, lastp = NULL;
for (p = q->head; p != NULL; p = p->next) {
int cval =(*f)(element,p->element);
if (cval<0){
// fprintf(stderr,"%i <=> %i == %i\n",*((int *) element),*((int *)(p->element)),
// cval);
if (cval<0){
// fprintf(stderr,"%i <=> %i == %i\n",*((int *) element),*((int *)(p->element)),
// cval);
break;
}
lastp = p;

View File

@ -295,7 +295,7 @@ int main(int argc, char **arg) {
alarm(params.timeout);
}
#endif
if (params.online) {
MyManager.manager = simpleBDDinit(0);
MyManager.t = HIGH(MyManager.manager);
@ -502,7 +502,7 @@ int argtype(const char *arg) {
if (strcmp(arg, "-bs") == 0 || strcmp(arg, "--bufsize") == 0) return 12;
if (strcmp(arg, "-pid") == 0 || strcmp(arg, "--pid") == 0) return 13;
if (strcmp(arg, "-ord") == 0 || strcmp(arg, "--order") == 0) return 14;
return -1;
}
@ -762,10 +762,10 @@ double CalcProbability(extmanager MyManager, DdNode *Current) {
double CalcExpectedCounts(extmanager * MyManager, DdNode *Current, char *query_id, int calcdown_needed) {
// fprintf(stderr,"%%calcing up\n");
double ret = CalcExpectedCountsUp(MyManager, Current, query_id);
double ret = CalcExpectedCountsUp(MyManager, Current, query_id);
// fprintf(stderr,"%%result is %e\n",ret);
// fprintf(stderr,"%%calcing down\n");
if (calcdown_needed != 0) {
// double retd=CalcExpectedCountsDown(MyManager,Current, query_id);
}
@ -818,7 +818,7 @@ void PrintNodeQueue(Queue q , extmanager MyManager){
QueueIterator qiter = QueueIteratorNew(q, 1);
fprintf(stderr,"Queue %p is [", q);
while (qiter->currentItem != NULL) {
DdNode* val = (DdNode*) qiter->currentItem->element;
QueueIteratorAdvance(qiter);
@ -846,7 +846,7 @@ int comparator(void *av, void *bv){
if (temp < 0)
ret= 1;
else if (temp > 0)
ret= -1;
ret= -1;
// else //never return zero otherwise one is pruned away, or(?)
// return 0;
if(LOG_EXPECTED){
@ -980,7 +980,7 @@ double CalcExpectedCountsDown(extmanager * MyManager, DdNode *Current, char *que
hfound = GetNode(MyManager->his, MyManager->varmap.varstart, h) ;
curh = GetNodeVarNameDisp(MyManager->manager, MyManager->varmap, h);
curl = GetNodeVarNameDisp(MyManager->manager, MyManager->varmap, l);
if(LOG_EXPECTED){fprintf(stderr, "%s (%i)--> %s %s\n", curnode,(*node).index,curh,curl);}
/** low node */
if((*lfound).dvalue2<-0.1){ //only if not seen before == dvalue2=0 (almost) otherwise requing does not harm
@ -1000,12 +1000,12 @@ double CalcExpectedCountsDown(extmanager * MyManager, DdNode *Current, char *que
PrintNodeQueue(q,*MyManager);
fprintf(stderr,"-> %p\n",h);
}
QueuePutOnPriority(q, h, NODE_VALUE,fun);
QueuePutOnPriority(q, h, NODE_VALUE,fun);
(*hfound).dvalue2=0;
}
(*hfound).dvalue2=(*hfound).dvalue2+(ivalue==0? dprob : (dprob*(tvalue)));
if(LOG_EXPECTED){fprintf(stderr, "h(%s)=%s %e %e %e\n", curnode,curh,(*hfound).dvalue2,tvalue,dprob);}
/** output expected counts current node */
/** output expected counts current node */
if(ivalue==1){
(*pcnt)[GetIndex(node) - MyManager->varmap.varstart]+=dprob * tvalue * (*hfound).dvalue;
//fprintf(stdout,"oec(%s,%s,%e). %% 1_1\n",query_id,dynvalue,dprob * tvalue * (*hfound).dvalue);
@ -1067,7 +1067,7 @@ double CalcExpectedCountsUp(extmanager * MyManager, DdNode *Current, char *query
AddNode(MyManager->his, MyManager->varmap.varstart, MyManager->t, 1, 0, NULL);//}//needed in down
return 1.0;
}
if (Current == MyManager->f){
if (Current == MyManager->f){
// fprintf(stderr,"adding false \n");
// if ((Found = GetNode(MyManager->his, MyManager->varmap.varstart, Current)) == NULL) {
AddNode(MyManager->his, MyManager->varmap.varstart, MyManager->f, 0, 0, NULL);//}//needed in down

View File

@ -282,7 +282,7 @@ density_integral parse_density_integral_string(char *input, char *variablename)
exit(EXIT_FAILURE);
}
if (result.low>result.high) {
fprintf(stderr, "Error ar parsing the string %s in the function parse_density_integral_string\n",input);
fprintf(stderr, "The value for low has to be larger than then value for high.\n");

View File

@ -11,7 +11,7 @@ int compare_int (const int *a, const int *b)
fprintf(stderr,"comparing %i %i \n",*a,*b);
int temp = *a - *b;
// return (a<b) ? 1 : -1;
// return -1;
if (temp < 0)
return 1;

View File

@ -693,10 +693,10 @@ int LoadVariableData(namedvars varmap, char *filename) {
switch(idat) {
case 0:
// http://www.cplusplus.com/reference/clibrary/cstdlib/strtod/
errno=0; // reset global error indicator
dvalue = strtod(dataread, &unparsed_string);
// check for errors
if (errno == ERANGE || unparsed_string == dataread) {
fprintf(stderr, "Error at file: %s. Variable: %s does not have a valid real value: %s.\n", filename, varname, dataread);
@ -792,7 +792,7 @@ void ReInitHistory(hisqueue *HisQueue, int varcnt) {
}
int my_index_calc(int varstart, DdNode *node){
if(Cudd_IsConstant(node)){
if(Cudd_IsConstant(node)){
return Cudd_V(node);
}else{
int index = GetIndex(node) - varstart+2;
@ -818,7 +818,7 @@ hisnode* GetNode(hisqueue *HisQueue, int varstart, DdNode *node) {
index=my_index_calc(varstart,node);
// fprintf(stderr,"----- node retuned: %p <-> %i <-> %i \n",node,GetIndex(node),index);
//TODO: this must be check think not initialzied. Null check fails?
// if (Cudd_IsConstant(node) ){
// if (Cudd_IsConstant(node) ){
// fprintf(stderr,"----- node retuned: %p <-> %i \n",node,GetIndex(node));
// fprintf(stderr,"returning %p ,,,,, %e\n", &(HisQueue[index].thenode[index]));
// return &(HisQueue[index].thenode[0]);}