# FMS Scheduling under Availability Constraint with Supervisor Based on Timed Petri Nets
## 6 Mathematical Model
### Genetic Algorithm
#### 6.2.7 Stopping Criteria
Determine the digital controllers  For each \(Z_{i,j+1}=1\)\(\forall\)\(j=1,\ldots,m-2\) Calculate \(\varphi_{t_{i,j}}\big{(}Z_{i,j+1}\big{)}=H\big{(}t_{i,j+1}\big{)}-\left(H \big{(}t_{i,j}\big{)}+h\big{(}t_{i,j+1}\big{)}\right)\) For each job \(s\succ i\) Calculate \(\varphi_{t_{i,j}}\big{(}Z_{i,j+1}\big{)}=H\big{(}t_{s,j+1}\big{)}-\left(H \big{(}t_{s,j}\big{)}+h\big{(}t_{s,j+1}\big{)}\right)\)
5. Determine the TPN controllers  For each \(A\left(t_{i,1},t_{i^{*},0}\right)=1\)\(\forall\)\(i,\)\(i\)\(i=1,2,\ldots,n\), \(i\
eq i^{*}\) Create the TPN controller: \(\pi_{\left(t_{i,1},t_{i^{*},0}\right)}:\Big{(}p_{1,\left(i^{\prime}\right)},t _{\left(i^{\prime}\right)}\Big{[}\theta_{\left(i^{\prime}\right)}\Big{]},p_{2, \left(i^{\prime}\right)}\Big{)}\). Calculate \(\theta_{\left(i^{\prime}\right)}=H\big{(}t_{i^{\prime},0}\big{)}-\left(H \big{(}t_{i,1}\big{)}+\varphi\big{(}Z\big{(}t_{i,1}\big{)}\big{)}\right)\). 6. Implement the supervisor to decomposed TPNTo solve the mathematical model (13)-(21), we used the Xpress optimizer. Xpress is a mathematical programming solver dealing with linear and quadratic problems in continuous and integer variables. For solving Mixed Integer Programs (MIPs), the optimizer provides a powerful branch and bound framework. The Xpress optimizer essentials, components and interfaces are found in many guides and reference manuals, from which we cite [41]. In the literature, many proposals deal with Xpress solver. [PERSON] [40] illustrates some applications of the optimization solver programs. Algorithms for solving large linear optimization problems are reviewed. [PERSON] et al. [42] highlights the Xpress solver's efficiency to optimize mixed linear problems. To illustrate the supervisor synthesis, we reconsider the decomposed timed Petri net shown in Figure 3 and the preventive maintenance presented in Table 2. The obtained results are shown in Table 3.  
Moreover, as explained in Step 2 of Algorithm 3, the decision variable \(A(t_{1,1},t_{2,0})=1\) expresses that the job \(i_{1}\) is treated before the job \(i_{2}\), (\(i_{1}\prec i_{2}\)). Hence, the timed direct arc (\(t_{2,1},t_{1,0}\)) is removed from the decomposed TPN, i.e., \(A(t_{2,1},t_{1,0})=0\) (Figure 8). According to Step 3, the determination of digital controllers is related to \(Z_{1,2}=1\), as follows:  
\[\Longrightarrow\left\{ \begin{array}{c}\varphi_{t_{1,1}}(Z_{1,2})=H(t_{1,2} )-(H(t_{1,1})+h(t_{1,2}))=5\;t.s\\ As(i_{2}\succ i_{1})\Longrightarrow\varphi_{t_{2,1}}(Z_{1,2})=H(t_{2,2})-(H(t_ {2,1})+h(t_{2,2}))=2\;t.s.\end{array} \right.\]  
Indeed, the two digital controllers \(\varphi_{t_{1,1}}(Z_{1,2})\) and \(\varphi_{t_{2,1}}(Z_{1,2})\) require a waiting time respectively for \(i_{1}\) and \(i_{2}\) at \(j_{1}\). Jobs \(i_{1}\) and \(i_{2}\) are respectively delayed by \(5\;t.s\) and \(3\;t.s\). Afterward, the TPN controller \(\pi_{(t_{1,1},t_{2,0})}:\left(p_{1,(1,2)},t_{(1,2)}\left[\theta_{(1,2)}\right],p_{2,(1,2)}\right)\) permits a good sequence between \(i_{1}\) and \(i_{2}\). Its time lag \(\theta_{(1,2)}\) is determined as follows:  
\[\succeq\quad A(t_{1,1},t_{2,0})=1\\ \Longrightarrow\theta_{(1,2)}=H(t_{2,0})-(H(t_{1,1})+\varphi(Z(t_{1,1})))= 1\;t.s\]  
Figure 8: The remaining arc for supervisor synthesis. \begin{table}
\begin{tabular}{c c c c c} \hline \(H(t_{1,0})=0\) & \(H(t_{1,1})=3\) & \(H(t_{1,2})=13\) & \(H(t_{2,0})=7\) & \(H(t_{2,1})=11\) \\ \(H(t_{2,2})=15\) & \(A(t_{1,1},t_{2,0})=1\) & \(A(t_{2,1},t_{1,0})=0\) & \(Z_{1,1}=0\) & \(Z_{1,2}=1\) \\ \(Z_{2,1}=1\) & \(Z_{2,2}=0\) & & & \\ \hline \end{tabular}
\end{table} 
Table 3: The optimal solution and decision variables. Finally, the decomposed TPN coupled with the synthetized supervisor, shown in Figure 9, guarantees the optimal manufacturing scheduling; i.e., the optimal sequence firing of transitions is \(\sigma=t_{1,0}t_{1,1}t_{2,0}t_{2,1}t_{1,2}t_{2,2}\). Figure 10 illustrates the optimal manufacturing scheduling obtained from the controlled TPN model.