Пример #1
0
    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);
        }
    }
Пример #2
0
 public static BDDNode MakeLiteral(this OBDD obdd, int index)
 {
     return(obdd.MakeNode(index, BDDNode.True, BDDNode.False));
 }