public void Example() { // f(a,b,c) = (!a & !b & !c) | (a & b) | (b & c) var obdd = new OBDD(); var a = obdd.MakeNode(0, BDDNode.True, BDDNode.False); var b = obdd.MakeNode(1, BDDNode.True, BDDNode.False); var c = obdd.MakeNode(2, BDDNode.True, BDDNode.False); var na = obdd.MakeNot(a); var nb = obdd.MakeNot(b); var nc = obdd.MakeNot(c); var tmpAnd = obdd.MakeAnd(na, nb); var and1 = obdd.MakeAnd(tmpAnd, nc); var and2 = obdd.MakeAnd(a, b); var and3 = obdd.MakeAnd(b, c); var tmpOr = obdd.MakeOr(and1, and2); var or = obdd.MakeOr(tmpOr, and3); var root = or; using (var writer = new StringWriter()) { root.ExportToGraphviz(writer); Debug.Log(writer); } }
public void TransitionSystem() { const int numNodes = 7; const int numBits = 3; Assert.Less(numNodes, 1 << (numBits + 1)); var ts = new TransitionSystem(numNodes); ts.AddTransition(0, 1); ts.AddTransition(0, 2); ts.AddTransition(1, 3); ts.AddTransition(2, 4); ts.AddTransition(3, 3); ts.AddTransition(3, 5); ts.AddTransition(4, 4); ts.AddTransition(4, 5); ts.AddTransition(5, 5); ts.AddTransition(5, 6); ts.AddTransition(6, 6); var obdd = new OBDD(); var root = BDDNode.False; for (int i = 0; i < numNodes; i++) { for (int j = 0; j < numNodes; j++) { if (!ts.HasTransition(i, j)) { continue; } var transition = AddTransition(obdd, i, j, numBits); root = obdd.MakeOr(root, transition); } } using (var writer = new StringWriter()) { ts.ExportToGraphviz(writer, new IProposition[0]); Debug.Log(writer); } using (var writer = new StringWriter()) { root.ExportToGraphviz(writer); Debug.Log(writer); } using (var writer = new StringWriter()) { obdd.ExportToGraphviz(writer); Debug.Log(writer); } }