Class PetriNet


public final class PetriNet extends Featurizable<PetriNetFeature>
A Petri net model.
  • Constructor Details

    • PetriNet

      public PetriNet()
  • Method Details

    • addPlace

      public Place addPlace(String placeName)
      Adds a place to the Petri net.

      If a place with the same name already exists, the existing place is returned.

      Parameters:
      placeName - the name of the place
      Returns:
      the place instance
    • getPlace

      public Place getPlace(String placeName)
      Gets an existing place with the given name.
      Parameters:
      placeName - name of the place
      Returns:
      place instance, or null if no place exists with the given name
    • removePlace

      public Place removePlace(Place p)
      Removes an existing place.
      Parameters:
      p - place to be removed
      Returns:
      the removed place
    • getPlaces

      public Collection<Place> getPlaces()
      Returns the places of the Petri net.
      Returns:
      collection of places
    • getPlaceNames

      public Collection<String> getPlaceNames()
      Returns the names of the places in the Petri net.
      Returns:
      names of the places
    • addTransition

      public Transition addTransition(String transitionName)
      Adds a transition to the Petri net.

      If a transition with the same name already exists, the existing transition is returned.

      Parameters:
      transitionName - the name of the transition
      Returns:
      the transition instance
    • getTransition

      public Transition getTransition(String transitionName)
      Gets an existing transition with the given name.
      Parameters:
      transitionName - name of the transition
      Returns:
      transition instance, or null if no transition exists with the given name
    • removeTransition

      public Transition removeTransition(Transition t)
      Removes an existing transition.
      Parameters:
      t - transition to be removed
      Returns:
      the removed transition
    • getTransitions

      public Collection<Transition> getTransitions()
      Returns the transitions of the Petri net.
      Returns:
      collection of transitions
    • getTransitionNames

      public Collection<String> getTransitionNames()
      Returns the names of the transitions in the Petri net.
      Returns:
      names of the transitions
    • addPrecondition

      public Precondition addPrecondition(Place p, Transition t)
      Adds a precondition with multiplicity 1.
      Parameters:
      p - place
      t - transition
      Returns:
      the added precondition
    • addPrecondition

      public Precondition addPrecondition(Place p, Transition t, int multiplicity)
      Adds a precondition with given multiplicity.
      Parameters:
      p - input place
      t - target transition
      multiplicity - precondition multiplicity
      Returns:
      the added precondition
    • getPrecondition

      public Precondition getPrecondition(Place p, Transition t)
      Returns the existing precondition between a place and a transition.
      Parameters:
      p - input place
      t - target transition
      Returns:
      precondition between the place and the transition, or null if no precondition exists
    • removePrecondition

      public Precondition removePrecondition(Precondition pre)
      Removes the existing precondition between a place and a transition.
      Parameters:
      pre - existing precondition
      Returns:
      precondition between the place and the transition
    • getPreconditions

      public Collection<Precondition> getPreconditions(Transition t)
      Gets all the preconditions of a transition.
      Parameters:
      t - transition
      Returns:
      preconditions of the transition
    • addInhibitorArc

      public InhibitorArc addInhibitorArc(Place p, Transition t)
      Adds an inhibitor arc with multiplicity 1.
      Parameters:
      p - place
      t - transition
      Returns:
      the added inhibitor arc
    • addInhibitorArc

      public InhibitorArc addInhibitorArc(Place p, Transition t, int multiplicity)
      Adds an inhibitor arc with given multiplicity.
      Parameters:
      p - input place
      t - target transition
      multiplicity - inhibitor arc multiplicity
      Returns:
      the added inhibitor arc
    • getInhibitorArc

      public InhibitorArc getInhibitorArc(Place p, Transition t)
      Returns the existing inhibitor arc between a place and a transition.
      Parameters:
      p - input place
      t - target transition
      Returns:
      inhibitor arc between the place and the transition, or null if inhibitor arc exists
    • removeInhibitorArc

      public InhibitorArc removeInhibitorArc(InhibitorArc ia)
      Removes the existing inhibitor arc between a place and a transition.
      Parameters:
      ia - existing inhibitor arc
      Returns:
      inhibitor arc between the place and the transition
    • getInhibitorArcs

      public Collection<InhibitorArc> getInhibitorArcs(Transition t)
      Gets all the inhibitor arcs of a transition.
      Parameters:
      t - transition
      Returns:
      inhibitor arcs of the transition
    • addPostcondition

      public Postcondition addPostcondition(Transition t, Place p)
      Adds a postcondition with multiplicity 1.
      Parameters:
      p - place
      t - transition
      Returns:
      the added postcondition
    • addPostcondition

      public Postcondition addPostcondition(Transition t, Place p, int multiplicity)
      Adds a postcondition with given multiplicity.
      Parameters:
      p - input place
      t - target transition
      multiplicity - postcondition multiplicity
      Returns:
      the added postcondition
    • getPostcondition

      public Postcondition getPostcondition(Transition t, Place p)
      Returns the existing postcondition between a place and a transition.
      Parameters:
      p - input place
      t - target transition
      Returns:
      postcondition between the place and the transition, or null if no postcondition exists
    • removePostcondition

      public Postcondition removePostcondition(Postcondition post)
      Removes the existing postcondition between a place and a transition.
      Parameters:
      post - existing postcondition
      Returns:
      postcondition between the place and the transition
    • getPostconditions

      public Collection<Postcondition> getPostconditions(Transition t)
      Gets all the postconditions of a transition.
      Parameters:
      t - transition
      Returns:
      postconditions of the transition
    • toString

      public String toString()
      Overrides:
      toString in class Featurizable<PetriNetFeature>
    • getEnabledTransitions

      public Set<Transition> getEnabledTransitions(Marking marking)
      Returns the set of transitions enabled by a given marking.
      Parameters:
      marking - a marking
      Returns:
      set of transitions enabled by the marking
    • isEnabled

      public boolean isEnabled(Transition t, Marking m)
      Checks if a transition is enabled by a marking.
      Parameters:
      t - a transition
      m - a marking
      Returns:
      true if the transition is enabled by the marking