public void TestInputTransition() { var m = new Marking(1, new Dictionary <int, int> { { 0, 0 } }); var p = new MatrixPetriNet("p", new Dictionary <int, string> { { 0, "p0" } }, new Dictionary <int, string> { { 0, "Ti" } }, new Dictionary <int, List <InArc> >() { }, new Dictionary <int, List <OutArc> >() { { 0, new List <OutArc>() { new OutArc(0) } } }); Assert.AreEqual(0, m[0]); Assert.IsTrue(p.IsEnabled(0, m)); m = p.Fire(m); Assert.AreEqual(1, m[0]); Assert.IsTrue(p.IsEnabled(0, m)); m = p.Fire(m); Assert.AreEqual(2, m[0]); Assert.IsTrue(p.IsEnabled(0, m)); }
public void Test1to1Fire() { var m = new Marking(2, new Dictionary <int, int> { { 0, 1 }, { 1, 0 } }); var p = new MatrixPetriNet("p", new Dictionary <int, string> { { 0, "p0" }, { 1, "p1" } }, new Dictionary <int, string> { { 0, "t0" } }, new Dictionary <int, List <InArc> >() { { 0, new List <InArc>() { new InArc(0) } } }, new Dictionary <int, List <OutArc> >() { { 0, new List <OutArc>() { new OutArc(1) } } }); Assert.AreEqual(true, p.IsEnabled(0, m)); m = p.Fire(m); Assert.AreEqual(0, m[0]); Assert.AreEqual(1, m[1]); }
public void TestDrainTransition() { var m = new Marking(1, new Dictionary <int, int> { { 0, 5 } }); var p = new MatrixPetriNet("p", new Dictionary <int, string> { { 0, "p0" } }, new Dictionary <int, string> { { 0, "Ti" } }, new Dictionary <int, List <InArc> >() { { 0, new List <InArc>() { new InArc(0) } } }, new Dictionary <int, List <OutArc> >() { }); for (int i = 5; i >= 0; i--) { Assert.AreEqual(i, m[0]); Assert.AreEqual(i > 0, p.IsEnabled(0, m)); m = p.Fire(m); } }
public void TestFireConflictingTransitions() { var m = new Marking(3, new Dictionary <int, int> { { 0, 1 }, { 2, 0 }, { 1, 0 } }); var p = new MatrixPetriNet("p", new Dictionary <int, string> { { 0, "p0" }, { 1, "p1" }, { 2, "p2" } }, new Dictionary <int, string> { { 0, "t1" } }, new Dictionary <int, List <InArc> >() { { 0, new List <InArc>() { new InArc(0), new InArc(2) } } }, new Dictionary <int, List <OutArc> >() { { 0, new List <OutArc>() { new OutArc(1) } } }); Assert.AreEqual(false, p.IsEnabled(0, m)); m[2] = 1; Assert.AreEqual(true, p.IsEnabled(0, m)); }
public void Test2to1EnablementAndFiring() { var m = new Marking(3, new Dictionary <int, int> { { 0, 1 }, { 1, 0 }, { 2, 0 } }); var p = new MatrixPetriNet("p", new Dictionary <int, string> { { 0, "p0" }, { 1, "p1" }, { 2, "p2" } }, new Dictionary <int, string> { { 0, "t0" } }, new Dictionary <int, List <InArc> > { { 0, new List <InArc>() { new InArc(0), new InArc(2) } } }, new Dictionary <int, List <OutArc> > { { 0, new List <OutArc>() { new OutArc(1) } } }); Assert.AreEqual(false, p.IsEnabled(0, m)); m[2] = 1; Assert.AreEqual(true, p.IsEnabled(0, m)); m = p.Fire(m); Assert.AreEqual(0, m[0]); Assert.AreEqual(1, m[1]); Assert.AreEqual(0, m[2]); }