Class Marking

java.lang.Object
org.oristool.petrinet.Marking

public final class Marking extends Object
A marking, assigning a token count to each place of a Petri net.
  • Constructor Details

    • Marking

      public Marking()
      Builds an empty marking.
    • Marking

      public Marking(Marking m)
      Builds the copy of a marking.
      Parameters:
      m - input marking
  • Method Details

    • setTokensFrom

      public void setTokensFrom(Marking m)
      Resets this marking to the token counts of the input one.
      Parameters:
      m - input marking
    • getTokens

      public int getTokens(Place place)
      Returns the number of tokens in a place.
      Parameters:
      place - the input place
      Returns:
      token count of the place
    • getTokens

      public int getTokens(String placeName)
      Returns the number of tokens of a place from its string name.
      Parameters:
      placeName - name of the place
      Returns:
      number of tokens of the place
    • setTokens

      public void setTokens(Place place, Integer tokens)
      Sets the number of tokens of a place.
      Parameters:
      place - target place
      tokens - count of the place
    • addTokens

      public void addTokens(Place place, int number)
      Adds a specified number of tokens in a place.
      Parameters:
      place - target place
      number - tokens to be added
    • removeTokens

      public void removeTokens(Place place, int number)
      Removes a specified number of tokens from a place.
      Parameters:
      place - target place
      number - tokens to be removed
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • containsSubMarking

      public boolean containsSubMarking(Marking subMarking)
      Checks whether this marking contains the same token counts for a subset of places.
      Parameters:
      subMarking - marking for a subset of places
      Returns:
      true if this marking contains (as a subset) the same token assignments of the input one
    • getNonEmptyPlacesNames

      public Set<String> getNonEmptyPlacesNames()
      Returns the names of places with nonzero token counts.
      Returns:
      a set of strings of place names