我正在尝试使用 CUDD 查找 Shared-BDD 中的节点总数。 我已经使用 BuDDy-2.4 编写了 C 代码并且运行良好但是当我使用 CUDD 而不是 BuDDy 时,我的程序显示错误。
我的 BuDDY C 文件是:
//BuDDY_C Code for Node Count:
#define X1 (a&b&c&d)|(!c&d&f)|(g&!g) //Define Function-1 here
#define X2 (a&b&d&!c)|(!c&!c&d)^(g) //Define Function-2 here
#include<bdd.h>
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
bdd z[2],a,b,c,d,e,f,g,h;
int i,INPUT=8,node_count,order[8]={2,5,1,6,0,4,3,7};
printf("\nGiven Variable Order:\t ");
for(i=0;i<INPUT;i++)
printf("%d \t",order[i]);
bdd_init(1000,100);
bdd_setvarnum(INPUT);
a = bdd_ithvar(order[0]); //Assign Variable order stored in order[0] to a
b = bdd_ithvar(order[1]); //Assign Variable order stored in order[1] to b
c = bdd_ithvar(order[2]); //Assign Variable order stored in order[2] to c
d = bdd_ithvar(order[3]); //Assign Variable order stored in order[3] to d
e = bdd_ithvar(order[4]); //Assign Variable order stored in order[4] to e
f = bdd_ithvar(order[5]); //Assign Variable order stored in order[5] to f
g = bdd_ithvar(order[6]); //Assign Variable order stored in order[6] to g
h = bdd_ithvar(order[7]); //Assign Variable order stored in order[7] to h
z[0]=X1;
z[1]=X2;
node_count=bdd_anodecount(z,2);
bdd_done();
printf("\n Total no of nodes are %d\n",node_count);
return 0;
}
我的 CUDD C 程序是:
//CUDD_C Code for Node Count
#define X1 (a&b&c&d)|(!c&d&f)|(g&!g) //Define Function-1 here
#define X2 (a&b&d&!c)|(!c&!c&d)^(g) //Define Function-2 here
#include <stdio.h>
#include <stdlib.h>
#include "cudd.h"
int main(void) {
DdNode *z[2],*a,*b,*c,*d,*e,*f,*g,*h;
int i,INPUT=8,node_count,order[8]={2,5,1,6,0,4,3,7};
printf("\nGiven Variable Order:\t ");
for(i=0;i<INPUT;i++)
printf("%d \t",order[i]);
DdManager * mgr = Cudd_Init(INPUT,0,CUDD_UNIQUE_SLOTS,CUDD_CACHE_SLOTS,0);
a = Cudd_bddIthVar(mgr, order[0]); //Assign Variable order stored in order[0] to a
b = Cudd_bddIthVar(mgr, order[1]); //Assign Variable order stored in order[0] to b
c = Cudd_bddIthVar(mgr, order[2]); //Assign Variable order stored in order[0] to c
d = Cudd_bddIthVar(mgr, order[3]); //Assign Variable order stored in order[0] to d
e = Cudd_bddIthVar(mgr, order[4]); //Assign Variable order stored in order[0] to e
f = Cudd_bddIthVar(mgr, order[5]); //Assign Variable order stored in order[0] to f
g = Cudd_bddIthVar(mgr, order[6]); //Assign Variable order stored in order[0] to g
h = Cudd_bddIthVar(mgr, order[7]); //Assign Variable order stored in order[0] to h
z[0]=X1;
z[1]=X2;
Cudd_Ref(z[0]);
Cudd_Ref(z[1]);
/*-----Calculate no of nodes and number of shared nodes*/
node_count= Cudd_SharingSize( z, 2);
printf("\n Total no of nodes are %d\n",node_count);
int err = Cudd_CheckZeroRef(mgr);
Cudd_Quit(mgr);
return err;
}
但是这个 CUDD C 程序显示错误
balal@balal-HP-H710:~/Desktop/cudd-3.0.0 $ g++ -o test test2_cudd.c -lbdd test2_cudd.c:在函数'<b>int main()'中: test2_cudd.c:2:14 : 错误: '<b>DdNode*' 和 '<b>DdNode*' 类型的无效操作数到二进制 '<b>operator&' #define X1 ( a&b &c&d)|(!c&d&f)|(g&!g) //在这里定义 Function-1 ~^~ test2_cudd.c:30:7: 注意:在宏 '<b>X1' 的扩展中 z[0]= X1 ; ^~ test2_cudd.c:2:25: 错误: '<b>bool' 和 '<b>DdNode*' 类型的无效操作数到二进制 '<b>operator&' #define X1 (a&b&c&d)|( !c&d &f)|(g&!g) //在这里定义 Function-1 ~~^~ test2_cudd.c:30:7: 注意:在宏 '<b>X1' 的扩展中 z[0]= X1 ; ^~ test2_cudd.c:2:33: 错误: '<b>DdNode*' 和 '<b>bool' 类型的无效操作数到二进制 '<b>operator&' #define X1 (a&b&c&d)|(!c&d&f)|( g&!g ) //在这里定义 Function-1 ~^~~ test2_cudd.c:30:7: 注意:在宏 '<b>X1' 的扩展中 z[0]= X1 ; ^~ test2_cudd.c:3:14: 错误: '<b>DdNode*' 和 '<b>DdNode*' 类型的无效操作数到二进制 '<b>operator&' #define X2 ( a&b &d&!c)|(!c&!c&d)^(g) //在这里定义 Function-2 ~^~ test2_cudd.c:31:7: 注意:在宏 '<b>X2' 的扩展中 z[1]= X2 ; ^~ test2_cudd.c:3:29: 错误: '<b>int' 和 '<b>DdNode*' 类型的无效操作数到二进制 '<b>operator&' #define X2 (a&b&d&!c)|( !c&!c&d )^(g) //在这里定义 Function-2 ~~~~~~^~ test2_cudd.c:31:7: 注意:在宏的扩展中 '<b >X2' z[1]= X2 ; ^~ balal@balal-HP-H710 : ~/Desktop/cudd-3.0.0 $