TestProject1.TestMatrixPetriNet.TestMarkingFlowInComplexNet C# (CSharp) Method

TestMarkingFlowInComplexNet() private method

private TestMarkingFlowInComplexNet ( ) : void
return void
        public void TestMarkingFlowInComplexNet()
        {
            var m = new Marking(4,
                new Dictionary<int, int>
                    {
                        { (int)Places.p1, 0 },
                        { (int)Places.p2, 0 },
                        { (int)Places.p3, 0 },
                        { (int)Places.p4, 0 }
                    });
            var p = new MatrixPetriNet("p",
                new Dictionary<int, string> {
                    {(int)Places.p1, "p1"},
                    {(int)Places.p2, "p2"},
                    {(int)Places.p3, "p3"},
                    {(int)Places.p4, "p4"}
                },
                new Dictionary<int, string>
                    {
                        { (int)Transitions.t1, "t1" },
                        { (int)Transitions.t2, "t2" },
                        { (int)Transitions.t3, "t3" }
                    },
                new Dictionary<int, List<InArc>>(){
                    {(int)Transitions.t1, new List<InArc>(){new InArc((int)Places.p1)}},
                    {(int)Transitions.t2, new List<InArc>(){new InArc((int)Places.p2)}},
                    {(int)Transitions.t3, new List<InArc>(){new InArc((int)Places.p4)}}
                },
                new Dictionary<int, List<OutArc>>(){
                    {(int)Transitions.t1, new List<OutArc>(){new OutArc((int)Places.p2)}},
                    {(int)Transitions.t2, new List<OutArc>(){new OutArc((int)Places.p3)}},
                    {(int)Transitions.t3, new List<OutArc>(){new OutArc((int)Places.p2)}}
                });

            /*
             * This model is a petri net in this shape
             *
             * P1 --> T1 --> P2 --> T2 --> P3
             *                ^
             *                |
             *                T3
             *                ^
             *                |
             *                P4
             * */
            AssertMarkings(m, new Dictionary<Places, double>{
                { Places.p1, 0 },
                { Places.p2, 0 },
                { Places.p3, 0 },
                { Places.p4, 0 } });

            m[(int)Places.p1] = 1;
            AssertMarkings(m, new Dictionary<Places, double>{
                { Places.p1, 1 },
                { Places.p2, 0 },
                { Places.p3, 0 },
                { Places.p4, 0 } });

            m = p.Fire(m);
            AssertMarkings(m, new Dictionary<Places, double>{
                { Places.p1, 0 },
                { Places.p2, 1 },
                { Places.p3, 0 },
                { Places.p4, 0 } });

            m = p.Fire(m);
            AssertMarkings(m, new Dictionary<Places, double>{
                { Places.p1, 0 },
                { Places.p2, 0 },
                { Places.p3, 1 },
                { Places.p4, 0 } });

            m[(int)Places.p4] = 1;
            AssertMarkings(m, new Dictionary<Places, double>{
                { Places.p1, 0 },
                { Places.p2, 0 },
                { Places.p3, 1 },
                { Places.p4, 1 } });

            m = p.Fire(m);
            AssertMarkings(m, new Dictionary<Places, double>{
                { Places.p1, 0 },
                { Places.p2, 1 },
                { Places.p3, 1 },
                { Places.p4, 0 } });

            m = p.Fire(m);
            AssertMarkings(m, new Dictionary<Places, double>{
                { Places.p1, 0 },
                { Places.p2, 0 },
                { Places.p3, 2 },
                { Places.p4, 0 } });
        }