Preface

Petri Nets have been widely used in different areas of science and technology since they were first presented in the middle of the last century by Dr. Carl Adam Petri. It is believed that he planned to use Petri Nets to represent chemical reactions.

Since then, Petri Networks have gained great acceptance in the design of manufacturing processes, logistic processes, software design, communication protocols, modern control theory, artificial intelligence and, of course, chemical process simulations.

Dra. Alcaraz-Mejia and I have been involved with Petri Nets since our master and PhD degrees from 2000 onwards. We used Petri Nets as a way to represent the dynamics of abstract discreteevent systems. Since then, we have used this modeling tool in our research activities in the areas of fault prediction and detection, observability and controllability analysis, to mention a few. Also, we have used Petri Nets as an instrument to teach the student models of concurren‐ cy, programming for embedded systems, distributed systems, data modeling and so on.

The graphic nature of the models in Petri Nets makes their use in different areas of science and engineering very attractive, since the models can be obtained in a very intuitive and natural way. Additionally, Petri Nets have a solid mathematical base that comes from linear algebra, vector spaces and linguistic analysis, among others. This allows a formal analysis of important properties such as liveness, interlocking, reachability, controllability or observa‐ bility, to mention a few.

The aim of this book is to present a collection of works to show the usability of Petri Nets in different areas of science and engineering. Whenever possible, models and graphics illus‐ trate the concepts developed in the chapters. The focus was to develop intuitive ideas and to motivate the reader, as much as possible, to use Petri Nets

We would like to thank Ms. Lada Bozic, Author Service Manager from INTECHOPEN, for her dedication and support during this process. With her help and coaching, we had incred‐ ible guidance to do our best effort to assure the quality of this book.

We hope that the readers found this book entitled "Petri Nets in Science and Engineering" illustrative and useful for their work in science and engineering.

**Dr. Raul Campos-Rodriguez**

Part-time Professor School of Engineering and Sciences Western Region Monterrey Institute of Technology and Higher Education, Jalisco, Mexico

### **Dra. Mildreth Alcaraz-Mejia** Research Professor Electronics, Systems and Informatic Department ITESO University, Jalisco, Mexico

**Chapter 1**

Provisional chapter

**Introductory Chapter: Petri Nets in Science and**

DOI: 10.5772/intechopen.79309

The Petri nets are one of the most widely used methods for the study of the dynamics that falls within the category of Discrete Event Systems (DES) [1]. The DES is a class of systems that are guided by the occurrence of events asynchronous in time, which are becoming more and more relevant nowadays. The Petri nets are graphically represented as a directed graph, with two classes of nodes, called places and transitions. The places allow capturing the state of a system. They also represent the conditions required by the events to occur, or to execute, in the DES. The transitions represent the events, or actions, executed in a system. The execution of the transitions may require one or more conditions to be activated. Moreover, it is possible that a transition does not include input places, as t<sup>1</sup> in Figure 2. This class of transitions allows capturing situations in a DES where an event may be random or stochastic, for example, the arrival of an information package in a communication channel. The explanation of the Petri net in Figure 2 will be addressed lather in this section, after the introduction of the system that it

Figure 1 depicts a conceptual diagram of a multitasking manufacturing system [6]. The system is supplied with the raw material from two conveyors, C<sup>1</sup> and C2. A robot arm distributes the raw material to either a mill machine or to a lather machine, depending on the manufacturing recipe. The semi-finished pieces are then moved by transporting bands to the assembly machine.

Figure 2 depicts a Petri net model for this multitasking manufacturing system. The supply of the raw material is represented as two transitions with no inputs. In means the material may arrive at any time that the inventory of raw pieces is able to feed the manufacturing system. The robotic arm moves the raw pieces to the mill machine, by means of t4, or to the lather machine, by means of t5. The semi-finished pieces are moved to the assembly station to

