An Optimal Deadlock Recovery Algorithm for Special and Complex Flexible Manufacturing Systems-S₄PR

Eliminating deadlocks and reserving maximal permissiveness together is an important and hot issue for all kinds of flexible manufacturing systems. Many experts are making much effort to obtain optimal control algorithms. However, most researchers cannot obtain the real optimal controllers even though their policy is maximally permissive, especially for special S4PR (Systems of Sequential Systems with Shared Resources) systems. Based on this reason, this paper tries to propose a novel recovery policy to recover systems’ all states based on control transitions (CT). Therefore, the system can hold the real maximal permissive states. Especially, we propose the concept of the shortest path selected marking (SPSM) so that we can hence obtain the recovery transition. Furthermore, our proposed concept avoids solving integer linear programming problems (ILPP) based on our algorithm method. Moreover, three examples of S4PR Petri net models (PNM) with deadlocks are illustrated in our proposed algorithm. Experimental data shows that our policy can not only prevent the deadlocks but reserve all initial markings in S4PR. Please notice that this proposed recovery policy seems the first one applied for S4PR by using control transitions and still obtaining the best permissiveness whatever their algorithms among existing literature belong to use control places or control transitions.


I. INTRODUCTION
Nowadays is an era of digitization, mechanization, diversification, and artificial intelligence. The flexible manufacturing systems (FMS) are more suitable for this era working on factory production. Fortunately, the Petri net (PN) has been recognized as the most potent semantic-based tools for modeling discrete events and dynamic systems. Moreover, PN can search deadlocks prediction when one constructs an FMS. Therefore, how to avoid, prevent, or detect recovery deadlocks methods are presented.
Generally, two analysis methods are mainly used to formulate FMS deadlock prevention strategies: system structure analysis [3]- [6], [9], [19], [21]- [24], [30], [34], [35] and reachability graphs analysis [7], [8], [20], [39]- [43], [46]- [48]. The former relies on structural analysis, such as the concept of siphon control, to design a suitable control The associate editor coordinating the review of this manuscript and approving it for publication was Zhiwu Li . subnet to solve the deadlock problem. With this strategy, the calculations are usually simple, but will encounter explosion problems, because as the model becomes larger and more complex, the number of siphons increases exponentially. Li and Zhou [22]- [24] first presented searching the elementary siphon method. Their motivation is to control explicitly and reduce the dependent siphons. Then, the effect of elementary siphon control is more than siphon control to prevent the deadlocks.
The latter can be adopted to design the maximally permissive controllers. Under this analysis method, a system's reachability graph is needed to compute firstly. Besides, all reachable markings in a reachability graph are also needed to identify. Accordingly, Uzam [7] firstly proposed the novel concepts of Deadlock Zone (DZ) and Deadlock-Free Zone (DFZ) based on the theory of regions [25] to design an optimal deadlock prevention policy. On the other hand, Ghaffari et al. [39] also redefine the theory of regions and introduce three new definitions of dangerous VOLUME 9, 2021 This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/ markings, forbidden markings, legal markings, and the set of Marking/Transition-Separation Instances (MTSI). For enhancing computational efficiency of the conventional theory of regions, Huang and Pan [40], [41], Huang et al. [42], and Pan et al. [43] even put forward the concept of crucial MTSI (CMTSI). It is worth noting that these adopted CMTSI deadlock prevention policies still make a controlled system maximally permissive. In addition, many experts have invested some new concepts in the field of deadlock prevention for solving the FMS's deadlock problem [1], [2], [44]- [48], [50]- [52]. For example, Chen et al. [1], [2] use interval inhibitor arcs to forbid reaching illegal markings. Pirrodi et al. [44] utilize siphons and markings to design maximally permissive controllers. Pan et al. [45] combine the theory of regions and selective siphons to obtain more efficient controllers. Chen et al. [46] proposed an MFFP (i.e., the Maximal number of Forbidding First bad marking (FBM) Problem) concept to obtain maximally permissive controllers, etc. However, above all mentioned algorithms could inevitably lose parts of original reachable markings even they are maximally permissive since they cannot recover deadlock and quasi-deadlock markings. They merely prevent legal markings from running to deadlock or quasi-deadlock zone.
Thus, Huang et al. [10] were the first to present the idea that prevented deadlocks and kept original markings by using control transitions. Simultaneously, Huang et al. [11] constructed the algorithm roughly to prevent deadlocks from occurring and reserve original reachable markings successfully. Yet, they cannot avoid the redundant control transitions. In [12], Huang et al. proposed a deadlock detection and recovery method to reduce redundant control transitions. However, its controllers could not become optimal in a larger or more complicated system due to its manual designing process. In other words, in [12], it does not show any formalized equation in its algorithm.
Motivated by the work in [12], Zhang and Uzam [13] develop a set covering technique to derive the minimal control set from enhancing computational efficiency. Finally, a deadlock S 3 PR PNM can be recovered successfully by adding the minimal control transitions. However, it is a pity that they merely demo two small S 3 PR PNM from [12], although according to their conclusion, the proposed method can be applied in pure and bounded Petri net models of FMSs.
Based on transition-based techniques, Row and Pan [15] also present two novel deadlock prevention algorithms, the All Reachability Graph (ARG) viewpoint and the First Deadlock Marking (FDM) viewpoint, to obtain maximally permissive live states and recover all original deadlock markings for an original PN model.
Similarly, Row et al. [17] present a deadlock recovery policy using control transitions. Its method can detect the maximum reachable markings under the same system structure before the recovery algorithm is used. Besides, it can use fewer controllers among existing literature [12], [15] to recover all deadlock and quasi-deadlock markings in a controlled system. The first one uses transition-based controllers to successfully recover the large classical S 3 PR PNM with 26750 reachable markings [3].
At the same time, Bashir et al. [16] also used iterative procedures to design deadlock recovery based on control transitions. First, to prevent the state explosion problem in the reachability graph analysis, the structural characteristic of PNM is considered. Then, calculate the control transition and add it to the deadlock PNM to recover the deadlock markings. Nevertheless, this method is still not the most ideal because it cannot fully recover PNM.
On the other hand, Chen et al. [14] proposed another novel transition-based recovery policy and developed two different kinds of algorithms. The first one uses an iterative approach. In each iteration step, the integer linear programming problem (ILPP) is calculated to obtain a control transition until all deadlock states are covered. The second is a one-time skill. Therefore, one can find and pick up all controllers. According to their experimental results, these two algorithms have indeed successfully restored two classic S 3 PR examples. However, according to [26], it has a computational complexity problem because there are too many constraints and variables in the formulated ILPP. Therefore, Dong et al. [26] proposed an improved deadlock recovery method to solve the FMS deadlock problem based on vector analysis. In addition, iteratively calculates a small number of recovery controllers to recover all illegal markings. Therefore, it does show better computational efficiency than [14]. However, this method is still NP-hard because it must solve ILPP.
Recently, Pan [18] proposed a deadlock recovery strategy based on the concept of a three-dimensional matrix called Generation and Comparison Auxiliary Matrix (GCAM). The recovery controllers of a deadlock PNM can hence be obtained once its GCAM is built. Finally, an iterative method is used until all deadlock and quasi-deadlock markings become legal markings. According to the experimental results [18], the GCAM method does obtain optimal with the least number of controllers. However, its computational cost will rise sharply in a large PNM since it has to build a three-dimensional matrix between every deadlock marking with all legal markings.
The above all deadlock recovery methods by using control transitions focus on classic S 3 PR PNM, although we all know that all transition-based methods are not limited to S 3 PR. In fact, in the existing literature, we have not seen any research paper using control transition in S 4 PR PNM. Thus, in this paper, we first try to solve deadlocks for S 4 PR PNM by using control transitions.
The rest of this article is organized as follows. The second section describes the basic definition of Petri nets and reachability graph analysis. The third section proposes the proposed control method. The fourth section introduces the experimental results. The fifth section gives a comparison. Finally, conclude Section VI.

