# How to Determine Places, Transitions and Tokens in a Scenario when Modeling with Petri Nets?

When modeling a scenario with Petri nets how should I determine the places, transitions and tokens?

Example:

There are two exam assistants in an exam hall observing the exam. They stand in front of the exam hall. When a student has a question one of the assistants goes to him and answers his question while the other stays in front of hall. When the question is answered, the assistant goes back to the front of the hall.

By modeling this scenario it must be distinguished which assistant stays in front of hall. Then the Petri net must be expanded so that the assistants take turns answering the questions.

Here is my solution:

p0 represents the front of the exam hall. The two tokens represent the assistants and p1 is where the student seats. I also limited the capacity of p1 to one.

The given solution is however totaly different:

How should I generally think and how can I determine which part of a given scenario is represented by which part of the Petri net (places, transitions and tokens)?

Generally, the idea of a (normal) petri-net is to efficiently represent a system to model an arbitrary amount of 'agents' that change their state depending on certain transitions. (This would quite quickly get out of hand in a state machine)

So, the basic strategy is to first determine what your 'agents' are and model them as your tokens. The state of an individual agent corresponds to the places and the state transitions correspond to transitions in the petri-net.

Depending on what you want to model, you need to do a bit more and also consider different (in your modeling interpretation, not as far as the petri-net is concerned) tokens that are created by some action of other tokens, but the general idea of what tokens, places and transitions are remains the same.

Your answer follows the basic strategy, but it fails to meet the requirement that the tokens are distinguishable and that at least one of them must remain in front of the hall. In a normal petri-net, we cannot distinguish tokens from another, so if a token moves to $p_1$, we cannot know which.

A solution is to construct different transitions such that we know which assistant moves, based on the transition taken. The 'given solution' you provide does this and adds some restrictions to model the requirement that at least one of them must remain in front of the hall.

If you find it challenging to apply Petri Nets in modeling an application then it may help to consider the following mapping between the types of words found in a text description of an application with the types of Petri Net elements found in a Petri Net diagram of the application:

1. Nouns are candidates for places.
2. Verbs are nominees for transitions (and/or inputs and outputs).
3. Values, amounts or counts are contenders for tokens in places.

## Example Application

[Consider Figure 1 for the following example]. For the “Exam Hall Problem”, think of (Infinity, 2017):

1. A place as a holder or container for “things”. a. There are two exam assistants in front of the hall and each assistant must be distinguished from the other. Thus there are two places: one place for each assistant in front of the hall (P4, P5). b. The exam assistants can answer questions at the same time. Thus there are two additional places: one place for an exam assistant answering a question (P2, P3).
2. A token in a place as the counter for the place, the number of “things”. a. If an exam assistant is not in front of the hall then the place is empty. If an exam assistant is in front of the hall then the place is not empty, the place has a token. b. If an exam assistant is answering a question then the place is not empty, the place has a token. If an exam assistant is not answering a question then the place is empty.
3. A transition as a start or end of “activities”. a. An exam assistant going to a student to answer a question is an activity (T1, T3). b. An exam assistant who answered a question is another activity (T2, T4).

The given solution for the “Exam Hall Problem” appears to be a solution for the second scenario: the exam assistants take turns answering questions (Infinity, 2017). Figure 1 is a modified version of the given solution. It was modified to satisfy the requirements of the first scenario. It includes text labels, chosen from or derived from the words in the example description.

Figure 1 Petri Net Model for Exam Assistants Answering Questions in an Exam Hall

For the “dynamic and interactive version” of this document, the visibility of labels in Figure 1 can be toggled by clicking on the diagram (Chionglo, 2017).

## Reference

Chionglo, J. F. (2017). A Reply to "How to Determine Places, Transitions and Tokens in a Scenario when Modeling with Petri Nets?" at Computer Science Stack Exchange. Available at https://www.academia.edu/31997446/A_Reply_to_How_to_with_Petri_Nets_At_Computer_Science_Stack_Exchange.

Infinity. (2017). "How to Determine Places, Transitions and Tokens in a Scenario when Modeling with Petri Nets?" at Computer Science Stack Exchange. Retrieved on Mar. 21, 2017 at How to Determine Places, Transitions and Tokens in a Scenario when Modeling with Petri Nets?.

When I use Petri nets or explain them to others, my general policy in naming places and transitions is to use a phrase of the form <noun phrase> <predicate> whenever possible. A token is a subject described by the phrase.

A place represents a condition the subject may be in. For instance:

• An item is in store.
• The order is being processed.
• The computer has been assembled and is ready to be tested.
• The sun is shining.

A transition describes a change of state to the subject. For instance: