Esempio n. 1
0
    // destructive simplification procedure, prunes subtrees with too low counts
    long long int simplify_subtree(int pos, int divisor, int min_size, int indent) {
        PropertyDecisionNode &n = inner_node[pos];
        if (n.property == -1) {
            for (int i=0;i<indent;i++) v_printf(10,"  ");
            v_printf(10,"* leaf: count=%lli, size=%llu bits, bits per int: %f\n", (long long int)leaf_node[n.leafID].count, (unsigned long long int)leaf_node[n.leafID].realSize/5461, (leaf_node[n.leafID].count > 0 ? leaf_node[n.leafID].realSize/leaf_node[n.leafID].count*1.0/5461 : -1));
            if (leaf_node[n.leafID].count == 0) return -100; // avoid empty leafs by giving them an extra penalty
            return leaf_node[n.leafID].count;
        } else {
            for (int i=0;i<indent;i++) v_printf(10,"  ");
            v_printf(10,"* test: property %i, value > %i ?  (after %lli steps)\n", n.property, n.splitval, (long long int)n.count);
            long long int subtree_size = 0;
            subtree_size += simplify_subtree(n.childID, divisor, min_size, indent+1);
            subtree_size += simplify_subtree(n.childID+1, divisor, min_size, indent+1);
            n.count /= divisor;
            if (n.count > CONTEXT_TREE_MAX_COUNT) {
               n.count = CONTEXT_TREE_MAX_COUNT;
            }
            if (n.count < CONTEXT_TREE_MIN_COUNT) n.count=CONTEXT_TREE_MIN_COUNT;
            if (n.count > 0xf) n.count &= 0xfff8; // remove some lsb entropy
//            printf("%li COUNT\n",n.count);
            if (subtree_size < min_size) {
//                printf("  PRUNING THE ABOVE SUBTREE\n");
                n.property = -1; // procedure is destructive because the leafID is not set
            }
            return subtree_size;
        }
    }
Esempio n. 2
0
    // destructive simplification procedure, prunes subtrees with too low counts
    long long int simplify_subtree(int pos, int divisor, int min_size) {
        PropertyDecisionNode &n = inner_node[pos];
        if (n.property == -1) {
//            printf("* leaf %i : count=%lli, size=%llu bits, bits per int: %f\n", n.leafID, (long long int)leaf_node[n.leafID].count, (unsigned long long int)leaf_node[n.leafID].realSize/5461, (leaf_node[n.leafID].count > 0 ? leaf_node[n.leafID].realSize/leaf_node[n.leafID].count*1.0/5461 : -1));
            if (leaf_node[n.leafID].count == 0) return -100; // avoid empty leafs by giving them an extra penalty
            return leaf_node[n.leafID].count;
        } else {
//            printf("* split on prop %i at val %i after %lli steps\n", n.property, n.splitval, (long long int)n.count);
//            printf("* split on prop %i\n", n.property);
            long long int subtree_size = 0;
            subtree_size += simplify_subtree(n.childID, divisor, min_size);
            subtree_size += simplify_subtree(n.childID+1, divisor, min_size);
            n.count /= divisor;
            if (n.count > CONTEXT_TREE_MAX_COUNT) {
               n.count = CONTEXT_TREE_MAX_COUNT;
            }
            if (n.count < CONTEXT_TREE_MIN_COUNT) n.count=CONTEXT_TREE_MIN_COUNT;
//            printf("%li COUNT\n",n.count);
            if (subtree_size < min_size) {
//                printf("  PRUNING THE ABOVE SUBTREE\n");
                n.property = -1; // procedure is destructive because the leafID is not set
            }
            return subtree_size;
        }
    }
Esempio n. 3
0
 void simplify(int divisor=CONTEXT_TREE_COUNT_DIV, int min_size=CONTEXT_TREE_MIN_SUBTREE_SIZE) {
     v_printf(10,"TREE BEFORE SIMPLIFICATION:\n");
     simplify_subtree(0, divisor, min_size, 0);
 }
Esempio n. 4
0
 void simplify(int divisor=CONTEXT_TREE_COUNT_DIV, int min_size=CONTEXT_TREE_MIN_SUBTREE_SIZE) {
     simplify_subtree(0, divisor, min_size);
 }
Esempio n. 5
0
 void simplify(int divisor=CONTEXT_TREE_COUNT_DIV, int min_size=CONTEXT_TREE_MIN_SUBTREE_SIZE, int plane=0) {
     v_printf(10,"PLANE %i: TREE BEFORE SIMPLIFICATION:\n",plane);
     simplify_subtree(0, divisor, min_size, 0, plane);
 }