Closed matthewryanscott closed 7 months ago
After some playing around with this my current thought is to have a TransitionOccurrence
class that will encapsulate this.
The high-level concept makes sense.
But I would need to see a concrete example to reason about this.
Isn't it strange that we are talking about marking evolution and yet we would express it as a “transition occurrence”?
Current
You have a Petri net instance, and you can get a
marking_after_transition
based on amarking
and atransition
.However, the mechanism of constructing the new marking is internal to this function and can only be tested as a black box. Its internal algorithm also cannot be exploited for any other purpose than to get a new marking.
This means that you have to infer what the function did by comparing the input and output markings.
Desired
You have a Petri net instance, and you can get the
transition_effects
for a givenmarking
andtransition
. Those effects are a list of operations that can be appliedYou can call
apply_effects(marking, effects)
and it will return a new marking with the effects applied.Therefore, the implementation of
marking_after_transition
would be reduced to:You can also directly inspect the effects in tests, and they could also be used as a basis for showing additional context & animations in a simulator.