# A Theoretical Foundation for Context-Aware Cyber-Physical Production Systems
## 6 Results
### An Example  
In this subsection, we illustrate the proposed method with an example. **Example 1**. : _Consider a CPPS with two production processes to produce two types of products. The two production processes are modeled by two task subnets. There are two types of resources in the CPPS. The two task subnets share the two types of resources. The model of the CPPS is depicted in Figure 3a. The firing time of each transition is listed in Table 2. Suppose an order is received and is to be released to the CPPS for processing the products. The requirements of the order are shown in Table 3. The product demands of the order include three type-1 products and one type-2 product. The deadline of the order is the eighth period. For this example, \(J=2\), \(D_{1}=3\), \(D_{2}=1\), \(\Phi=8\), \(R=2\). We set the time horizon \(\Pi=9\). Therefore, \(\mathbf{J}=\{1,2\}\) and \(\mathbf{R}=\{1,2\}\). The nominal capacity of type-r resources in period \(\tau\) is \(C_{\tau\tau}=2\) for each \(\tau\in\mathbf{R}\) and \(\tau\in\{1,2,...,\Pi\}\). The total number of type-r resources in each period \(\tau\) is listed in Table 4. The initial marking \(m_{\eta}(p_{\eta 0})=D_{j}\) for \(j\in\{1,2\}\). In this example, we use set the function \(g(\tau)=0\) for \(\tau\leq\Phi\) and \(h(\tau)>0\) for \(\tau>\Phi\) to penalize overdue. As \(\Phi=8\), \(\lambda(40,e1)=1\), \(\lambda(80,e1)=1\) and \(\lambda(a(\upsilon,w))=0\) for all the other arc \(a(\upsilon,w)\). For this example, \(A_{j\tau\tau}\) is listed in Table 5._  
The NOP for this example is as follows, where (7) is the objective function, (8) is the capacity constraints, (9) is the flow balance constraints, (10), (11) are the demand constraints, (12) and (13) are the final product constraints. \[\min_{f}\sum_{j\in J}\sum_{r\in R}\sum_{t\in\Pi}\sum_{a(\upsilon,w)\in A_{j \tau}}\lambda(a(\upsilon,w))f(a(\upsilon,w)) \tag{7}\]  
\[\sum_{j\in J=\{1,2\}}\sum_{a(\upsilon,w)\in A_{j\tau}}f(a(\upsilon,w))\leq C_ {\tau\tau}\forall r\in\mathbf{R}\,\forall\tau\in\prod=\{1,2,...,\Pi\} \tag{8}\]  
\[\sum_{w\in V(\upsilon)}f(a(\upsilon,w))=0\,\forall\upsilon\in V\backslash\{s, e_{1},e_{2}\} \tag{9}\]  
\[f(a(s,1))=D_{1} \tag{10}\]\[f(a(s,41))=D_{2} \tag{11}\] \[\sum_{v=31}^{40}f(a(v+11,e1))=D_{1}\] (12) Table 3.0 (13) Table 3.1  
where \(Z\) is the set of nonnegative integers. We apply the CPLEX problem solver [56] to solve the NOP in the Context-Generation Algorithm. By solving the NOP, we find the solution in Table 6, which can be represented in the Joint Spatial-Temporal Network in Table 3.2 The objective function value is 0. Therefore, the deadline can be met. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Resource Type**\((r)\) & **Period**\((t)\) & \(C_{rt}\) \\ \hline  
\hline \hline \end{tabular}
\end{table} 
Table 4: The nominal capacity of each type of resources in each period. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Task Type** & **Transition** & **Firing time** \\ \hline
1 & \(t_{1}\) & \(\mu(t_{1})=1\) \\
1 & \(t_{2}\) & \(\mu(t_{2})=2\) \\
1 & \(t_{3}\) & \(\mu(t_{3})=1\) \\
1 & \(t_{4}\) & \(\mu(t_{4})=0\) \\
2 & \(t_{5}\) & \(\mu(t_{5})=2\) \\
2 & \(t_{6}\) & \(\mu(t_{6})=2\) \\
2 & \(t_{7}\) & \(\mu(t_{7})=2\) \\
2 & \(t_{8}\) & \(\mu(t_{8})=0\) \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Firing time of each transition in Figure 3a. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Product (Task) Type** & **Quantity** & **Deadline** \\ \hline
1 & \(D_{1}=3\) & 8 \\ \hline
2 & \(D_{2}=1\) & 8 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Requirements of an order. Following is an explanation of the control actions generated for the first period and the second period. For the first period (\(\tau=1\)), the control action \(c_{1}=\) [1 0 0 1 0 0 0] represents that transition \(t_{1}\) and transition \(t_{5}\) will be fired. This means that the two transitions will be fired concurrently. For the second period (\(\tau=2\)), the control action \(c_{2}=\) [0 1 0 0 0 0] represents that transition \(t_{2}\) will be fired.