Skip to content

Commit

Permalink
added helpers for post/preset of transitions
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamBanham committed Feb 7, 2025
1 parent 4bcc704 commit 869bcdd
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion pmkoalas/models/petrinet.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,26 @@ def __str__(self) -> str:
for a in self.arcs:
_str += f"\t\t- {a}\n"
return _str


def preset_of_transition(net:LabelledPetriNet,transition:Transition
) -> FrozenSet[Place]:
"""
Returns the set of places that need to be marked for transition
to fire, or the preset of a transition.
"""
return frozenset([arc.from_node
for arc in net.arcs
if arc.to_node == transition])

def postset_of_transition(net:LabelledPetriNet,transition:Transition
) -> FrozenSet[Place]:
"""
Returns the set of places that are marked after the transition fires,
or the postset of a transition.
"""
return frozenset([arc.to_node
for arc in net.arcs
if arc.from_node == transition])

class BuildablePetriNet(LabelledPetriNet):
"""
Expand Down

0 comments on commit 869bcdd

Please sign in to comment.