# A Theoretical Foundation for Context-Aware Cyber-Physical Production Systems
## 5 Approach to Deadline Awareness Problem and Future States Awareness Problem
### Situation-Aware Context Generation Algorithm  
In this subsection, we first present Theorem 2 for deadline awareness and future states awareness and then a context generation algorithm for CPPS. Based on Theorem 1, we have the following result. **Theorem 2**. : _Assume that \(g(\tau)=0\) for \(\tau\leq\Phi\) and \(h(\tau)>0\) for \(\tau>\Phi\). If there exists a solution to the Nominal Optimization Problem, there exists a control policy \(u\) under which \(G_{c}(m_{0},u)\) can reach \(m_{f}\) without visiting any undesirable states. If the objective function value of the solution to the Nominal Optimization Problem is zero, \(G_{c}(m_{0},u)\) can reach \(m_{f}\) by the deadline \(\Phi\) under control policy \(u\)._  
**Proof. **  
Let \(f\) be a solution to the NOP. It follows from Theorem 1 that there exists a control policy under which \(G_{c}(m_{0},u)\) is live and can reach \(m_{f}\) under \(u\). Hence, undesirable states will not be visited under \(u\). If the objective function value of the solution to the Nominal Optimization Problem is zero, \(\sum\limits_{j\in J}\sum\limits_{r\in R}\sum\limits_{t\in\prod a(v,w)\in A_{ j\mu}}\lambda(a(v,w))f(a(v,w))\) must be \(0\). Let \(A_{je}=\Big{\{}a(v_{Nj,\Pi+t},e_{j}),t\in\{1,2,...,\Pi\}\Big{\}}\) denote the set of arcs in the type-\(j\) task subnet directly connecting to the end node \(e_{j}\). Note that each term \(\sum\limits_{a(v,w)\in A_{j\mu}}\lambda(a(v,w))f(a(v,w))\) in \(\sum\limits_{j\in J}\sum\limits_{r\in R}\sum\limits_{t\in\prod a(v,w)\in A_{ j\mu}}\lambda(a(v,w))f(a(v,w))\) can be broken down into two terms, \(\sum\limits_{a(v,w)\in A_{j\mu}}\lambda(a(v,w))f(a(v,w)\) and \(\sum\limits_{a(v,w)\in A_{j\mu}}\lambda(a(v,w))f(a(v,w))\). As \(\lambda(a(v,w))\) is equal to zero for all arcs with the exception of the arcs that connect to the end nodes, the following holds:  
\(\lambda(a(v,w))=0\) for each \(a(v,w)\in A_{j\mu}\backslash A_{je}\). Therefore, the term \(\sum\limits_{a(v,w)\in A_{j\mu}}\lambda(a(v,w))f(a(v,w))\) is reduced to \(\sum\limits_{a(v,w)\in A_{j\mu}}\lambda(a(v,w))f(a(v,w))\), which is equal to \(\sum\limits_{\tau\in\{1,2,...,\Pi\}}\lambda(a(v_{Nj,\Pi+\tau},e_{j}))f(a(v_{Nj, \Pi+\tau},e_{j}))\). As \(g(\tau)=0\) for \(\tau\leq\Phi\), \(\lambda(a(v_{Nj,\Pi+\tau},e_{j}))\) is equal to zero for each \(\tau\in\{1,2,...,\Phi\}\) and \(\sum\limits_{\tau\in\{1,2,...,\Pi\}}\lambda(a(v_{Nj,\Pi+\tau},e_{j}))f(a(v_{Nj, \Pi+\tau},e_{j}))\) is reduced to \(\sum\limits_{\tau\in\{\Phi+1,\Phi+2,...,\Pi\}}\lambda(a(v_{Nj,\Pi+\tau},e_{j}))f(a(v_{ Nj,\Pi+\tau},e_{j}))\). Hence \(\sum\limits_{\tau\in\{\Phi+1,\Phi+2,...,\Pi\}}\lambda(a(v_{Nj,\Pi+\tau},e_{j}))f(a(v_{ Nj,\Pi+\tau},e_{j}))\) is equal to \(0\). As \(h(\tau)>0\) for, \(\lambda(a(v_{Nj,\Pi+t},e_{j}))>0\) for each \(\tau\in\{\Phi+1,\Phi+2,...,\Pi\}\). As \(f(a(v_{Nj,\Pi+t},e_{j}))\) is nonnegative, \(f(a(v_{Nj,\Pi+\tau},e_{j}))\) must be zero for each \(\tau\in\{\Phi+1,\Phi+2,...,\Pi\}\). Therefore, the deadline \(\Phi\) can be met. \(\square\)Based on the theorem presented above, we propose Algorithm 3 to generate the contextual information (control actions) for Future States-Aware systems. The following algorithm first constructs \(JSTN(V,A)\) for the model \(G\) of a CPPS with an initial marking \(m_{0}\) and formulates NOP next. Finally, the NOP is solved to find a solution. If a solution can be found by solving the NOP, the proposed algorithm will generate the Future States-Aware Context. Otherwise, it will exit. ```
Step 1: Construct \(JSTN(V,A)\) for the model \(G\) of a CPPS with an initial marking \(m_{0}\) Step 2: Formulate the nominal optimization problem Formulate NOP according to \(JSTN(V,A)\) Step 3: Solve the nominal optimization problem Find the solution of NOP If there is a solution \(f\) if \(\sum\limits_{f\in J}\sum\limits_{r\in R}\sum\limits_{t\in\prod a(v,w)\in A_{ int}}\lambda(a(v,w))f(a(v,w))=0\)  The deadline \(\Phi\) can be met. Else The deadline \(\Phi\) cannot be met.