II. PRELIMINARY
A. PETRI NETS [29] A Petri Net (PN) is a five-tuple N = (P, T , F, W , M 0 ). P and T are two finite, nonempty, and disjoint sets. P represents a set of places, and T represents a set of transitions. The relation between P and T is that (P ∪ T = ∅) and (P ∩ T = ∅). The relation F, P, and T is F ⊆ {(P × T ) ∪ (T × P). It represents the set of arcs of a PN, symbolized by arrows going from P to T or T to P denotes a flow relation in the PN model. W : (P × T ) ∪ (T × P) → N is a mapping that assigns a weight to an arc: W (x, y) > 0 for each (x, y) ∈ F, where x, y ∈ (P ∪ T ) and N is the set of non-negative integers.
A marking M is a multiset of PN places, which allocates tokens to each place of a PN model. M (p) denotes the number of tokens in place p. M 0 represents the initial marking of N . A PN is pure if no place is both input and output places of the same transition. The incidence matrix ∈ P A ,(p 0 is called a process idle place); (2) N is a strongly connected state machine; and (3) every circuit of N contains place p 0 .

Definition 3:
A System of Simple Sequential Process with Resources (S 3 PR) [3] is defined as the union of a set of nets N i sharing common places, called resource places P Ri , such (4) any two N i are composable when they share a set of common resource idle places. In the above definition, p 0 i is called the process idle place and P i the set of operation places. The N i shall be called a process net.
Definition 4: A Systems of Sequential Systems with Shared Resources (S 4 PR) [36], [38]: 2) P 0 , P A , P R are called the process idle places, operation places and resource places respectively. T is called the set of transitions.
strongly connected state machine such that every circuit of the state machine contains idle place p 0 .