> © 2016 The Author(s). Licensee InTech. This chapter is distributed under the terms of the Creative Commons Attribution License (http://creativecommons.org/licenses/by/3.0), which permits unrestricted use, distribution, and eproduction in any medium, provided the original work is properly cited.

© 2018 The Author(s). Licensee IntechOpen. This chapter is distributed under the terms of the Creative Commons Attribution License (http://creativecommons.org/licenses/by/3.0), which permits unrestricted use,

distribution, and reproduction in any medium, provided the original work is properly cited.

Introductory Chapter: Petri Nets in Science and

Raul Campos-Rodriguez and Mildreth Alcaraz-Mejia

Raul Campos-Rodriguez and Mildreth Alcaraz-Mejia

Additional information is available at the end of the chapter

Additional information is available at the end of the chapter

http://dx.doi.org/10.5772/intechopen.79309

**Engineering**

Engineering

1. Introduction

represents.

produce a final product.

#### **Introductory Chapter: Petri Nets in Science and Engineering** Introductory Chapter: Petri Nets in Science and Engineering

DOI: 10.5772/intechopen.79309

Raul Campos-Rodriguez and Mildreth Alcaraz-Mejia Raul Campos-Rodriguez and Mildreth Alcaraz-Mejia

Additional information is available at the end of the chapter Additional information is available at the end of the chapter

http://dx.doi.org/10.5772/intechopen.79309

1. Introduction

The Petri nets are one of the most widely used methods for the study of the dynamics that falls within the category of Discrete Event Systems (DES) [1]. The DES is a class of systems that are guided by the occurrence of events asynchronous in time, which are becoming more and more relevant nowadays. The Petri nets are graphically represented as a directed graph, with two classes of nodes, called places and transitions. The places allow capturing the state of a system. They also represent the conditions required by the events to occur, or to execute, in the DES.

The transitions represent the events, or actions, executed in a system. The execution of the transitions may require one or more conditions to be activated. Moreover, it is possible that a transition does not include input places, as t<sup>1</sup> in Figure 2. This class of transitions allows capturing situations in a DES where an event may be random or stochastic, for example, the arrival of an information package in a communication channel. The explanation of the Petri net in Figure 2 will be addressed lather in this section, after the introduction of the system that it represents.

Figure 1 depicts a conceptual diagram of a multitasking manufacturing system [6]. The system is supplied with the raw material from two conveyors, C<sup>1</sup> and C2. A robot arm distributes the raw material to either a mill machine or to a lather machine, depending on the manufacturing recipe. The semi-finished pieces are then moved by transporting bands to the assembly machine.

Figure 2 depicts a Petri net model for this multitasking manufacturing system. The supply of the raw material is represented as two transitions with no inputs. In means the material may arrive at any time that the inventory of raw pieces is able to feed the manufacturing system. The robotic arm moves the raw pieces to the mill machine, by means of t4, or to the lather machine, by means of t5. The semi-finished pieces are moved to the assembly station to produce a final product.

Depending on what is the interest of study of the system, for example, the design of control strategies or the evaluation of performance of the assembly recipe, the model in Figure 2 could be refined or extended. Even new sections of the assembly system may be added to the Petri

Introductory Chapter: Petri Nets in Science and Engineering

http://dx.doi.org/10.5772/intechopen.79309

3

The manufacturing system and assembly lines, as well as communication protocols, are some of the most popular type of systems that are modeled and studied with Petri net models [8–10]. However, other types of systems such as workflow management or logistic systems are similarly likely to be modeled and studies by means of Petri nets [15–17]. Moreover, the design and implementation of complex software systems is as well plausible to be addressed with Petri net

The addressing of software design with Petri nets is popular because the construction of models for complex structures and control flow is quite intuitive thanks to its graphical nature. Moreover, the techniques developed around the Petri nets allow the construction of models that are usually more compact than the produced by other methods, such as those developed in graph theory. However, Petri nets and graph theory are not antagonist. On the contrary, the theory developed in one of them is usually extended to the other. Thus, they are usually

Figure 3 depicts a block diagram of a reader and writer problem in computer sciences. The processes share a region of memory where they can read and write. The diagram depicts the process that can read, process that can write, and process that perform both operations, reading and writing to the shared memory region. This situation arises in several cases in the

Figure 4 depicts a model for the above problem of readers and writers [2]. The net represents a system with 2k readers modeled as p2. The system allows up to k parallel reads from a shared memory region. It is represented by the marking in p3. However, the writing operation

Figure 3. The problem of readers and writers. The problem considers a set of process that can read and write to a shared memory region. The system must allow any number of simultaneous reading operations, while the writing operation requires that no reading operation is in execution. On the other hand, when a writing operation is in execution, no other

design of monolithic and distributed system, within the area of software design.

net model.

models [18, 19, 26].

complementary to each other.

writing, nor reading, operation is allowed.

Figure 1. A multitasking manufacturing station. The system is supplied with raw material from two inventories C<sup>1</sup> and C2. A robotic arm moves the raw pieces to the mill machine or to the lather machine depending on a manufacturing recipe. The robotic arm then moves the semi-finished pieces to the assembly station (AS), where final products are produced.

Figure 2. A Petri net model for the multitasking manufacturing system. The model is divided into a supply section, a robot section, lather and mill sections, and assembly section. The supply raw material is handled by a robotic arm that moves it to the lather ð Þ t<sup>5</sup> or mill ð Þ t<sup>4</sup> machine depending on a recipe. The semi-finished pieces are routed to the assembly machine by three different ways. Once the final product is assembled, t<sup>18</sup> moves the products to the store section.

Depending on what is the interest of study of the system, for example, the design of control strategies or the evaluation of performance of the assembly recipe, the model in Figure 2 could be refined or extended. Even new sections of the assembly system may be added to the Petri net model.

The manufacturing system and assembly lines, as well as communication protocols, are some of the most popular type of systems that are modeled and studied with Petri net models [8–10]. However, other types of systems such as workflow management or logistic systems are similarly likely to be modeled and studies by means of Petri nets [15–17]. Moreover, the design and implementation of complex software systems is as well plausible to be addressed with Petri net models [18, 19, 26].

The addressing of software design with Petri nets is popular because the construction of models for complex structures and control flow is quite intuitive thanks to its graphical nature. Moreover, the techniques developed around the Petri nets allow the construction of models that are usually more compact than the produced by other methods, such as those developed in graph theory. However, Petri nets and graph theory are not antagonist. On the contrary, the theory developed in one of them is usually extended to the other. Thus, they are usually complementary to each other.

Figure 1. A multitasking manufacturing station. The system is supplied with raw material from two inventories C<sup>1</sup> and C2. A robotic arm moves the raw pieces to the mill machine or to the lather machine depending on a manufacturing recipe. The robotic arm then moves the semi-finished pieces to the assembly station (AS), where final products are

Figure 2. A Petri net model for the multitasking manufacturing system. The model is divided into a supply section, a robot section, lather and mill sections, and assembly section. The supply raw material is handled by a robotic arm that moves it to the lather ð Þ t<sup>5</sup> or mill ð Þ t<sup>4</sup> machine depending on a recipe. The semi-finished pieces are routed to the assembly machine by three different ways. Once the final product is assembled, t<sup>18</sup> moves the products to the store section.

produced.

2 Petri Nets in Science and Engineering

Figure 3 depicts a block diagram of a reader and writer problem in computer sciences. The processes share a region of memory where they can read and write. The diagram depicts the process that can read, process that can write, and process that perform both operations, reading and writing to the shared memory region. This situation arises in several cases in the design of monolithic and distributed system, within the area of software design.

Figure 4 depicts a model for the above problem of readers and writers [2]. The net represents a system with 2k readers modeled as p2. The system allows up to k parallel reads from a shared memory region. It is represented by the marking in p3. However, the writing operation

Figure 3. The problem of readers and writers. The problem considers a set of process that can read and write to a shared memory region. The system must allow any number of simultaneous reading operations, while the writing operation requires that no reading operation is in execution. On the other hand, when a writing operation is in execution, no other writing, nor reading, operation is allowed.

Figure 4. A Petri net model that represents the typical problem of readers and writers. The model allows up to 2k processes p<sup>2</sup> � � that can read or write to and from shared memory resources <sup>p</sup><sup>3</sup> � �. However, only k of them can be concurrently in a reading operation. On the other hand, the writing process requires k tokens to be on the shared place p3. That is, no reading operation must be executed by any of the 2k readers in p<sup>2</sup> to allow the writing operation. Thus, the writing operation must wait until all the reading operations have finished. Similarly, when a writing operation is in execution, no reading operation is allowed, since p<sup>3</sup> is empty.

requires k tokens on p3. That is, it requires that no reading operation is currently in execution. Correspondingly, when a writing operation is in execution, no read operation is allowed. This is represented by k weighted arc of t1. Thus, when writing operation is in execution, by the firing of t1, the k tokens in p<sup>3</sup> are removed. Once the reading operation is done, the firing of t<sup>2</sup> returns k tokens to p3. The Petri net model allows any of the 2k processes to read and to write to the shared place p<sup>3</sup> by connecting the place p<sup>2</sup> to the reading or writing sections of the net.

Other attractive attribute of the Petri nets is their solid mathematical basis. The incidence matrix that represents the structure of the net in Figure 4 is represented by Eq. (1). The incidence matrix is independent of the initial condition of the net. This structure could be analyzed by methods from the matrix theory, linear algebra, or vector spaces, for example.

$$
\begin{bmatrix}
1 & -1 & 0 & 0 \\
0 & 0 & 1 & -1
\end{bmatrix}
\tag{1}
$$

In a similar way, the vector uk

systems.

relies on them.

in the positive cone of Z+

2. Petri nets in science

a system and their associated abstract properties.

[7]. Figure 5(a) depicts the state space, in R<sup>3</sup>

where n is the number of places of the net.

to operate by a matrix multiplication.

! represents the number of times each transition is fired at a given

Introductory Chapter: Petri Nets in Science and Engineering

http://dx.doi.org/10.5772/intechopen.79309

5

stage in the evolution of the net. In this sense, the Parikh vector behaves like a "functor" in the sense of the category theory [3], from the strings over the alphabet of events in a DES to vectors that quantifies the occurrence of events in a DES. That is, the Parikh vector "loses" the execution order of the events in a trajectory of a DES to obtain a pure vector which is simpler

There are different semantics for the execution of the transitions in a Petri net model. First, in a single firing semantics, only one of the enabled transitions can fire at a time. Second, in the multiple firing semantics, all the enabled transitions are allowed to fire at a time. In all the semantic approaches, the conflicting transitions, that is, the ones whose firing disables the firing of others are resolved by priorities, by a probability distribution, or some other conflict resolution mechanism. Depending on the adopted semantics, the ability of the models to capture dynamics of real systems differs. For example, if the analyzed system is of distributed nature, such as a cluster of computers or a cloud service, then the correct semantics is that of multiple firing. The expressiveness of the different semantic mechanisms is a theoretical question that lies around the computer sciences. The next subsections detail some theoretical aspects of the Petri nets and application in science and theory of

As mentioned, the Petri nets are a very versatile tool that turns it useful in science, as well as in engineering. In the science field, a wide developed aspect is related to the study of Petri nets as

For example, the study of properties of the Petri net models in terms of vectors and matrices is complemented with the linguistic study in terms of strings and formal languages. The welldeveloped theory of matrices, linear algebra, and vector spaces are well suited to the analysis of properties in the net models, providing efficient solutions. However, other studies such as the reachability analysis, requires the partial expansion of the state space of the models, which turns the investigation in an inverse direction, from a vector space to string over a language. Though, the advantages of the study of the Petri net properties in terms of vectors, matrices, and linear algebra in general are considerable, and many of the theory developed for Petri nets

Indeed, by restricting the marking of a Petri net to be non-negative, the state space entirely lies

initial conditions M<sup>0</sup> ¼ ½ � 100 and M<sup>0</sup> ¼ ½ � 200 , the two hyperplanes are orthogonal to the unitary vector u ¼ ½ � 111 . Moreover, if the net is conservative (i.e., the number of tokens over all its places remains constant for any evolution trajectory), then it is easy to show that the entire state space of the Petri net lives in one of the hyperplanes orthogonal to a vector in R<sup>n</sup>,

. Thus, some of the theory of positive linear systems could be applied

, of the Petri net model in (b) for two different

The state equation of a Petri net allows a formal definition of its dynamics. The next state of a Petri net can be computed from the current state, and a multiplication of the matrix that represents the structure of the net and a vector that represents the transitions that can fire, as follows:

$$M\_{k+1} = M\_k + B\overrightarrow{u\_k} \tag{2}$$

The vector uk ! represents one or more transitions that are allowed to fire. It is known as the Parikh vector, in a clear relationship to the Parikh's theorem. This theorem relates the strings in a context-free language and the number of the occurrences of the symbols in these strings.

In a similar way, the vector uk ! represents the number of times each transition is fired at a given stage in the evolution of the net. In this sense, the Parikh vector behaves like a "functor" in the sense of the category theory [3], from the strings over the alphabet of events in a DES to vectors that quantifies the occurrence of events in a DES. That is, the Parikh vector "loses" the execution order of the events in a trajectory of a DES to obtain a pure vector which is simpler to operate by a matrix multiplication.

There are different semantics for the execution of the transitions in a Petri net model. First, in a single firing semantics, only one of the enabled transitions can fire at a time. Second, in the multiple firing semantics, all the enabled transitions are allowed to fire at a time. In all the semantic approaches, the conflicting transitions, that is, the ones whose firing disables the firing of others are resolved by priorities, by a probability distribution, or some other conflict resolution mechanism. Depending on the adopted semantics, the ability of the models to capture dynamics of real systems differs. For example, if the analyzed system is of distributed nature, such as a cluster of computers or a cloud service, then the correct semantics is that of multiple firing. The expressiveness of the different semantic mechanisms is a theoretical question that lies around the computer sciences. The next subsections detail some theoretical aspects of the Petri nets and application in science and theory of systems.
