join cud packages
This commit is contained in:
parent
5746edafaf
commit
e8e33e405a
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
/* ----------- Headers */
|
/* ----------- Headers */
|
||||||
|
|
||||||
#include "apt.h"
|
#include "apt.h"
|
||||||
|
|
||||||
/* ----------- Exported Function Prototypes */
|
/* ----------- Exported Function Prototypes */
|
||||||
|
|
@ -180,7 +180,7 @@ Queue q;
|
|||||||
** QueueDispose
|
** QueueDispose
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
PUBLIC
|
PUBLIC
|
||||||
#ifdef __ANSI_C__
|
#ifdef __ANSI_C__
|
||||||
void QueueDispose(Queue q, DisposeFunction f)
|
void QueueDispose(Queue q, DisposeFunction f)
|
||||||
#else
|
#else
|
||||||
@ -577,20 +577,20 @@ ComparisonFunction f;
|
|||||||
QueueItem item;
|
QueueItem item;
|
||||||
item = QueueNewItem(element,type);
|
item = QueueNewItem(element,type);
|
||||||
//fprintf(stderr,"searching for location using %p.\n",f);
|
//fprintf(stderr,"searching for location using %p.\n",f);
|
||||||
if (f == NULL){
|
if (f == NULL){
|
||||||
//fprintf(stderr,"comparing function is null %f \n",f);
|
//fprintf(stderr,"comparing function is null %f \n",f);
|
||||||
exit(1);
|
exit(1);
|
||||||
QueuePutItem(q,item);
|
QueuePutItem(q,item);
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
if (q->head == NULL) QueuePutItem(q,item);
|
if (q->head == NULL) QueuePutItem(q,item);
|
||||||
else {
|
else {
|
||||||
QueueItem p, lastp = NULL;
|
QueueItem p, lastp = NULL;
|
||||||
for (p = q->head; p != NULL; p = p->next) {
|
for (p = q->head; p != NULL; p = p->next) {
|
||||||
int cval =(*f)(element,p->element);
|
int cval =(*f)(element,p->element);
|
||||||
if (cval<0){
|
if (cval<0){
|
||||||
// fprintf(stderr,"%i <=> %i == %i\n",*((int *) element),*((int *)(p->element)),
|
// fprintf(stderr,"%i <=> %i == %i\n",*((int *) element),*((int *)(p->element)),
|
||||||
// cval);
|
// cval);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
lastp = p;
|
lastp = p;
|
@ -295,7 +295,7 @@ int main(int argc, char **arg) {
|
|||||||
alarm(params.timeout);
|
alarm(params.timeout);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (params.online) {
|
if (params.online) {
|
||||||
MyManager.manager = simpleBDDinit(0);
|
MyManager.manager = simpleBDDinit(0);
|
||||||
MyManager.t = HIGH(MyManager.manager);
|
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, "-bs") == 0 || strcmp(arg, "--bufsize") == 0) return 12;
|
||||||
if (strcmp(arg, "-pid") == 0 || strcmp(arg, "--pid") == 0) return 13;
|
if (strcmp(arg, "-pid") == 0 || strcmp(arg, "--pid") == 0) return 13;
|
||||||
if (strcmp(arg, "-ord") == 0 || strcmp(arg, "--order") == 0) return 14;
|
if (strcmp(arg, "-ord") == 0 || strcmp(arg, "--order") == 0) return 14;
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -762,10 +762,10 @@ double CalcProbability(extmanager MyManager, DdNode *Current) {
|
|||||||
double CalcExpectedCounts(extmanager * MyManager, DdNode *Current, char *query_id, int calcdown_needed) {
|
double CalcExpectedCounts(extmanager * MyManager, DdNode *Current, char *query_id, int calcdown_needed) {
|
||||||
|
|
||||||
// fprintf(stderr,"%%calcing up\n");
|
// 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,"%%result is %e\n",ret);
|
||||||
// fprintf(stderr,"%%calcing down\n");
|
// fprintf(stderr,"%%calcing down\n");
|
||||||
|
|
||||||
if (calcdown_needed != 0) {
|
if (calcdown_needed != 0) {
|
||||||
// double retd=CalcExpectedCountsDown(MyManager,Current, query_id);
|
// double retd=CalcExpectedCountsDown(MyManager,Current, query_id);
|
||||||
}
|
}
|
||||||
@ -818,7 +818,7 @@ void PrintNodeQueue(Queue q , extmanager MyManager){
|
|||||||
|
|
||||||
QueueIterator qiter = QueueIteratorNew(q, 1);
|
QueueIterator qiter = QueueIteratorNew(q, 1);
|
||||||
fprintf(stderr,"Queue %p is [", q);
|
fprintf(stderr,"Queue %p is [", q);
|
||||||
|
|
||||||
while (qiter->currentItem != NULL) {
|
while (qiter->currentItem != NULL) {
|
||||||
DdNode* val = (DdNode*) qiter->currentItem->element;
|
DdNode* val = (DdNode*) qiter->currentItem->element;
|
||||||
QueueIteratorAdvance(qiter);
|
QueueIteratorAdvance(qiter);
|
||||||
@ -846,7 +846,7 @@ int comparator(void *av, void *bv){
|
|||||||
if (temp < 0)
|
if (temp < 0)
|
||||||
ret= 1;
|
ret= 1;
|
||||||
else if (temp > 0)
|
else if (temp > 0)
|
||||||
ret= -1;
|
ret= -1;
|
||||||
// else //never return zero otherwise one is pruned away, or(?)
|
// else //never return zero otherwise one is pruned away, or(?)
|
||||||
// return 0;
|
// return 0;
|
||||||
if(LOG_EXPECTED){
|
if(LOG_EXPECTED){
|
||||||
@ -980,7 +980,7 @@ double CalcExpectedCountsDown(extmanager * MyManager, DdNode *Current, char *que
|
|||||||
hfound = GetNode(MyManager->his, MyManager->varmap.varstart, h) ;
|
hfound = GetNode(MyManager->his, MyManager->varmap.varstart, h) ;
|
||||||
curh = GetNodeVarNameDisp(MyManager->manager, MyManager->varmap, h);
|
curh = GetNodeVarNameDisp(MyManager->manager, MyManager->varmap, h);
|
||||||
curl = GetNodeVarNameDisp(MyManager->manager, MyManager->varmap, l);
|
curl = GetNodeVarNameDisp(MyManager->manager, MyManager->varmap, l);
|
||||||
|
|
||||||
if(LOG_EXPECTED){fprintf(stderr, "%s (%i)--> %s %s\n", curnode,(*node).index,curh,curl);}
|
if(LOG_EXPECTED){fprintf(stderr, "%s (%i)--> %s %s\n", curnode,(*node).index,curh,curl);}
|
||||||
/** low node */
|
/** low node */
|
||||||
if((*lfound).dvalue2<-0.1){ //only if not seen before == dvalue2=0 (almost) otherwise requing does not harm
|
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);
|
PrintNodeQueue(q,*MyManager);
|
||||||
fprintf(stderr,"-> %p\n",h);
|
fprintf(stderr,"-> %p\n",h);
|
||||||
}
|
}
|
||||||
QueuePutOnPriority(q, h, NODE_VALUE,fun);
|
QueuePutOnPriority(q, h, NODE_VALUE,fun);
|
||||||
(*hfound).dvalue2=0;
|
(*hfound).dvalue2=0;
|
||||||
}
|
}
|
||||||
(*hfound).dvalue2=(*hfound).dvalue2+(ivalue==0? dprob : (dprob*(tvalue)));
|
(*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);}
|
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){
|
if(ivalue==1){
|
||||||
(*pcnt)[GetIndex(node) - MyManager->varmap.varstart]+=dprob * tvalue * (*hfound).dvalue;
|
(*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);
|
//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
|
AddNode(MyManager->his, MyManager->varmap.varstart, MyManager->t, 1, 0, NULL);//}//needed in down
|
||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
if (Current == MyManager->f){
|
if (Current == MyManager->f){
|
||||||
// fprintf(stderr,"adding false \n");
|
// fprintf(stderr,"adding false \n");
|
||||||
// if ((Found = GetNode(MyManager->his, MyManager->varmap.varstart, Current)) == NULL) {
|
// if ((Found = GetNode(MyManager->his, MyManager->varmap.varstart, Current)) == NULL) {
|
||||||
AddNode(MyManager->his, MyManager->varmap.varstart, MyManager->f, 0, 0, NULL);//}//needed in down
|
AddNode(MyManager->his, MyManager->varmap.varstart, MyManager->f, 0, 0, NULL);//}//needed in down
|
@ -282,7 +282,7 @@ density_integral parse_density_integral_string(char *input, char *variablename)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (result.low>result.high) {
|
if (result.low>result.high) {
|
||||||
fprintf(stderr, "Error ar parsing the string %s in the function parse_density_integral_string\n",input);
|
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");
|
fprintf(stderr, "The value for low has to be larger than then value for high.\n");
|
@ -11,7 +11,7 @@ int compare_int (const int *a, const int *b)
|
|||||||
fprintf(stderr,"comparing %i %i \n",*a,*b);
|
fprintf(stderr,"comparing %i %i \n",*a,*b);
|
||||||
int temp = *a - *b;
|
int temp = *a - *b;
|
||||||
// return (a<b) ? 1 : -1;
|
// return (a<b) ? 1 : -1;
|
||||||
|
|
||||||
// return -1;
|
// return -1;
|
||||||
if (temp < 0)
|
if (temp < 0)
|
||||||
return 1;
|
return 1;
|
@ -693,10 +693,10 @@ int LoadVariableData(namedvars varmap, char *filename) {
|
|||||||
switch(idat) {
|
switch(idat) {
|
||||||
case 0:
|
case 0:
|
||||||
// http://www.cplusplus.com/reference/clibrary/cstdlib/strtod/
|
// http://www.cplusplus.com/reference/clibrary/cstdlib/strtod/
|
||||||
|
|
||||||
errno=0; // reset global error indicator
|
errno=0; // reset global error indicator
|
||||||
dvalue = strtod(dataread, &unparsed_string);
|
dvalue = strtod(dataread, &unparsed_string);
|
||||||
|
|
||||||
// check for errors
|
// check for errors
|
||||||
if (errno == ERANGE || unparsed_string == dataread) {
|
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);
|
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){
|
int my_index_calc(int varstart, DdNode *node){
|
||||||
if(Cudd_IsConstant(node)){
|
if(Cudd_IsConstant(node)){
|
||||||
return Cudd_V(node);
|
return Cudd_V(node);
|
||||||
}else{
|
}else{
|
||||||
int index = GetIndex(node) - varstart+2;
|
int index = GetIndex(node) - varstart+2;
|
||||||
@ -818,7 +818,7 @@ hisnode* GetNode(hisqueue *HisQueue, int varstart, DdNode *node) {
|
|||||||
index=my_index_calc(varstart,node);
|
index=my_index_calc(varstart,node);
|
||||||
// fprintf(stderr,"----- node retuned: %p <-> %i <-> %i \n",node,GetIndex(node),index);
|
// fprintf(stderr,"----- node retuned: %p <-> %i <-> %i \n",node,GetIndex(node),index);
|
||||||
//TODO: this must be check think not initialzied. Null check fails?
|
//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,"----- node retuned: %p <-> %i \n",node,GetIndex(node));
|
||||||
// fprintf(stderr,"returning %p ,,,,, %e\n", &(HisQueue[index].thenode[index]));
|
// fprintf(stderr,"returning %p ,,,,, %e\n", &(HisQueue[index].thenode[index]));
|
||||||
// return &(HisQueue[index].thenode[0]);}
|
// return &(HisQueue[index].thenode[0]);}
|
Reference in New Issue
Block a user