PT connection syntax

Starting from v0.4.0, SoyutNet supports a simpler syntax for connecting places and transitions by overloading operators >>, <<, >, <.

Graph format

_images/TestSingleBranch-test_labeled.png
  • Places are represented by circles with labels \(p_i\).

  • Transitions are represented by boxes with labels \(t_i\).

  • Arcs are arrows with labels in the form of ‘\(w ~ \{l_1, l_2, \dots \}\)’.
    • \(w\) is the weight of arc.

    • \(\{l_i\}\) is the arc labels meaning that a particular arc accepts tokens with a label in the set \(\{l_i\}\).

    • If arc has no label, then it has the default label ‘\(1 \{0\}\)’.

Single branch examples


            assert t1 == p1 >> t1
            assert t1 == t1 > p1

_images/TestSingleBranch-test_01_a.png

            assert p3 == (p1 >> t1 >> p2 >> t2 >> p3)

_images/TestSingleBranch-test_01_b.png

            assert p1 == (p1 > (t1 > (p2 > (t2 > p3))))

_images/TestSingleBranch-test_02.png

            assert p1 == (p3 << t2 << p2 << t1 << p1)

_images/TestSingleBranch-test_03.png

            assert p3 == (p3 < (t2 < (p2 < (t1 < p1))))
            assert p3 == (p3 > (t2 >> p2 >> t1 >> p1 >> t3))

_images/TestSingleBranch-test_04.png

            _ = net.Arc()
            assert p3 == (p1 >> _ >> t1 >> _ >> p2 >> t2 >> _ >> p3)

_images/TestSingleBranch-test_05.png

            _ = net.Arc()
            assert p1 == (p3 << _ << t2 << _ << p2 << _ << t1 << _ << p1)

_images/TestSingleBranch-test_06.png

            _ = net.Arc()
            assert t2 == (p1 > _ > t1 > _ > p2 > _ > t2 > _ > p3)

_images/TestSingleBranch-test_07.png

            _ = net.Arc()
            assert t1 == (p3 < _ < t2 < _ < p2 < _ < t1 < _ < p1)

_images/TestSingleBranch-test_08.png

            _ = net.Arc(weight=3, labels=[1, 2])
            assert t1 == (p3 < _ < t2 < _ < p2 < _ < t1 < _ < p1)

_images/TestSingleBranch-test_09.png

Multiple branch examples


            _ = net.Arc(weight=2)
            assert p2 == (p1 >> _ >> t1 >> p2)
            assert p3 == (t1 >> p3)

_images/TestSplit-test_01.png

            _ = net.Arc(weight=2)
            assert t1 == (p1 >> _ >> t1 > {
                p2,
                p3,
            })

_images/TestSplit-test_02.png

            _ = net.Arc(weight=2)
            assert t1 == (p1 >> _ >> t1 > {
                p3 << t2 << p2,
                p3,
            })

_images/TestSplit-test_03.png

            assert p1 == (((p1 > t1) > t2) > t3)
            assert p2 == (t1 >> p2)
            assert p3 == (t2 >> p3)
            assert p4 == (t3 >> p4)

_images/TestSplit-test_04.png

            assert p1 == (((p1 > {t1 > p2}) > {t2 > p3}) > {t3 > p4})

_images/TestSplit-test_05.png

            _ = net.Arc(weight=2)
            assert t1 == (p1 >> _ >> t1 > {
                p2 > (t2 > (p3 > (t4 > p4))),
                p3,
            })

_images/TestSplit-test_06.png

            a1 = net.Arc(labels=[1])
            a2 = net.Arc(labels=[2])
            a = net.Arc(labels=[1, 2], weight=2)

            assert t1 == (p1 >> a >> {
                t1 > a1 > p2,
                t1 > a2 > p3,
            })

_images/TestSplit-test_07.png

            a = lambda x: net.Arc(labels=[x])
            _ = net.Arc(labels=[1, 2, 3], weight=4)

            assert p1 == (p1 >> _ >> {
                t1 > a(1) > {
                    p2 > a(1) > {t2 > a(1) > p4},
                    p3 > a(2) > {t2 > a(2) > p5},
                },
                t1 > a(2) > {
                    p3 > a(1) > {t3 > a(1) > p4},
                },
            }) >> a(3) >> p1

_images/TestSplit-test_08.png