**5. Numerical Example**

In this section, an example is used to present the application of the proposed approach. Consider an AMS example illustrated in Figure 15a. Its Petri net model is given in [6,7,15,22,45,46]. The system consists of four machines M1–M4 for processing parts; two robots R1 and R2 for loading and unloading parts. Each machine (robot) can process (hold) one part at a time. There are two input buffers I1 and I2 and two output buffers O1 and O2. Two raw part types, A and B, are considered to be processed in the system. Figure 15b shows the operation sequences of the two raw part types. The S3PR net of this AMS example is illustrated in Figure 16. It comprises 19 places and 14 transitions. The places can be defined as the following set partitions: *PA* = {*p*2, *p*3, ... , *p*12}, *PR* = {*p*13, *p*14, ... , *p*18}, and *P0* = {*p*1, *p*19}. The S3PR net contains 282 reachable markings.

**Figure 15.** (**a**) An AMS example and (**b**) production sequence.

**Figure 16.** S3PR net (*No*, *Mo*) of the AMS illustrated in Figure 13a.

Suppose that the first configuration of the system involves removing old machine. In this case, an old machine M1 is removed from the system (*No*, *Mo*). To model the removed machine by using the synthesis procedure of Algorithm 1, we construct a configuration as a rewriting rule R= {*rr1*} with *rr1* = {*L1*, *R1,* ϕ*1*, •ϕ*1*, ϕ*<sup>1</sup>* •}, where *L1* and *R1* are illustrated in Figures 17a and 17b, respectively. In addition, we have ξ*1: N1* → *No*, ϕ*1*= ({*p2*, *p3*, *p4*, *p5*, *p13*, *p16*, *p17*},{*t1*, *t2*, *t3*, *t4*, *t5*, *t6*}), •ϕ*1*= ({*L1.t1*},{*R1.t1*}), and ϕ*<sup>1</sup>* • = ({*L1.t6*},{*R1.t6*}). The second configuration includes adding new product. If a new product (part C) is assigned to a system, which indicates that a new operation sequence is assigned and the system requires an adjustment to its Petri net model structure. To model the addition of new product by using the synthesis procedure of Algorithm 1, we construct a configuration as a rewriting rule R = {*rr2*} with *rr2* = {*L2*, *R1,* ϕ*2*, •ϕ*2*, ϕ*<sup>2</sup>* •}, where *L2* and *R2* are illustrated in Figures 18a and 18b, respectively. Moreover, we have ξ*2: N2* → *N1*, ϕ*2*= ({*p15*, *p17*, *p20*, *p21*, *p22*, *p23*},{*t15*, *t16*, *t17*, *t18*}), •ϕ*2*= ({*L2.p15*, *L2.p17*},{*R2.t15*}), and ϕ*<sup>2</sup>* • = ({*L2.p15*, *L2.p17*},{*R2.t18*}).

The third system configuration involves rework. In this scenario, a part can be inspected after all operations have been completed. By using the proposed Algorithm 1, the production operations of the reworked part can be exactly and easily modeled by considering rework operations as alternative sequences. Suppose that an inspection machine M5 is added to a system and that part A is processed in M1 and M3. Then, part A is moved to an M5 by Robot 2 to check if there are defects in part A. If part A performs properly, then it will leave the system by Robot 2. Otherwise, if part A has defects, rework is needed, and part A is moved to M3 by Robot 2. To model the rework operation by using the synthesis procedure of Algorithm 1, we construct a configuration as a rewriting rule R = {*rr3*} with *rr3* = {*L3*, *R3,* ϕ*3*, •ϕ*3*, ϕ*<sup>3</sup>* •}, where *L3* and *R3* are illustrated in Figures 19a and 19b, respectively, ξ*3: N3* → *N2*, ϕ*3*= ({*p6*, *p7*, *p14*, *p18*, *p24*, *p25*, *p26*, *p27*},{*t6*, *t7*, *t8*, *t19*, *t20*, *t21*, *t22*}), •ϕ*3*= ({*L3.t6*},{*R3.t6*}), and ϕ*<sup>3</sup>* • = ({*L3.t8*},{*R3.t21*}). The Specifications of S3PR net illustrated in Figure 16 under changeable control specifications are shown in Table 2. In addition, the required monitors using Algorithm 2 of the system illustrated in Figure 16 under changeable control specifications are shown in Table 3.

