Class Place
java.lang.Object
org.tweetyproject.logics.petri.syntax.PetriNetNode
org.tweetyproject.logics.petri.syntax.Place
- All Implemented Interfaces:
Comparable<Place>
,Node
A class to describe places in a Petri net
- Author:
- Benedikt Knopp
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addTokens
(int tokens) boolean
canAddTokens
(int tokens) boolean
canRemoveTokens
(int tokens) int
getId()
int
int
boolean
isFinal()
check if this place is a designated final placeboolean
check if this place is a designated initial placevoid
removeTokens
(int tokens) void
setFinal()
specify that this place is a designated final placevoid
void
specify that this place is a designated initial placevoid
setMaxtokens
(int maxtokens) void
setTokens
(int tokens) Methods inherited from class org.tweetyproject.logics.petri.syntax.PetriNetNode
getName, setName
-
Constructor Details
-
Place
Create a new instance- Parameters:
id
- a unique identifier
-
Place
Create a new instance- Parameters:
id
- a unique identifiername
- a pretty name
-
-
Method Details
-
getId
- Overrides:
getId
in classPetriNetNode
- Returns:
- the id
-
setId
- Overrides:
setId
in classPetriNetNode
- Parameters:
id
- the id to set
-
getTokens
public int getTokens()- Returns:
- the number of tokens currently at this place
-
setTokens
public void setTokens(int tokens) - Parameters:
tokens
- the number of tokens currently at this place
-
getMaxtokens
public int getMaxtokens()- Returns:
- the maximal number of tokens that this place can hold
-
setMaxtokens
public void setMaxtokens(int maxtokens) - Parameters:
maxtokens
- the maximal number of tokens that this place can hold
-
addTokens
public void addTokens(int tokens) - Parameters:
tokens
- the number of tokens to be added to this place- Throws:
IllegalArgumentException
- if this number of tokens can not be added
-
removeTokens
public void removeTokens(int tokens) - Parameters:
tokens
- the number of tokens to be removed from this place- Throws:
IllegalArgumentException
- if this number of tokens can not be removed
-
canAddTokens
public boolean canAddTokens(int tokens) - Parameters:
tokens
- the number of tokens to be added to this place- Returns:
- true if this number can be added with respect to the token limit and the current number of tokens
-
canRemoveTokens
public boolean canRemoveTokens(int tokens) - Parameters:
tokens
- the number of tokens to be removed from this place- Returns:
- true if this number can be removed with respect to current number of tokens
-
compareTo
- Specified by:
compareTo
in interfaceComparable<Place>
-
isInitial
public boolean isInitial()check if this place is a designated initial place- Returns:
- true iff this place is a designated initial place
-
setInitial
public void setInitial()specify that this place is a designated initial place -
isFinal
public boolean isFinal()check if this place is a designated final place- Returns:
- true iff this place is a designated final place
-
setFinal
public void setFinal()specify that this place is a designated final place
-