C. REACHABILITY GRAPH (RG) ANALYSIS
In this paper, the proposed algorithm needs to analyze the reachability graph and identify all reachable markings. The detailed information of these definitions is shown as follows: Deadlock markings and Quasi-deadlock markings are collectively called illegal markings. The illegal marking is defined as follows: Except for quasi-deadlock and deadlock markings, the other reachable markings are legal ones.
Besides, Definition 9: An area composed of all deadlock markings is called the deadlock zone, denoted by Z D .
Definition 10: An area composed of all quasi-deadlock markings is called the quasi-deadlock zone, denoted by Z Q .
Definition 11: An area composed of all quasi-deadlock and deadlock markings is called the illegal zone, denoted by Z I .
Definition 12: An area composed of all legal markings is called a legal zone, denoted by Z L .

III. CONTROL METHODOLOGY
This section wants to further propose a novel control methodology with Petri nets and reachability graph analysis. Note that the deadlock markings and legal markings are used to calculate control transition (CT).

A. THE DESIGN CONCEPT OF CONTROL TRANSITION (CT)
According to above mention Petri nets theory and reachability graph analysis. An enabled transition undoubtedly can change one marking to another one. Therefore, if we can find an enabled transition to make a deadlock marking a legal one, the enabled transition could be used to design control transition (CT). Note that it will form a livelock [49] situation if we use an enabled transition between M D and M Q as control transition (CT). In detail, a livelock situation is similar to a deadlock, except that the states of the processes involved in the livelock constantly change to one another, none progressing. The term was coined firstly by Edward A. Ashcroft in a 1975 paper [49]. The design concept diagram of control transition (CT) is shown in FIGURE 1. FIGURE 2 is a typical S 4 PR PNM [27], [32], and its reachable graph is shown in FIGURE 3.      According to [14], [18], for anyone deadlock marking, one can choose all legal markings to form a control transition (CT) once the M D and M L are identified. In other words, in this example, M 0 ∼ M 3 , M 5 ∼ M 7 , M 9 ∼ M 11 , and M 13 ∼ M 17 could be chosen to obtain a control transition (CT). To easily understand our design concept of control transition, we try to pick the legal marking M 9 and the deadlock marking M 12 as an illustration. Firstly, based on Petri nets' state equation, the legal marking M 9 can be fired to the deadlock marking M 12 through the single transition t 1 . In this case, the state equation in Equation (1) is as below: In other words, if we want to design a control transition (CT) denoted t c in this deadlock PNM and push the deadlock marking M 12 back the legal marking M 9 , the state equation can be rewritten in Equation (2) as follows: Note that in Equation (2), the unknown a, b, c, d, e, f, g, h, i, j, and k belong to the integer since they are the elements of the incidence matrix of FIGURE 2. Besides, we move M 12 to the right side of the state equation. Equation (2) can be present in Equation (3) form as below: Accordingly, we can obtain that a = 1, b = −1, i = 4, and c = d = e = f = g = h = j = k = 0 based on the legal marking M 9 − the deadlock marking M 12 . The designed control transition (CT) in this case can then be identified shown in Equation (4): According to Definition 13, there are usually many legal markings in a deadlock PNM. Therefore, identifying the crucial legal marking so that it can be used to design control transition (CT) is a worth issue. In the following, we will give the formal definitions to identify crucial legal markings from the set of legal markings M L , called the Shortest Path Selected Marking (SPSM). The deadlock S 4 PR PNM could hence be controlled with a simpler algorithm and better computational efficiency. The SPSM is defined as follows:   For further understanding the detailed information of seeking Type II SPSM. FIGURE 6 shows that the shorter path σ * is what we want since |σ * | < |σ | (i.e. |σ * | = 1 and |σ | = 3). Remark 1: A deadlock marking must be with its corresponding SPSM. According to above definitions, the corresponding SPSM is of either Type I SPSM (M SPSM ) or II (M SPSM ).
Remark 2: Note that Type I SPSM (M SPSM ) should be identified and processed firstly for a deadlock marking. Proof: According to Theorem 1, a deadlock marking must be covered with its corresponding SPSM if M D = ∅. Therefore, the obtained all controllers t c based on M SPSM ∪M SPSM can recover their corresponding deadlock markings. Then, we use loop and iteration to find out the optimal controllers which can recover the most deadlock markings. The process cannot terminate until all deadlock markings in M D are recovered. Finally, we can obtain a set of recovery controllers to recover all deadlock markings. The conclusion holds. ♦ We discuss the computational complexity of the proposed algorithm. Firstly, it requires computing the reachability graph of a PNM. Undoubtedly, it suffers from the state's explosion problem. The reachability graph will be calculated at each iteration due to the M L and M D change after adding the controller to the PNM. Under the proposed policy, generally, M L extends, and M D reduces after every iteration. Secondly, this proposed algorithm is not an NP-hard problem since it does not to solve the Linear Programming Problems (LPPs). Although repeating analysis to generate a reachability graph makes more computation heavy, designing  while Run reachability graph analysis end while 9. Output completely recovered system with M D = ∅.
supervisors is still much more time-saving and systematic than other methods, such as Chen et al. [14] and Pan [18], since they both need to check all legal markings for calculating every deadlock marking.