**Figure 17.** A reconfigured S3PR net by removing a machine. (**a**) Left hand side net *L*. (**b**) Right hand side net *R*.

**Figure 18.** A reconfigured S3PR net by adding a product. (**a**) Left hand side net *L*. (**b**) Right hand side net *R*.

**Figure 19.** A reconfigured S3PR net by rework. (**a**) Left hand side net *L*. (**b**) Right hand side net *R*.





The controlled net after adding above changeable control specifications is illustrated in Figure 20. The place and arcs of the controller are illustrated with blue lines.

**Figure 20.** Controlled reconfigurable S3PR net after adding changeable control specifications.

#### **6. Conclusions**

This paper develops a novel two-step solution for quick and accurate reconfiguration of supervisory controllers for deadlock control in RMSs with dynamic changes. In the first step, the net rewriting system is used to design a reconfigurable PN model under dynamic configurations. The obtained model guarantees boundedness behavioral property but may not guarantee the other properties of a Petri net model (i.e., liveness and reversibility). The second step proposes an automatic deadlock prevention policy for reconfigurable Petri net using the siphon control method based on a place invariant to solve the deadlock problem with dynamic structure changes in RMSs and guarantee the liveness and reversibility properties for the system. The proposed method is validated using the GPenSIM tool and compared with existing methods in the literature to highlight its ability of adapting to RMS configuration changes.

The major advantages of the developed approach are as follows: (1) It does not need to compute reachability graphs as illustrated in Algorithm 2, Section 3, and has low-overhead computation as proved in Theorems 10 and 11, Section 4.4. (2) It can automatically and dynamically modify the structure of a Petri net model without affecting its behavioral properties, i.e., liveness, boundedness, and reversibility as illustrated in Algorithm 2, Section 3. (3) It allows rapid reconfigurability and reusability of the controller during reconfiguration as shown in Algorithm 2, Section 3. (4) It can easily handle any dynamical changes in RMSs compared with the studies in Badouel et al. [39], Llorens and Oliver [34], Wu and Zhou [25], and Kaid et al. [7] as shown in Algorithm 2, Section 3. (5) The GPenSIM code is developed for designing, simulation, validation, and performance analysis of deadlock problems with dynamic structure changes in RMSs and the correctness of the proposed

approach is proven and compared with the studies in Ezpeleta et al. [43], Li and Zhou [44], and Kaid et al. [6] as shown in Section 4.5. (6) Based on Theorems 10 and 11, the computational complexity of the proposed approach has polynomial time complexity. Therefore, it has low computational complexity and can be applicable to other types of complex systems such as mass customization manufacturing, lean productivity, agile manufacturing, and flexible manufacturing systems. (7) It can consider systems with sequential and complex resource requirements, meaning that a set of system resources can be used and shared to process each component according to sequential processes that depend on the step-by-step discrete execution and multiple processes that depend on the execution at the same time as shown in numerical example.

The limitation of the developed approach is that the obtained models lack an appropriate conversion approach from the PN model into control languages for application. Thus, our future research will examine the developed approach to have an automatic method to examine the applicability of the obtained models for real world manufacturing systems.

**Author Contributions:** Conceptualization, H.K. and A.A.-A.; software, H.K. and R.D.; resources, H.K., A.A.-A. and R.D.; formal analysis, H.K. and A.A.-A.; investigation, H.K., A.A.-A. and Z.L.; validation, H.K., A.A.-A., Z.L. and R.D.; writing—original draft preparation, H.K., A.A.-A. and Z.L.; writing—review and editing, H.K., A.A.-A., Z.L. and R.D.; visualization, H.K., A.A.-A. and Z.L.; supervision, A.A.-A., and Z.L. All authors have read and agreed to the published version of the manuscript.

**Funding:** This research was funded by King Saud University through Researchers Supporting Project Number (RSP-2020/62).

**Acknowledgments:** The authors would like to thank King Saud University for funding and supporting this research through Researchers Supporting Project Number (RSP-2020/62).

**Conflicts of Interest:** The authors declare no conflict of interest.
