示例#1
0
    public void MakeNot()
    {
        var obdd = new OBDD();

        var a = obdd.MakeLiteral(0);
        var b = obdd.MakeLiteral(1);

        Assert.IsNotNull(a);
        Assert.IsNotNull(b);
        Assert.AreNotEqual(a, b);

        var na = obdd.MakeNot(a);
        var nb = obdd.MakeNot(b);

        Assert.IsNotNull(na);
        Assert.IsNotNull(nb);
        Assert.AreNotEqual(na, nb);
        Assert.AreNotEqual(a, na);
        Assert.AreNotEqual(b, nb);

        var nna = obdd.MakeNot(na);
        var nnb = obdd.MakeNot(nb);

        Assert.IsNotNull(nna);
        Assert.IsNotNull(nnb);
        Assert.AreNotEqual(nna, nnb);

        // double negation cancels out
        Assert.AreEqual(a, nna);
        Assert.AreEqual(b, nnb);
    }
示例#2
0
    public void MakeLiteral()
    {
        var obdd = new OBDD();

        var a = obdd.MakeLiteral(0);
        var b = obdd.MakeLiteral(1);
        var c = obdd.MakeLiteral(2);

        Assert.IsNotNull(a);
        Assert.IsNotNull(b);
        Assert.IsNotNull(c);
        Assert.AreNotEqual(a, b);
        Assert.AreNotEqual(b, c);
        Assert.AreNotEqual(c, a);
    }
示例#3
0
    public void Restrict()
    {
        var obdd = new OBDD();

        var a  = obdd.MakeLiteral(0);
        var at = obdd.Restrict(a, 0, true);
        var af = obdd.Restrict(a, 0, false);

        Assert.AreEqual(BDDNode.True, at);
        Assert.AreEqual(BDDNode.False, af);
    }
示例#4
0
    private static BDDNode AddTransition(OBDD obdd, BDDNode node, int index, int numBits, int offset)
    {
        for (int i = 0; i < numBits; i++)
        {
            int literal  = i * 2 + offset;
            var variable = obdd.MakeLiteral(literal);

            bool hasBit = (index & (1 << i)) != 0;
            if (!hasBit)
            {
                variable = obdd.MakeNot(variable);
            }

            node = obdd.MakeAnd(node, variable);
        }

        return(node);
    }