# A Theoretical Foundation for Context-Aware Cyber-Physical Production Systems
## 4 CPPS Models
The number of tokens in the first place \(p_{\emptyset}\) under the initial marking \(m_{j0}\) of the type-j task subnet \(G_{j}=(P_{j},T_{j},F_{j},m_{j0},\mu_{j})\) is \(m_{j0}(p_{\emptyset})=D_{j}\), where \(D_{j}>0\)._  
The final marking of the CPPS model is defined as follows. **Definition 9**. : _For a task subnet \(G_{j}\Big{(}m_{jf}\Big{)}=(P_{j},T_{j},F_{j},m_{jf},\mu_{j})\) in the final state \(m_{jf}\) in which the order requirements for type-j tasks is fulfilled, the number of tokens in the last place \(p_{jN_{j}}\) of the final marking is \(m_{jf}(p_{jN_{j}})=D_{j}\)._  
**Definition 10**. : _Let \(r\) denote the idle place of type-\(r\) resource subnet \(GR_{r}\). The final state of the type-\(r\) resource subnet \(GR_{r}\Big{(}m_{rf}\Big{)}=(P_{r},T_{r},F_{r},m_{rf},\mu_{r})\) satisfies \(m_{rf}(p_{r})=m_{r0}(p_{r})\). That is, resources are in an idle state after processing the required tasks._  
Based on the initial states of tasks and resources, we define the CPPS model in the initial state as \(G(m_{0})=(P,T,F,m_{0},\mu)=G\big{\|}\,GR\), where \(G\big{\}}=\big{\|}\,G\big{\rangle}_{j}(m_{j0})\) and \(GR=\big{\|}\,GR_{r}(m_{r0})=(P_{R},T_{R},F_{R},m_{R0},\mu_{R})\). Based on the final states of tasks and resources, we define the CPPS model in the final state as \(G(m_{f})=(P,T,F,m_{f},\mu)=G\big{\|}\,GR\), where \(G\big{\}}=\big{\|}\,G\big{\rangle}_{j}\Big{(}m_{jf}\Big{)}\) and \(GR=\big{\|}\,GR_{r}\Big{(}m_{rf}\Big{)}=(P_{R},T_{R},F_{R},\,m_{Rf},\,\mu_{R})\). In the CPPS model \(G=(P,T,F,m_{0},\mu)\), a controlled transition is a transition that requires an allocation of resources to be fired. Let \(T_{c}\), where \(T_{c}\subseteq T\), be the set of controlled transitions in \(G\). We define a control action \(c\) as a vector in \(Z^{|T_{c}|}\) that specifies the number of times each transition in \(T_{c}\) to be fired concurrently. A sequence of control actions \(\{c_{n}\}\) is called a control policy \(u\). The behaviors of \(G=(P,T,F,m_{0},\mu)\) under a control policy \(u\) is denoted by \(G_{c}=(P,T,F,m_{0},\mu,u)\). Figure 4: An undesirable state in which the two types of resources are in a circular waiting situation and a subset of transitions can no longer be fired. **Definition 11**. : _A CPPS model \(G=(P,T,F,m_{0},\mu)\) under a control policy \(u\) is represented by a controlled DTPN \(G_{c}=(P,T,F,m_{0},\mu,u)\) and is abbreviated as \(G_{c}(m_{0},u)\), where \(u\) is a control policy that is defined by a mapping \(u\): \(R(m_{0}){\rightarrow}Z^{|T_{c}|}\) that generates a sequence {\(c_{n}\)} of control actions for \(G_{c}\)._  
A control action \(c\) is a vector in \(Z^{|T_{c}|}\) that specifies the number of times each transition in \(T_{c}\) to be fired concurrently. Suppose \(T_{c}=\{t_{1},t_{2},t_{3},t_{5},t_{6},t_{7}\}\). For the marking in Figure 2(a), the control action \(c=[2\ 0\ 0\ 0\ 0\ 0]\) can be applied to fire transition \(t_{1}\) twice. A sequence of control actions to be executed in the CPPS model define a control policy. Not all control policies can preserve the liveness property of the system. For the example in Figure 2(a), \(c_{1}=[2\ 0\ 0\ 0\ 0\ 0]\), \(c_{2}=[0\ 2\ 0\ 0\ 0\ 0]\) and \(c_{3}=[1\ 0\ 0\ 1\ 0\ 0]\) are three control actions that can be applied consecutively from the marking in Figure 2(a). Applying the sequence of control actions \(c_{1}\), \(c_{2}\) and \(c_{3}\) will fire \(t_{1}\) three times, fire \(t_{2}\) two times and fires \(t_{5}\) one time. The sequence of control actions \(c_{1}\), \(c_{2}\) and \(c_{3}\) define a control policy. However, this control policy brings the CPPS to an undesirable circular waiting situation in Figure 4. Therefore, generation of the control actions that can maintain the liveness of the CPPS model is an important issue. The Context-Generation Algorithm for CPPS to be introduced in Section 5.3 serves to generate the sequence of control actions to be executed.