Exemple #1
0
    def test_fire_transition(self):
        net = PetriNet()
        net.add_transition('A').add_transition('B')
        net.add_place(1).add_place(2).add_place(3).add_place(4)
        net.add_edge(1, -1).add_edge(-1, 3).add_edge(2, -1) \
         .add_edge(3, -2).add_edge(-2, 4)

        net.add_marking(1).add_marking(2)

        # ----------------------------------
        net.fire_transition(-1)
        transitions = net.all_enabled_transitions()
        self.assertListEqual(transitions, [-2])
Exemple #2
0
    def test_place_capacity(self):
        net = PetriNet()
        for i in range(1, 4):
            net.add_place(i)
        net.add_transition('A')
        net.add_transition('B')
        net.add_edge(1, -1)
        net.add_edge(-1, 2)
        net.add_edge(-1, 3)
        net.add_edge(2, -2)

        net.add_marking(1, 1)
        net.add_marking(2, 4)

        net.fire_transition(-1)

        print(net.get_exceeded_places())
        net.fire_transition(-2)
        net.fire_transition(-2)
        net.fire_transition(-2)
        net.fire_transition(-2)
        print(net.get_exceeded_places())