Interface EfficientPetrinetSemantics
-
- All Superinterfaces:
PetrinetSemantics,org.processmining.models.semantics.Semantics<Marking,Transition>,java.io.Serializable
- All Known Implementing Classes:
EfficientPetrinetSemanticsImpl
public interface EfficientPetrinetSemantics extends PetrinetSemantics
Petrinet semantics designed with good performance characteristics avoiding object creation overhead. Therefore, multiple additional methods are added, to allow for direct access and manipulation of the data structures.The original
PetrinetSemanticsinterface is also supported, but using methods of this interface might not lead to the best performance.- Author:
- F. Mannhardt, S.J. van Zelst
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceEfficientPetrinetSemantics.PlaceVisitorVisitor style interface to iterate through places
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Markingconvert(byte[] marking)convert a primative int array to a marking object based on the internal index representation of the petri net's places.byte[]convert(Marking marking)allows to convert a given marking to an equivalent int array based on the internal index representation of the petri net's places.voiddirectExecuteExecutableTransition(Transition transition)Executes (fires) a transition.booleanequalMarking(byte[] marking1, Marking marking2)booleanequalOrLessMarking(byte[] marking1, Marking marking2)org.processmining.models.semantics.ExecutionInformationexecuteExecutableTransition(Transition toExecute)For better performance, use methoddirectExecuteExecutableTransition(Transition)instead.voidforEachMarkedPlace(EfficientPetrinetSemantics.PlaceVisitor placeVisitor)Visits each place that is marked with one or more tokens.voidforEachPlace(EfficientPetrinetSemantics.PlaceVisitor placeVisitor)Visits each place.java.util.Collection<Transition>getExecutableTransitions()For better performance, use methodisEnabled(Transition)instead.intgetIndex(Place place)intgetIndex(Transition transition)byte[]getMissingTokensToEnable(int transitionIndex)byte[]getMissingTokensToEnable(Transition t)figures out whether a certain transition t is missing any tokens to be fired.PlacegetPlace(int placeIndex)byte[]getState()MarkinggetStateAsMarking()Creates a newMarkingobject with the current marking.TransitiongetTransition(int index)booleanisEnabled(int transitionIndex)booleanisEnabled(Transition transition)booleanisMarked(byte[] marking, Place place)voidsetState(byte[] state)Sets the state to the supplied state (marking).voidsetStateAsMarking(Marking marking)Sets the state to the supplied marking.
-
-
-
Method Detail
-
directExecuteExecutableTransition
void directExecuteExecutableTransition(Transition transition)
Executes (fires) a transition. For performance reasons, this method does not check whether the transition is actually enabled and does not return information on what changed.- Parameters:
transition-
-
equalMarking
boolean equalMarking(byte[] marking1, Marking marking2)- Parameters:
marking1-marking2-- Returns:
- whether marking2 is equal to marking1
-
equalOrLessMarking
boolean equalOrLessMarking(byte[] marking1, Marking marking2)- Parameters:
marking1-marking2-- Returns:
- whether marking2 has equal or less tokens on each place than marking1
-
executeExecutableTransition
org.processmining.models.semantics.ExecutionInformation executeExecutableTransition(Transition toExecute) throws org.processmining.models.semantics.IllegalTransitionException
For better performance, use methoddirectExecuteExecutableTransition(Transition)instead.- Specified by:
executeExecutableTransitionin interfaceorg.processmining.models.semantics.Semantics<Marking,Transition>- Parameters:
toExecute-- Returns:
- Throws:
org.processmining.models.semantics.IllegalTransitionException
-
forEachMarkedPlace
void forEachMarkedPlace(EfficientPetrinetSemantics.PlaceVisitor placeVisitor)
Visits each place that is marked with one or more tokens.- Parameters:
placeVisitor-
-
forEachPlace
void forEachPlace(EfficientPetrinetSemantics.PlaceVisitor placeVisitor)
Visits each place.- Parameters:
placeVisitor-
-
getExecutableTransitions
java.util.Collection<Transition> getExecutableTransitions()
For better performance, use methodisEnabled(Transition)instead.- Specified by:
getExecutableTransitionsin interfaceorg.processmining.models.semantics.Semantics<Marking,Transition>- Returns:
- a collection of all enabled transitions
-
getIndex
int getIndex(Place place)
- Parameters:
place-- Returns:
- the index used for this place, corresponds to an index in
getState()
-
getIndex
int getIndex(Transition transition)
- Parameters:
transition-- Returns:
- the index used (internally) for this transition.
-
getMissingTokensToEnable
byte[] getMissingTokensToEnable(Transition t)
figures out whether a certain transition t is missing any tokens to be fired.- Parameters:
t- transition to fire- Returns:
- array of the number of tokens missing for each indexed place to enable t
-
getMissingTokensToEnable
byte[] getMissingTokensToEnable(int transitionIndex)
-
getPlace
Place getPlace(int placeIndex)
- Parameters:
placeIndex- of the place- Returns:
- the Place object corresponding to the index
-
getState
byte[] getState()
- Returns:
- a copy of the underlying array of tokens in the current state (marking).
-
getStateAsMarking
Marking getStateAsMarking()
Creates a newMarkingobject with the current marking.- Returns:
- the current state as a
Marking
-
getTransition
Transition getTransition(int index)
- Parameters:
index- of the transition- Returns:
- the Transition Object corresponding to the index
-
isEnabled
boolean isEnabled(Transition transition)
- Parameters:
transition-- Returns:
- whether the transition is enabled
-
isEnabled
boolean isEnabled(int transitionIndex)
-
isMarked
boolean isMarked(byte[] marking, Place place)- Parameters:
marking- obtained withgetState()place- of the net- Returns:
- where place p is marked
-
setState
void setState(byte[] state)
Sets the state to the supplied state (marking). The state array is copied into the internal data structure.- Parameters:
state-
-
setStateAsMarking
void setStateAsMarking(Marking marking)
Sets the state to the supplied marking.- Parameters:
marking-
-
convert
byte[] convert(Marking marking)
allows to convert a given marking to an equivalent int array based on the internal index representation of the petri net's places.- Parameters:
marking- of the petri net used wihtin semantics- Returns:
- corresponding int array
-
convert
Marking convert(byte[] marking)
convert a primative int array to a marking object based on the internal index representation of the petri net's places.- Parameters:
marking- to transform (int arr)- Returns:
- fresh marking object
-
-