IV. EXAMPLES
There are three examples used to illustrate our proposed deadlock recovery algorithm.

A. EXAMPLE 1
The example 1 [27], [32] shown in FIGURE 2 is a simple S 4 PR PNM with a deadlock marking, and the number of reachable markings of reachability graph is 18. To prevent deadlock, 18 reachable markings (M 0 to M 17 ) are identified according to the software TINA [31]. A deadlock marking M 12 , two quasi-deadlock markings M 4 and M 8 are then located. According to the reachability graph analysis and the definition of SPSM, one can know that Marking 12 (M 12 ) belongs to Type I deadlock marking (M D ) and Marking 9 (M 9 ) is its corresponding Type I SPSM.

B. EXAMPLE 2
A more complex model S 4 PR PNM than Example 1 from [28,33] shown in FIGURE 9 is discussed in this subsection. There are three resource places (r 1 , r 2 , and r 3 ), two idle VOLUME 9, 2021 According to the definitions of SPSM (also can refer to FIGURE 4), one can know that these four deadlock markings all belong to Type I deadlock marking (M D ). Their corresponding Type I SPSMs are shown in TABLE 3. Note that the deadlock marking M 30 has 2 Type I SPSMs since the two legal markings fit the definition 14. Accordingly, their control transition (CT) can then be calculated . TABLE 4 shows the five control transitions. Obviously, t c1 = t c2 = t c4 = (p 1 + r 2 ) -(p 2 ) and t c3 = t c5 = (p 1 + r 2 ) -(p 2 ) from TABLE 4. Therefore, we choose t c1 = (p 1 + r 2 ) -(p 2 ) as the first controller to add into the PNM since it can control the three deadlock markings (i.e., M 3 , M 27 , and M 30 ). When we add the controller to the PNM, obviously, there is only one deadlock marking M 32 left in the system. FIGURE 11 shows this situation. From the reachability graph in FIGURE 11, we can see that all 43 reachable markings are reserved in this PNM. In other words, the first control transition controls and recovers the initial three deadlock markings and their corresponding quasi-deadlock markings. Finally, the optimally controlled system net is obtained with the second control transition t c5= (p 1 + r 2 ) -(p 2 ) when it is added into the deadlock S 4 PR PNM. FIGURE 12 shows the controlled reachability graph. From FIGURE 12, all initial illegal markings are recovered these two control transitions (CT) and become live.

