# Dealing with Deadlocks in Industrial Multi Agent Systems
## 5 More Complicated Examples
### Example 4  
Consider the PN model given in Figure 7. There are 16 places and 12 transitions.  
Figure 6: The PN model (**left**) with its supervisor (**right**) created by three monitors and their interconnections with the uncontrolled model.  
The transpose of the incidence matrix is the following  
\[\mathbf{N}^{T}=\left(\begin{array}{cccccccccccccccc}1&0&0&0&0&0&-1&0&0&0&0&0&- 1&0&0&0\\ -1&1&0&0&0&0&0&0&0&0&0&0&1&0&-1&0\\ 0&-1&1&0&0&0&0&0&0&0&0&0&0&-1&1&0\\ 0&0&-1&1&0&0&0&0&0&0&0&0&0&1&-1&0\\ 0&0&0&-1&1&0&0&0&0&0&0&0&-1&1&0\\ 0&0&0&0&-1&0&0&0&0&0&0&0&-1&1&0\\ 0&0&0&0&0&0&0&0&1&-1&0&0&0&-1&1\\ 0&0&0&0&0&0&0&0&1&-1&0&0&0&-1&1\\ 0&0&0&0&0&0&0&0&1&-1&0&0&0&-1\\ 0&0&0&0&0&0&0&0&0&1&-1&0&0&0&-1\end{array}\right)\]  
The siphons and traps are the following.  
\[\begin{array}{l}\mathcal{E}_{1}=\{p_{11},p_{10},p_{10}\}\\ \mathcal{E}_{2}=\{p_{11},p_{13},p_{14},p_{15},p_{16}\}\\ \mathcal{S}_{3}=\{p_{10},p_{15},p_{2},p_{4}\}\\ \mathcal{E}_{4}=\{p_{14},p_{15},p_{16},p_{17}\}\\ \mathcal{S}_{5}=\{p_{14},p_{15},p_{16},p_{17}\}\\ \mathcal{S}_{6}=\{p_{14},p_{15},p_{16},p_{17}\}\\ \mathcal{S}_{7}=\{p_{10},p_{11},p_{12},p_{18},p_{19}\}\\ \mathcal{S}_{8}=\{p_{13},p_{14},p_{15},p_{16},p_{17}\}\\ \mathcal{S}_{9}=\{p_{13},p_{14},p_{15},p_{16},p_{18}\}\\ \mathcal{S}_{10}=\{p_{11},p_{12},p_{13},p_{14},p_{15},p_{16}\}\\ \mathcal{S}_{11}=\{p_{11},p_{12},p_{13},p_{14},p_{15},p_{16},p_{17}\}\\ \end{array}\]  
Here, \(S_{1}=T_{1}\), \(S_{2}=T_{2}\), \(S_{4}=T_{5}\), \(S_{7}=T_{8}\), \(S_{10}=T_{10}\). Consequently, \(S_{1}\), \(S_{2}\), \(S_{4}\), \(S_{7}\), \(S_{10}\) cannot be emptied. It is sufficient to prevent \(S_{3}\), \(S_{5}\), \(S_{6}\), \(S_{8}\), \(S_{9}\) before emptying. Rename them to be, respectively, \(S_{1}\), \(S_{2}\), \(S_{3}\), \(S_{4}\), \(S_{5}\). Hence,  
\[\mathbf{S}=\left(\begin{array}{cccccccccccccccc}0&1&0&1&0&0&0&0&0&1&0&0&0& 0&1&0\\ 0&0&0&0&1&0&0&0&1&0&0&0&1&1&0\\ 0&0&0&0&0&1&0&0&1&0&0&0&1&1&1\\ 0&0&0&0&1&0&1&0&0&0&1&1&1&0\\ 0&0&0&0&0&1&0&1&0&0&0&1&1&1&1\end{array}\right) \tag{40}\]  
Figure 7: The PN model.  
\[\mathbf{N}_{c}=\mathbf{S}.\mathbf{N}=\left(\begin{array}{cccccccccccccccc}0&0&0&0&0&0&0&0&0&0&0 &0\\ 0&-1&0&0&1&0&0&0&0&1&-1&0\\ 0&-1&0&0&0&1&0&0&0&1&0&-1\\ -1&0&0&0&1&0&0&0&1&0&-1&0\\ -1&0&0&0&0&1&0&0&1&0&0&-1\end{array}\right) \tag{41}\]  
Thus, we obtain five monitors \(V_{S_{1}}-V_{S_{5}}\) (creating the supervisor) and their interconnections with the uncontrolled PN model. In order to establish marking of these monitors the following settings are necessary: \(M_{0}(S_{i})-M_{1}(V_{S_{i}})>0\), \(i=1,\ldots,5\). Because \(M_{0}(S_{1})=1\), \(M_{1}(V_{S_{1}})=0\). Analogically, \(M_{0}(S_{2})=2\), \(M_{1}(V_{S_{2}})=1\); \(M_{0}(S_{3})=3\), \(M_{1}(V_{S_{3}})=2\); \(M_{0}(S_{4})=3\), \(M_{1}(V_{S_{4}})=2\); \(M_{0}(S_{5})=4\), \(M_{1}(V_{S_{5}})=3\). With markings of monitors set in such a way, we obtain the controlled PN model without any deadlocks. RT of the controlled PN model has 54 nodes including the initial marking \(\mathbf{M}_{0}=(0,\,0,\,0,\,0,\,0,\,0,\,1,\,0,\,0,\,0,\,1,\,1,\,1,\,1,\,1,\,1, \,1,\,1,\,2,\,2,\,3)^{T}\). These nodes represent the space of reachable markings of the controlled PN model. The interconnection between original uncontrolled PN model and the supervisor represented by the set of monitors is realized by means of the incidence matrix \(\mathbf{N}_{c}\), namely by \(\mathbf{N}_{c}^{+}\) and \(\mathbf{N}_{c}^{-}\). The supervisor is displayed in Figure 8 (right) together with the uncontrolled system (left).