Supervisor Reconfiguration for Deadlock Prevention by Resources Reallocation

Analysis and control of deadlocks play an important role in the design and operation of automated flexible manufacturing systems (FMSs). In FMS, deadlocks are highly undesirable situations, which always cause unnecessary cost. The design problem of an optimal supervisor is in general NP-hard. A computationally efficient method often ends up with a suboptimal one. This paper develops a deadlock prevention policy based on resources reallocation and supervisor reconfiguration. First, given a plant model, we reallocate the marking of each resource place to be one, obtaining a net model whose reachable states are much less than that of the original one. In this case, we find a controlled system for it by using the theory of regions. Next, the markings of the resource places in the controlled system are restored to their original ones.Without changing the structure of the obtained controlled system, we compute the markings of the monitors gradually, which can be realized by two algorithms proposed in this paper. Finally, we decide a marking for each monitor such that it makes the controlled system live with nearly optimal permissive behavior. Two FMS examples are used to illustrate the application of the proposed method and show its superior efficiency.


Introduction
Traditional mass production systems can hardly cope with intensive competition in market and rapid variation in requirements.Hence, automated flexible manufacturing systems (FMSs) arise, aiming to offer a novel production mode with a small batch and multiple product types.The analysis and control of such systems have become the hot topics in the field of manufacturing systems.Petri nets [1] are a graphbased mathematical formalism suitable to describe, model, and analyze the behavior of automated flexible manufacturing systems.
Due to the existence of shared resources, an FMS may contain deadlocks.Based on Petri nets, researchers have developed many policies to deal with the deadlock problem [2][3][4][5][6] in FMS.Generally, there are mainly two analysis techniques to deal with deadlock prevention in FMS: structure [7][8][9][10][11] and reachability graph analysis [12][13][14][15][16].The former always obtains a deadlock prevention policy through special structural objects of a Petri net such as siphons and resource-transition circuits.This method can usually obtain a computationally efficient liveness-enforcing supervisor in general but at the same time restrict a system such that a portion of permissive behavior is excluded.For the latter, the reachability graph can completely reflect the behavior of a system.Though a very highly or even maximally permissive liveness-enforcing supervisor can always be obtained, its computation is very expensive.
As stated, reachability graph analysis [17] is an important technique for deadlock controll; however, it always suffers from a state explosion problem.This is due to the fact that it is impossible to achieve the enumeration of all or a part of reachable markings in practice.Based on this technique, an optimal or suboptimal supervisor with highly behavioral permissiveness can always be obtained for a small system.In [18], Uzam and Zhou develop an iterative approach to design an optimal or suboptimal supervisor.This method is easy to use if the reachable space of a system is small but cannot guarantee the optimality of the supervisor.
The theory of regions developed in [19] can be used as an effective approach to find an optimal liveness-enforcing Petri net supervisor if such a supervisor exists.However, it suffers from computational and structural complexity problems.The work in [20] proposes a vector covering approach to improve the computation efficiency of the work in [19].
A siphon-based deadlock prevention policy is a typical application of structure analysis techniques of Petri nets.Although not optimal and even overly restrictive, this approach is computationally tractable and allows its supervisor to be reused when a system experiences new job instances [2,[21][22][23][24][25][26][27][28].Recent effective and computationally efficient deadlock prevention policies are proposed by Piroddi et al. in [29,30].
Nowadays, the distribution of resources in an FMS may change frequently and dynamically due to fluctuant customer demands.Such changes mean different production or service requirements for the providers.Therefore, the supervisory control system has to reconfigure rapidly in response to the changes in its physical entity and the control specifications by modifying or adjusting its plant model and controller.Once the resource configurations are changed, the supervisors are updated accordingly.Recently, the study in [31] proposes a novel deadlock prevention policy based on reconfiguration of Petri net supervisors.The method presented in [31] is near optimal, but its performance needs to be further improved.
Motivated by existing work, this paper presents an effective and computationally efficient method to design nearly optimal control places based on resources reallocation and supervisor reconfiguration.The main idea of the method is stated as follows.
(iv) Without changing the structure of the controlled system (  ,   ), we compute the markings of the monitors gradually.Finally, we decide a marking for each monitor such that for all  ∈  0 ∪   ∪   ,   () =  0 (), and for all V ∈   ,   (V) makes the controlled system (  ,   ) live, where (  ,   ) is a controlled system for (,  0 ) with   =  1 .
The rest of this paper is organized as follows.Section 2 briefly reviews preliminaries used in this paper.Section 3 formulates the considered problem through a motivation example.Section 4 presents a deadlock prevention policy that is formalized by Algorithm 2. Two FMS examples are given in Section 5, showing the superiority of the proposed method.A comparison between the proposed method and a previous one is made in Section 6.Finally, Section 7 concludes this paper.
Firing it yields a new marking   such that for all  ∈ ,   () = ()−(, )+(, ), as denoted by [⟩  .  is called an immediately reachable marking from .Marking   is said to be reachable from  if there exists a sequence of transitions  =  0  1 . . .  and markings  1 ,  A -vector is a column vector  :  → Z index by  and a -vector is a column vector  :  → Z index by , where Z is the set of integers. is a -invariant if  ̸ = 0 and   [] = 0  .A -invariant  is said to be a -semiflow if every element of  is nonnegative.
A nonempty set  ⊆  is a siphon if •  ⊆  • .A siphon is minimal if there is no siphon contained in it as a proper subset.A minimal siphon that does not contain the support of any -invariant is called a strict minimal siphon (SMS).
A marking  of a Petri net  is a mapping from  to N. () denotes the number of tokens in place .A place  is marked at a marking  if () > 0. A subnet  ⊆  is marked at a marking  if at least one place in  is marked at .The sum of tokens of all places in  is denoted by (), that is, () = ∑ ∈ (). is said to be empty at  if () = 0. (,  0 ) is called a net system or marked net and  0 is called an initial marking of .
Markings and vectors are usually represented via using a multiset.As a result, vector  is denoted by ∑ ∈ ().For instance, a marking that puts two tokens in place  1 and three tokens in place  3 only in a net with  = { 1 −  6 } is denoted as  = 2 1 + 3 3 instead of (2, 0, 3, 0, 0, 0)  .
Let  ∈  ∪  be a node of net  = (, , , ).The preset of  is defined as With respect to the concepts of supervisors and controlled systems, the reader is referred to [14].A supervisor is said to be optimal if its resulting controlled system covers all safe states of a plant and every reachable state in the controlled system is a safe state of the plant.Such a controlled system is said to be optimal.

M-Nets.
This paper considers a class of manufacturingoriented Petri nets, M-nets [31].It is a generalization of the existing net classes that can model FMS.In this paper, we just focus on the research of ordinary M-nets, a type of M-nets.Definition 1.An M-net denoted by (,  0 ) satisfies the following statements: (4) For all  ∈   , it is associated with a minimal semiflow   such that   () = 1, for all  ∈   ,   () ≥ 0, and for all  ∈  0 ,   () = 0.
(11) An uncontrolled siphon in (,  0 ) contains at least one resource place and one activity place but no idle process place.
(13) If (,  0 ) is not live, liveness can be enforced by adding monitors whose addition leads to a controlled system.( 14) Let (  ,   0 ) be a controlled system for (,  0 ).(  ,   0 ) is live if it is ordinary and no siphon is unmarked.(  ,   0 ) is live if it is generalized and satisfies the controlled-siphon (cs) property.(15) Let   be the set of monitors in (  ,   0 ).For all V ∈   , there exists a minimal -semiflow  V such that  V (V) = 1 and for all  ∈ ‖ V ‖ \ {V},  ∈   .
In order to make Definition 1 clear, an example is given in Appendix A. It is easy to find that M-nets are more general than almost all manufacturing-oriented Petri nets, for example, the ones in [2,22,24,32].

An MIP-Based Deadlock Detection Method.
In this paper, by using a technique that is called the mixed integer programming (MIP) approach proposed in [32], siphons that cause deadlocks can be detected.Let (,  0 ) be an ordinary net with  = (, , ) and  the maximal empty siphon at , that is, for all  ∉ , () > 0. Finding  in  is the solution of a mixed integer programming problem.For all  ∉ , let V  = 1 and for all  ∉  • , let   = 1.
It is easy to see that any  with V  = 1 and any  with   = 1 are removed from the net.Since  is a siphon, we have that for all  ∈  • , V  = 0 implies   = 0 and for all  ∈  • ,   = 1 implies the truth of V  = 1.This leads to V  ,   ∈ {0, 1} .
For a structurally bounded net, we have where SB() = max{() |  =  0 + [],  ≥ 0,  ≥ 0} is the structural bound of place .Therefore, the maximal siphon unmarked at a given marking  can be determined by the following MIP problem and there exist siphons unmarked at  iff  MIP < || [32]: s.t.constraints (1)-( 4) and where [] is the incidence matrix and  and  are vectors of real numbers.Relation  =  0 + [] is usually called the state equation.

Structure Design of a Petri Net Supervisor
Now, let us go briefly through the processes by using the theory of regions to design a supervisor for a Petri net model.
One first needs to generate its reachability graph.Then, the set of marking/transition separation instances should be found, whose number is in theory exponential with respect to the net size and the initial marking.Finally, for each instance, a monitor should be found by solving a linear programming problem in which the number of constraints is approximately equal to that of nodes in the reachability graph.For such a method, the size of a reachability graph is rather sensitive to the size and the initial marking of a net.These facts make it infeasible for the theory of regions to be applied to real-world problems.
With the purpose of formulating the proposed method even more clearly, we design Algorithm 1 to find a controlled system ( 1 ,  1 ) for ( 1 ,  1 ) that can be obtained by reallocating the marking of each resource place in (,  0 ) to be one, with  1 = ( 0 ∪   ∪   ∪   , ,  1 ,  1 ).Proposition 5. Let ( 1 ,  1 ) be the resulting net from adding monitors to an ordinary M-net ( 1 ,  1 ) by using Algorithm 1. Then ( 1 ,  1 ) is ordinary and live.
The proof of Proposition 5 is given in Appendix B. In order to illustrate Algorithm 1, consider a small example from [31].Figures 1(a) and 1(b) show an ordinary M-net (,  0 ) and its corresponding reachability graph with eight reachable states, respectively.Now by applying Algorithm 1 to (,  0 ), a plant mode ( 1 ,  1 ) can be obtained, as shown in Figure 1(c).It has the same topology structure as (,  0 ) in Figure 1(a) but its resource places have a small initial marking with ( 5 ) = 1 and ( 6 ) = 1.Its reachability graph is shown in Figure 1(d) with five reachable states.Figure 1(e) shows a controlled system ( 1 ,  1 ) for ( 1 ,  1 ), which can be obtained by using the theory of regions [15,19].
The principal objective of reallocating the marking of each resource place to be one is that it is more tractable by using the theory of regions to design a controlled system for ( 1 ,  1 ) than that for (,  0 ).We can see that the reachable states of ( 1 ,  1 ) are five that are less than that of (,  0 ) whose reachable states are eight.One can image the heavy computation if the theory of regions is applied to such a net shown in Figure 1(a), with an initial marking  0 = 100 1 + 80 2 + 50 3 having more than 8 × 10 4 states.Algorithm 1 considers ( 1 ,  1 ), as shown in Figure 1(c), which has five reachable markings only.Therefore, it is easier for us to find a supervisor for ( 1 ,  1 ) than that for (,  0 ).Then, a controlled system ( 1 ,  1 ) for ( 1 ,  1 ) can be obtained by using the theory of regions, as shown in Figure 1(e).
In this section, we propose a method to realize the structure design of a controlled system which can be obtained by Algorithm 1.That is to say, the structure of the supervisors has been found, based on which a deadlock prevention policy will be presented in the next section.

Deadlock Prevention Policy
This section proposes a deadlock prevention policy that can be carried out through the following Algorithm 2. In the previous section, a controlled system ( 1 ,  1 ) can be obtained for ( 1 ,  1 ) with  1 = ( 0 ∪   ∪   ∪   , ,  1 ,  1 ) and  1 = ( 0 ∪   ∪   , , , ).In this section, we can find a controlled system (  ,   ) for (,  0 ) by restoring the markings of the resource places in ( 1 ,  1 ) to their original ones and then computing a marking for each monitor.That is to say, even if the initial marking of the plant model changes, the structure of the controlled system obtained previously can be reused.This implies that we only need to compute the marking of each monitor in the controlled system when the markings of the resource places change.Now, let us consider the relationship between the activity places, the monitors, and the resource places.First, we can find that the tokens that will flow into the activity places can not be greater than that of their holding resource places.Similarly, the tokens in the monitor should be less than that of the resource places which the monitor's activity places hold.That can be expressed by the following: for all  ∈ {1, 2, . . ., }, V  ∈   , (V  ) is the set of the activity places controlled by V  , and for all  ∈ (V  ),  is called the monitor's activity place.  = ( •• (V  )) ∩   , for all  ∈   ,   (V  ) ≤ ∑ ∈  () − 1.Then, an upper limit value for each marking with respect to the monitors V 1 , V 2 ,. .., and V  can be obtained.Finally, we decide a marking for each monitor such that it makes the controlled system live which can be decided by the MIP-based deadlock detection method in [32].Consequently, Algorithm 2 is designed to formulate the proposed method.Let (  ,   ) denote a controlled system for (,  0 ), which has the same net structure as ( 1 ,  1 ) with   = ( 0 ∪  ∪   ∪   , ,  1 ,  1 ).Theorem 6.Let (  ,   ) be a controlled system for an ordinary M-net (,  0 ) by using Algorithm 2. Then (  ,   ) is live.
The proof of Theorem 6 is given in Appendix B. We briefly explain Algorithm 2 as follows.First, a controlled system ( 1 ,  1 ) for ( 1 ,  1 ) can be obtained by using Algorithm 1 in the previous section.Next, the markings of the resource places in ( 1 ,  1 ) are restored to their original ones.Then, we compute an upper limit value for the marking of each monitor and denote it by . .,   (V  ), . . .,   (V  )]  ,  ∈ {1, 2, . . ., }.If the marking vector ⃗  makes the controlled system live, we stop the algorithm and the marking vector ⃗  is the result we want to obtain.If the marking vector ⃗  makes the controlled system not live, then each marking in ⃗  decreases by one; repeat this step until it makes the controlled system live and denote it by That is to say, we obtain a new higher limit value vector ⃗ ℎ and a lower limit value vector ⃗  for the marking of each monitor.Finally, by using Algorithm 2, we decide a marking for each monitor such that for all  ∈  0 ∪   ∪   ,   () =  0 (), and for all V ∈   ,   (V) makes the controlled system live which can be decided by the MIPbased deadlock detection method proposed in [32].
For example, a controlled system (  ,   ) can be obtained for the net in Figure 1(a) by utilizing Algorithm 2, as shown in Figure 2. In the previous section, a controlled system ( 1 ,  1 ) has been obtained, as shown in Figure 1(e).Then, we can find a controlled system (  ,   ) for (,  0 ) by restoring the markings of the resource places in ( 1 ,  1 ) to their original ones with ( 5 ) = 2 and ( 6 ) = 1, and then an upper limit value for the marking of the monitor   can be computed.We can find that the activity places controlled by   are  2 and  3 .Therefore, (  ) = { 2 ,  3 }, { 5 ,  6 } = ( •• (  )) ∩  R .Then, we can obtain that (  ) ≤ ( 5 ) + ( 6 ) − 1 implies that (  ) ≤ 2. As shown in Figure 2, the controlled system is live with (  ) = 2, which can be decided by the MIP-based deadlock detection method in [32].Consequently, the marking (  ) = 2 is the one that we want to obtain.
Given a plant model (,  0 ), we reallocate the marking of each resource place to be one, obtaining a net model ( 1 ,  1 ).By using Algorithm 1, a controlled system ( 1 ,  1 ) for ( 1 ,  1 ) can be obtained.Then, the markings of the resource places in ( 1 ,  1 ) are restored to their original ones.On the premise of not changing the structure of the controlled system, we compute the marking of each monitor by Algorithm 2. That is to say, even if the initial markings of the plant model change, the structure of the controlled system obtained previously can be reused.This implies that we only need to compute the marking of each monitor in the controlled system without changing the supervisor's structure.Figure 3 shows the flowchart of the proposed deadlock control strategy.

Experimental Studies
In order to show the advantage of the proposed method, this section provides two typical examples that are taken from [31].The computational results indicate that the proposed deadlock prevention policy is nearly optimal and superior to the one in [31].
An FMS consists of two robots R1 and R2 and three machines M1-M3.Its model is shown in Figure 4(a).It is an ordinary M-net, where  1 and  10 are idle places,  11 − 15 are resource places, and the others are activity places.As shown in Figure 4(b), ( 1 ,  1 ) is the controlled system for the net ( 1 ,  1 ) with the initial marking of each resource place being one.
To illustrate Algorithm 2, consider ( 1 ,  1 ) shown in Figure 4(b).The activity places  4 and  9 are controlled by V 1 and hold the resource places  12 and  14 , respectively.That can be expressed by the following: 13 ,  14 ,  15 }.Based on Algorithm 2, the marking of the monitor V 1 should be less than the total markings of the resource places  12 and  14 .That can be expressed by an inequality: Much the same can be applied to monitors V 2 and V 3 .The inequalities can be obtained as follows: Now, the net under initial marking 4 1 + 4  method.From ( 7) and ( 8), the results can be obtained as follows: Therefore, we can obtain an upper limit value for the marking of each monitor and denote it by [3,3,3]  .Then, we find that the marking vector ⃗  makes the controlled system live which can be decided by the MIP-based deadlock detection method proposed in [32].Therefore, the marking vector [  (V 1 ),   (V 2 ),   (V 3 )]  = [3,3,3]  is the result we want to obtain.It can be verified that the controlled model in Figure 4(b) under initial marking 4 1 + 4 10 + 2 11 + 2 12 + 2 13 + 2 14 + 2 15 with (V 1 ) = 3, (V 2 ) = 3, and (V 3 ) = 3 obtained by the proposed method is live with 1032 reachable states.Compared the proposed method with the one in [31] with 941 states, it can be clearly seen that we have achieved a better result, what we call a near-optimal result.
Compared with the method in [31], the superiority of the proposed policy can be verified.Table 1 shows the permissive behavior of the controlled systems under different initial markings, where the markings of the monitors are decided by Algorithm 2. In this table,   is the number of reachable states of (,  0 ),   represents the number of states that an optimal controlled system for (,  0 ) has,   indicates the number of states of the controlled system (  ,   ), and   /  implies the optimality degree.In order to make a comparative analysis of the proposed method and the one in [31], let Li's denotes the results in [31].For economy of space, the detailed computational steps are omitted.From this table, we conclude that the proposed method for this example is near optimal and superior to the one in [31].
The second FMS is shown in Figure 5(a).It has two robots R1 and R2, each of which can hold one product at a time.The cell also contains four machines M1-M4, and each of them can hold one part.Parts enter FMS through two automatic loading buffers I1 and I2 and leave it through two unloading ones O1 and O2.The robots deal with the movements of  Figure 6(a) shows its net model that is an ordinary Mnet in which  0 = { 1 ,  8 },   = { 15 ,  16 ,  17 ,  18 ,  19 }, and the others are activity places.The controlled system of such a plant model is shown in Figure 6(b), which can be obtained by the theory of regions [15].
Consider the model shown in Figure 6(b).The monitor V 1 controls the activity places  3 ,  11 , and  12 .The set of their corresponding resource places is { 15 ,  18 }.Therefore, the markings of the monitor V 1 should be less than the total markings of the resource places  15 and  18 .That can be expressed by an inequality: The same situation can be applied to monitors V 2 , V 3 , V 4 , V 5 , and V 6 .The inequalities can be obtained as follows:  (V 2 ) ≤ ( ( By exploiting Algorithm 2, the markings for the monitors can be obtained, as shown in Table 2.For economy of space, the computational steps for the system are not shown in detail.Table 2 shows the performance of the controlled systems under different initial markings.From this table, it is verified that the proposed method for this example is nearly optimal and may even achieve optimality.It is obviously superior to the method in [31].

Comparision of Computational Efficiency
The deadlock prevention method proposed in [31] needs to calculate all SMS in the controlled system and infer algebraic inequalities.An improved method of avoiding this problem is presented in this paper, which is simple and practicable.To illustrate the application of the proposed method, two FMS examples are used in this paper.A comparison between the proposed method and the one in [31] is shown in Tables 1 and  2. The superiority of the proposed one is obvious.For a class of FMS considering resource allocation, this paper proposes a deadlock prevention policy by resources reallocation and supervisor reconfiguration, which can make a good tradeoff between optimality and computational tractability for a class of ordinary Petri nets.

Conclusion
The deadlock prevention policy is a static strategy that imposes restrictions on the interactions among resources and processes such that resource requests that may lead to deadlocks are prevented.Behavioral permissiveness is very important in designing a liveness-enforcing supervisor for a system to be controlled.An optimal liveness-enforcing supervisor can lead to high utilization of system resources.This paper proposes a deadlock prevention policy by resources reallocation and supervisor reconfiguration.Given a plant model, we first reallocate the marking of each resource place to be one, and then find a controlled system by using Algorithm 1. Next, the markings of the resource places in the controlled system are restored to their original ones.Without changing the structure of the controlled system, we compute the markings of the monitors.Finally, we decide a marking for each monitor such that it makes the controlled system live which can be realized by Algorithms 2 proposed in this paper.For a fixed net structure with different initial marking, the theory of regions is used once only.That is to say, the supervisory control system can be reconfigured rapidly in response to the changes in the initial markings of the plant model.Two FMS examples are used to illustrate the application of the proposed method and show its superior efficiency.However, the proposed method suffers from the computational complexity problem due to the theory of regions.In theory, it suffers from the exponential complexity.Future efforts will be made to a near-optimal supervisor with low computational costs.In addition, the proposed method is applicable to ordinary M-nets only.Therefore, our future work will extend this method to more general classes of Petri nets, for example, the ones in [34,35].

A. An Example for Definition 1
As the net shown in Figure 7, it is an M-net, where  1 is an idle process place,  2 ,  3 , and  4 are activity places, and  5 and  6 are resource places.It is quasi-live, bounded, and conservative.It is live if no siphon is uncontrolled.
Proof.It follows immediately from the definition of an ordinary M-net that it is a class of ordinary Petri nets.According to Theorem 2, the result is true.
The proof of Proposition 5.
Proof.It follows immediately from the theory of regions that ( 1 ,  1 ) is live.( 1 ,  1 ) is excluded by Algorithm 1 if it is a generalized net.Therefore, the result is true.
The proof of Theorem 6.
Proof.According to Proposition 5, ( 1 ,  1 ) is ordinary and live.The structure of the controlled system (  ,   ) is the same as that of the ( 1 ,  1 ).That is to say, (  ,   ) is an ordinary controlled system as well as an M-net according to Definition 1.Then, from Theorem 4, (  ,   ) is an ordinary M-net, (  ,   ) is live if  MIP = ||.Therefore, the result is true.

1 Figure 3 :
Figure 3: Flowchart of the deadlock prevention policy.

Figure 5 :
Figure 5: (a) Layout of an FMS and (b) routes of part types P1 and P2.

Figure 6 :
Figure 6: (a) Petri net model of an FMS and (b) structure of the controlled system.