## 4 Case study Example--Beverage Production and Distribution Machine
### Decomposition of the System  
Let us now decompose the above system according to the second decomposition technique. This time the CPS is oriented into the implementation within integrated device. Let us apply Algorithm 1 in order to decompose the system. Firstly, an incidence matrix \(A_{1}\) of a Petri net \(N_{1}\) is read. The matrix consists of \(|T|=16\) rows and \(|P|=20\) columns, as shown in Figure 3.  
At the first step of the algorithm a unit matrix \(Q\) given as \([D|A_{1}]\) is formed, while \(D\) is equal to the identity matrix. During the subsequent stages, algorithm searches for the place invariants that form proper SMCs. Such operations are executed within steps 2-4, until set \(\mathcal{S}\) (of all found SMCs) cover all places of the Petri net. For the given example, this condition is fulfilled at the 15 th iteration (examination of 15 th transition). The following place invariants are obtained: \begin{table}
\begin{tabular}{c c c} \hline
**Place** & **Output** & **Task** \\ \hline p1 & - & - \\ p2 & y1 & Fill up first container \\ p3 & y2 & Fill up second container \\ p4 & y3 & Load cup \\ p5 & y4 & Warm up 1 st container \\ p6 & y5 & Warm up 2 nd container \\ p7 & y10 & Move trolley to left \\ p8,...,p10 & - & - \\ p11 & y6 & Open first valve \\ p12 & y7 & Open second valve \\ p13 & y8 & Mix ingredients \\ p14,...,p17 & - & - \\ p18 & y9 & Open main valve \\ p19 & y11 & Move trolley to right \\ p20 & y12 & Unload cup \\ \hline \end{tabular}
\end{table} 
Table 2: Association between places and outputs. Figure 3: Incidence matrix \(A_{1}\) of Petri net \(N_{1}\) that describes beverage machine. \(I_{1}=[100100100100000000111]\), with support: \(\{p_{1},\ p_{4},\ p_{7},\ p_{10},\ p_{18},\ p_{19},\ p_{20}\}\), \(I_{2}=[11001001001001001111]\), with support: \(\{p_{1},\ p_{2},\ p_{5},\ p_{8},\ p_{11},\ p_{14},\ p_{17},\ p_{18},\ p_{19},\ p_{20}\}\), \(I_{3}=[10100100101001111]\), with support: \(\{p_{1},\ p_{3},\ p_{6},\ p_{9},\ p_{11},\ p_{14},\ p_{17},\ p_{18},\ p_{19},\ p_{20}\}\), \(I_{4}=[1100100100100101111]\), with support: \(\{p_{1},\ p_{2},\ p_{5},\ p_{8},\ p_{12},\ p_{15},\ p_{17},\ p_{18},\ p_{19},\ p_{20}\}\), \(I_{5}=[1010010010010101111]\), with support: \(\{p_{1},\ p_{3},\ p_{6},\ p_{9},\ p_{12},\ p_{15},\ p_{17},\ p_{18},\ p_{19},\ p_{20}\}\), \(I_{6}=[1100100100001011111]\), with support: \(\{p_{1},\ p_{2},\ p_{5},\ p_{8},\ p_{13},\ p_{16},\ p_{17},\ p_{18},\ p_{19},\ p_{20}\}\), \(I_{7}=[10100100100101111]\), with support: \(\{p_{1},\ p_{3},\ p_{6},\ p_{9},\ p_{13},\ p_{16},\ p_{17},\ p_{18},\ p_{19},\ p_{20}\}\). All the above invariants form proper SMCs, thus set \(\mathcal{S}\) consists of seven components \(\mathcal{S}=\{S_{1},\ldots,S_{7}\}\), as follows:  
\(S_{1}=\{p_{1},\ p_{4},\ p_{7},\ p_{10},\ p_{18},\ p_{19},\ p_{20}\}\), \(S_{2}=\{p_{1},\ p_{2},\ p_{5},\ p_{8},\ p_{11},\ p_{14},\ p_{17},\ p_{18},\ p_{19},\ p_{20}\}\), \(S_{3}=\{p_{1},\ p_{3},\ p_{6},\ p_{9},\ p_{11},\ p_{14},\ p_{17},\ p_{18},\ p_{19},\ p_{20}\}\), \(S_{4}=\{p_{1},\ p_{2},\ p_{5},\ p_{8},\ p_{12},\ p_{15},\ p_{17},\ p_{18},\ p_{19},\ p_{20}\}\), \(S_{5}=\{p_{1},\ p_{3},\ p_{6},\ p_{9},\ p_{12},\ p_{15},\ p_{17},\ p_{18},\ p_{19},\ p_{20}\}\), \(S_{6}=\{p_{1},\ p_{2},\ p_{5},\ p_{8},\ p_{13},\ p_{16},\ p_{17},\ p_{18},\ p_{19},\ p_{20}\}\), \(S_{7}=\{p_{1},\ p_{3},\ p_{6},\ p_{9},\ p_{13},\ p_{16},\ p_{17},\ p_{18},\ p_{19},\ p_{20}\}\). Since the above SMCs cover all places of the Petri net, the designer manually selects the most suitable components and checks, whether obtained solution fulfils the needs. In the presented example, four SMCs are selected as a final result: \(\{S_{1},S_{2},S_{5},S_{6}\}\), while the redundant three \(\{S_{3},S_{4},S_{7}\}\), are reduced from the final solution. At the subsequent step, all places that occur in more than one SMC are manually replaced NOPs. This operation simply substitutes places that belong to multiple components by no-operational ones in order to avoid doubled actions performed by the decomposed controller.