Пример #1
0
    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);
        }
    }
Пример #2
0
    public void AddTransition()
    {
        const int numBits = 3;
        var       obdd    = new OBDD();
        var       root    = AddTransition(obdd, 0, 1, numBits);

        // example i = 0, j = 1, numBits = 3
        // binary i = 000, j = 001
        // interleave j2 i2 j1 i1 j0 i0
        //            0  0  0  0  1  0
        // variables  5  4  3  2  1  0

        using (var writer = new StringWriter())
        {
            root.ExportToGraphviz(writer);
            Debug.Log(writer);
        }

        using (var writer = new StringWriter())
        {
            obdd.ExportToGraphviz(writer);
            Debug.Log(writer);
        }
    }