C. EXAMPLE 3
The third most complex S 4 PR PNM among the three examples from [27], [35], [37] shown in FIGURE 13 is a classic example. The PNM has 23 places (i.e., three idle places (p 1 , p 5 , and p 15 ) contained 8 tokens each, 6 shared resource places (p 18 − p 23 or signed R 1 − R 6 ) contained two tokens each, and 14 operation places) and 18 transitions. We not only recover this PNM but make a comparison with other   researches in the existing literature. Firstly, according to the reachability graph analysis, 25 deadlock markings are identified from 19300 initial reachable markings. TABLE 5 shows the detailed information of all 25 deadlock markings based on the software TINA for easy tracking and checking. Note that we do not show the detailed information of legal and quasi-deadlock markings due to the limitation of paper space. In the first iteration, 9 deadlock markings are recovered when the first controller (i.e., • t = p 2 , t • = p 1 + p 19 ) is added into the PNM. In second iteration, 10 deadlock markings are   [27], [35], [37]. recovered when the second controller (i.e., • t = p 10 + p 14

V. DISCUSSION AND COMPARISON OF THE COMPUTATIONAL COMPLEXITY WITH EXISTING LITERATURE
This section will make some comparisons with the existing literature based on the third classical complex number PNM. Notice that the ''CPs'' represents the number of control places, the ''CTs'' represents the number of control transitions, ''R L '' represents the number of live reachable markings, and ''% R L '' represents the recovery percent relative to the original 19300 reachable markings. TABLE 7 shows the performance comparison of eight deadlock solutions, where our work, Chen et al. [14], and Pan [18] are based on the control transition technology, and the others [27], [30], [35]- [37] are based on the control place technology. Further, the methods [30], [35], [36] adopt the siphon concept, but the methods [27], [37] use the P-invariant concept. The computational complexity of their methods is also shown in TABLE 7. The place-based approach needs to add control places to solve the deadlock problems of flexible manufacturing systems. Still, the proposed transition-based method adds transitions to deal with deadlock problems. From the viewpoint of permissiveness in a PNM, all the place-based methods can hold partial or all initial legal markings in the controlled net system. Still, the transition-based method can recover to all initial reachable markings, whether deadlock or quasi-deadlock markings. Therefore, from TABLE 7, it is obvious that our proposed method is the only one that can achieve real 100 % maximally permissive markings using four control transitions among all published researches.
Although Chen et al. [14] and Pan [18] did not apply their algorithm to this example, it has been observed that their proposed algorithm can indeed solve the deadlock problems of this S 4 PR PNM and recover all deadlock markings. In other words, their algorithms can also achieve real 100 % maximally permissive. However, note that their algorithms belong to an NP-hard since they need to solve integer linear programming problems (ILPP). Further, in literature [14] and [28], they both need to solve ILPP formed by deadlock markings and almost all legal markings. However, this paper can identify the crucial legal marking according to our algorithm to obtain the controller directly. There's no doubt that  the proposed method's computational efficiency in this paper is the best among the three ones.

VI. CONCLUSION
Solving FMS's deadlock problems is a boiling issue. Many experts make their all life to do this research. They use all kinds of algorithms to achieve maximally permissive states. However, it is a challenging target even they all claimed that their controllers are optimal. In fact, they do not obtain the real optimal or maximally permissive controllers, whatever algorithms are used. Our previous research successfully calculated the optimal controllers based on control transition (CT) and recovered the S 3 PR PNM. It is a pity that our algorithm cannot obtain optimal controllers for S 4 PR PNM [15], [17]. In theory, the proposed method in this paper is not limited to S 4 PR since it adopted the concept of control transition (CT). Based on scientific spirit, we merely claimed we could use our proposed method to recover the S 4 PR PNM because all present examples in this paper belong to S 4 PR PNM.
In this paper, a novel algorithm based on control transitions (CT) is finally proposed to eliminate deadlocks for S 4 PR PNM. Please note that the proposed algorithm succeeds in recovering all deadlock and quasi-deadlock markings and holds all original markings, whatever they belong to what kinds of markings initially. Moreover, according to our knowledge, this paper is the first one to really apply their algorithm for S 4 PR PNM. Most importantly, we first propose the novel concept of the shortest path selected marking (SPSM) in this domain to avoid solving integer linear programming problems (ILPP) based on our algorithm method. The contribution is obvious and very precious. Of course, some deficiencies need improvements, like the formal proof and redundant calculation. Our future work is to expand the algorithm method and apply it to more complex PNM with deadlocks recovery.