我正在与 (https://github.com/ivmai/cudd https://github.com/ivmai/cudd),目标是进行以下重复过程:
(1) 输入:(连贯、非递减)布尔函数表达式
顶部 = a_1a_2a_3...+ x_1x_2x_3...+z_1z_2z_3...)。我正在使用的布尔值有
数千个变量 (ai...zj) 和数百个术语。
(2) 处理:将布尔值转换为BDD以简化最小项的计算,或者相互
独家割集(我们在可靠性世界中称之为)。
(3) 输出:拿我的一套。最小割集(minterm)。计算顶部事件概率
将 (2) 中找到的所有小项相加。
我找到了一种方法,使用劳动密集型手动 C 接口来构建布尔值。我还找到了如何使用优秀的 tulip-dd Py 接口来做到这一点,但无法使其像 cudd 那样扩展。
现在我希望通过 cudd 的 C++ 接口我可以两全其美(我的要求是不是太高了?)也就是说,tulip-dd 的便利性和 cudd 的可扩展性。这是一些示例代码。我失败的地方是在第 3 步中,打印出了 minterms,我以前可以在 C 中做到这一点。我如何使用 C++ 接口来做到这一点?我的具体想法和尝试请参见代码中的注释。
int main()
{
/*DdManager* gbm; /* Global BDD manager. I suppose we do not use this if we use the Cudd type below.*/
/* (1-2) Declare the vars and build the Boolean. Convert Boolean to BDD */
Cudd mgr(0, 0);
BDD a = mgr.bddVar();
BDD b = mgr.bddVar();
BDD c = mgr.bddVar();
BDD d = mgr.bddVar();
BDD e = mgr.bddVar();
BDD top = a*(b + c + d*e);
/* How to print out the equivalent to below, which prints out all minterms and their relevant vars in C.
But the mgr below has to be a *DManager ? If so, how to convert? */
Cudd_PrintDebug(mgr, BDD, 2, 4);
return 0
}
谢谢,
桂