1

I have a memory problem with the cudd package. I've modified cudd to support custom constant nodes, for example some expression of the form (op x y), by adding a new field in the DdNode's type union.

I wrote a function that transforms a constant node of type bool to a 0/1-valued BDD node.

the transformation procedure works like Cudd_addApply with a slight difference: Ite is used to connect the returned values instead of cuddUniqueInter, because the return values might have a different index than the original children (sometimes even lower than the current level, causing assertions to fail)

the problem arised when I tried to recollect the intermediate results, this is how I managed the reference counts (NULL checks are removed):

auto n = Cudd_addIthVar(dd, index);
Cudd_Ref(n);
// T, E are transformations of children
res = (T == E) ? T : Cudd_addIte(dd, n, T, E);
Cudd_Ref(res);
Cudd_RecursiveDeref(dd, n); // remove temp results
Cudd_RecursiveDeref(dd, T);
Cudd_RecursiveDeref(dd, E);
cuddCacheInsert1(dd, op, f, res);
Cudd_Deref(res);
return (res);

this approach seems to pass Cudd_DebugCheck and Cudd_CheckKeys, but the ref counts of some internal nodes exceed unexpectedly a hundred and the ite operation hangs.

farmerzhang1
  • 41
  • 1
  • 4
  • A few things: (1) Are you sure that variable "n" is always *before* the variables of "T" and "E" in the variable order at the time of performing your operations? If not, Cudd_addIte(...) will not do what you want. Keep in mind that during Cudd_addIte, automatic variable reordering can occur. Your comment that "return values might have a different index than the original children" sound like you are not considering the effect of variable reordering, because the index is the logical variable number, which is different from where it is in the order. – DCTLib Oct 24 '22 at 08:29

0 Answers0