3
$\begingroup$

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:

enter image description here

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:

enter image description here

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)?

$\endgroup$

3 Answers 3

3
$\begingroup$

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.

Petri Net Model for Exam Assistants Answering Questions in an Exam Hall 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?.

$\endgroup$
2
$\begingroup$

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.

$\endgroup$
1
$\begingroup$

When I use Petri nets or explain them to others, my general policy is to always name places and transitions and places by propositions of the form <subject> <predicate>.

The subject is a noun phrase. It may be definite or indefinite. It must be definite for a safe place (one that will never contain more than 1 token at a time).

The predicate is a verb phrase. For places, the verb is stative (describing a state); for transitions, it is dynamic (describing a change of state, an action or event).

With this naming convention, interpretation is straightforward:

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.
  • It is raining.

A token in a place is a subject to which the given proposition applies. For safe places, there exists only one possible subject (e.g. in The sun is shining) or no real subject at all (e.g. in It is raining).

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

  • An item is retrieved from store.
  • The order finishes being processed.
  • The computer starts being tested.
  • The sun goes down.
  • It starts to rain.
  • It ceases to rain.

I've found that, particularly for places, insisting on them being named in this way avoids conceptual errors and makes the model much easier to understand.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.