<jupyter_start><jupyter_text>Petri Net Traversal<jupyter_code>import numpy as np
class MatrixPetriNet:
    __slots__ = ("_mo","_pre","_post","_mk","_last_mk","_enabled")
    def __init__(self,
        M_o = np.array([
                        [2],
                        [0],
                        [0],
                        [0],
                        [0]
                        ]),
        Pre = np.array([
                        [2,0,0,0,0],
                        [0,1,0,0,0],
                        [0,0,1,0,0],
                        [0,0,0,1,0],
                        [0,0,0,0,1]
                        ]),
        Post = np.array([
                        [0,0,0,1,1],
                        [1,0,0,0,0],
                        [1,0,0,0,0],
                        [0,1,0,0,0],
                        [0,0,1,0,0]
                        ])):
        self._mo = self._mk = M_o
        self._pre, self._post = Pre, Post
    def M_o(self):
        return self._mo.transpose()[0]
    def Pre(self):
        return self._pre.transpose()
    def Post(self):
        return self._post.transpose()
    def M_k(self):
        return self._mk.transpose()[0]
    def Firing(self):
        while True:
            IsBlocked = True
            print("\nMarcado actual: ", self.M_k())
            for t_i in self.Enabled():
                IsBlocked = False
                print("Transición " + str(t_i) + " habilitada.")
            if IsBlocked:
                print("Red bloqueada...")
                break
            To_Fire = input("Selección: ")
            if To_Fire == "exit":
                break
            self._mk.transpose()[0] = self.M_k() - self.Pre()[int(To_Fire)] + self.Post()[int(To_Fire)]
    def Enabled(self):
            return (i for i,pre in enumerate(self.Pre()) if all(self.M_k() >= pre))
PetNet = MatrixPetriNet().Firing()<jupyter_output>Marcado actual:  [2 0 0 0 0]
Transición 0 habilitada.
Selección: 0
Marcado actual:  [0 1 1 0 0]
Transición 1 habilitada.
Transición 2 habilitada.
Selección: 1
Marcado actual:  [0 0 1 1 0]
Transición 2 habilitada.
Transición 3 habilitada.
Selección: 3
Marcado actual:  [1 0 1 0 0]
Transición 2 habilitada.
Selección: 2
Marcado actual:  [1 0 0 0 1]
Transición 4 habilitada.
Selección: 4
Marcado actual:  [2 0 0 0 0]
Transición 0 habilitada.
Selección: exit
{'fraction_non_alphanumeric': 0.1317928968763372, 'fraction_numerical': 0.04321780059905862, 'mean_word_length': 1.412796697626419, 'pattern_counts': {'":': 1, '<': 4, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '634521', 'license': 'Unlicense', 'n_tokens_mistral': 842, 'n_tokens_neox': 761, 'n_words': 179, 'path': 'PetNet.ipynb', 'repo_name': 'StealthSignatures/petri-net', 'size': '2337'}