public class PetriNet<T extends Event>
extends java.lang.Object
See parseFromString for a precise definition of the
input format to specify the Petri net.
| Modifier and Type | Field and Description |
|---|---|
protected java.util.Map<java.lang.String,java.lang.Integer> |
m_initialMarking
The list of places that contain a token in the initial marking
|
protected java.util.List<Place<T>> |
m_places
The list of places in the Petri net
|
protected java.util.List<Transition<T>> |
m_transitions
The list of transitions in the Petri net
|
| Constructor and Description |
|---|
PetriNet()
Creates an empty Petri Net
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
fire(Transition<T> t)
Attempts to fire a transition in the current state of the
Petri net.
|
protected Place<T> |
getPlace(java.lang.String label)
Gets the place with given label
|
void |
reset()
Resets the Petri net to its initial markings
|
void |
setInitialMarking(java.lang.String label,
int value)
Adds tokens to the initial marking of this Petri net.
|
protected java.util.List<Place<T extends Event>> m_places
protected java.util.List<Transition<T extends Event>> m_transitions
protected java.util.Map<java.lang.String,java.lang.Integer> m_initialMarking
public void reset()
protected Place<T> getPlace(java.lang.String label)
label - The labelnull if the place was not foundpublic boolean fire(Transition<T> t)
t - The transition to firetrue if the transition can fire, false
otherwise. If the transition fires, the Petri net's state is
updated accordingly.public void setInitialMarking(java.lang.String label,
int value)
label - The label of the place where tokens should be addedvalue - The number of tokens to put thereCopyright © Sylvain HallĂ©. All Rights Reserved.