makeVary(parentIndex, v, start, numRecord, dataPtr);
boolean status;
if((status = varyVectorPtr.vector_pushBack(varyPtr)) != true) {
- System.out.println("varyVectorPtr.vector_pushBack != true");
+ System.out.println("Assert failed: varyVectorPtr.vector_pushBack != true");
System.exit(0);
}
}
public void
adtree_make (Data dataPtr)
{
- int numRecord = dataPtr.numRecord;
numVar = dataPtr.numVar;
numRecord = dataPtr.numRecord;
dataPtr.data_sort(0, numRecord, 0);
Vector_t queryVectorPtr,
int lastQueryIndex)
{
- System.out.println("DEBUG: Starting getCount()");
if (nodePtr == null) {
- System.out.println("DEBUG: exiting getCount() at point 1, count= 0");
return 0;
}
int nodeIndex = nodePtr.index;
if (nodeIndex >= lastQueryIndex) {
- System.out.println("DEBUG: exiting getCount() at point 2, count= "+ nodePtr.count);
return nodePtr.count;
}
Query queryPtr = (Query)(queryVectorPtr.vector_at(q));
if (queryPtr == null) {
- System.out.println("DEBUG: exiting getCount() at point 3, count= "+ nodePtr.count);
return nodePtr.count;
}
int queryIndex = queryPtr.index;
if(queryIndex > lastQueryIndex) {
- System.out.println("Assert failed");
+ System.out.println("Assert failed: queryIndex > lastQueryIndex in getCount()");
System.exit(0);
}
queryVectorPtr.vector_at(qq));
}
}
- System.out.println("DEBUG: Calling adtree_getCount, HERE1");
+
int superCount = adtree_getCount(superQueryVectorPtr);
superQueryVectorPtr.vector_free();
int invertCount;
if (queryValue == 0) {
queryPtr.value = 1;
- System.out.println("DEBUG: Calling adtree_getCount, HERE2");
invertCount = getCount(nodePtr,
i,
q,
queryPtr.value = 0;
} else {
queryPtr.value = 0;
- System.out.println("DEBUG: Calling adtree_getCount, HERE3");
invertCount = getCount(nodePtr,
i,
q,
} else {
if (queryValue == 0) {
- System.out.println("DEBUG: Calling adtree_getCount, HERE4");
count += getCount(varyPtr.zeroNodePtr,
(i + 1),
(q + 1),
queryVectorPtr,
lastQueryIndex);
} else if (queryValue == 1) {
- System.out.println("DEBUG: Calling adtree_getCount, HERE5");
count += getCount(varyPtr.oneNodePtr,
(i + 1),
(q + 1),
queryVectorPtr,
lastQueryIndex);
} else { /* QUERY_VALUE_WILDCARD */
- System.out.println("Program shouldn't get here"); // catch bugs in learner
+ System.out.println("Adtree_getCount Program shouldn't get here"); // catch bugs in learner
System.exit(0);
}
}
- System.out.println("DEBUG: exiting getCount() at point 4, count= "+ count);
return count;
}
boolean status = learnerPtr.netPtr.net_isCycle();
if(status) {
- System.out.println("System has an incorrect result");
+ System.out.println("Assert failed: system has an incorrect result");
System.exit(0);
}
#ifndef SIMULATOR
float learnScore = learnerPtr.learner_score();
- System.out.println("Learn score= " + learnScore);
+ System.out.println("Learn score= " + (double)learnScore);
#endif
- System.out.println("Actual score= " + actualScore);
+ System.out.println("Actual score= " + (double)actualScore);
/*
* Clean up
numVar,
numVar,
offset);
+
}
int parentCount = adtreePtr.adtree_getCount(parentQueryVectorPtr);
if(parentCount < count || parentCount <= 0) {
- System.out.println("Assert failed for computeSpecificLocalLogLikelihood()");
System.exit(0);
}
float fval = (float)(probability * (Math.log((double)count/ (double)parentCount)));
+
return fval;
}
int numTotalParent = 0;
float logLikelihood = 0.0f;
- //System.out.println("DEBUG: before logLikelihood= " + logLikelihood);
for (int v = 0; v < numVar; v++) {
IntList parentIdListPtr = netPtr.net_getParentIdListPtr(v);
numTotalParent += parentIdListPtr.list_getSize();
-
populateQueryVectors(netPtr,
v,
queries,
logLikelihood += localLogLikelihood;
}
- //System.out.println("DEBUG: after logLikelihood= " + logLikelihood);
queryVectorPtr.vector_free();
parentQueryVectorPtr.vector_free();
queries = null;
int stkptr = 0;
- start = 0;
int lo = start;
int hi = start + (width * (num - 1));
pv.hi = hi;
pv.width = width;
pv.n = n;
- pv.offset = offset;
int typeflag;
/**
* debug
**/
- //System.out.println("DEBUG: lo= "+ pv.lo + " hi= " + pv.hi + " width= " + pv.width+ " offset= " + pv.offset + " n= " + pv.n + " size= " + size);
+ //System.out.println("DEBUG: lo= "+ pv.lo + " hi= " + pv.hi + " width= " + pv.width+ " offset= " + offset + " n= " + pv.n + " size= " + size);
if (size <= CUTOFF) {
- shortsort(base, pv.lo, pv.hi, pv.width, pv.n, pv.offset);
+ shortsort(base, pv.lo, pv.hi, pv.width, pv.n, offset);
} else {
while(true) {
do {
pv.loguy += pv.width;
- } while (pv.loguy <= pv.hi && cmp(base, pv.loguy, pv.lo, pv.n, pv.offset) <= 0);
+ } while (pv.loguy <= pv.hi && cmp(base, pv.loguy, pv.lo, pv.n, offset) <= 0);
do {
pv.higuy -= pv.width;
- } while (pv.higuy > pv.lo && cmp(base, pv.higuy, pv.lo, pv.n, pv.offset) >= 0);
+ } while (pv.higuy > pv.lo && cmp(base, pv.higuy, pv.lo, pv.n, offset) >= 0);
if (pv.higuy < pv.loguy) {
break;
}
int hi;
int width;
int n;
- int offset;
int loguy;
int higuy;
int max;
hi = 0;
width = 0;
n = 0;
- offset = 0;
loguy = 0;
higuy = 0;
max = 0;
swap(i, j, a);
}
+ /* ===========================================
+ * compareQuery
+ * -- Want smallest ID first
+ * -- For vector_sort
+ * ===========================================
+ */
public boolean less(Object x, Object y) {
Query aQueryPtr = (Query) x;
Query bQueryPtr = (Query) y;
int newCapacity = capacity * 2;
Object[] newElements = new Object[newCapacity];
- //void** newElements = (void**)malloc(newCapacity * sizeof(void*));
if (newElements == null) {
return false;
}
public void
vector_sort ()
{
- //qsort.sort(elements, 0, (elements.length - 1));
- qsort.sort(elements);
- //qsort(elements, size, 4, compare);
+ qsort.sort(elements, 0, size);
}
/* =============================================================================