# FMS Scheduling under Availability Constraint with Supervisor Based on Timed Petri Nets
## 6 Mathematical Model
### Genetic Algorithm
#### 6.2.7 Stopping Criteria  
The progress of reproduction by crossover and mutation operators and fitness continues until a satisfactory result is obtained or a preset maximum number of iterations is reached. After these iterations, the genetic algorithm prints the best chromosome that corresponds to the minimum makespan \(H_{max}\). Algorithm 2 recaps the GA steps. Initialization parameters are: population size (\(P\)), crossover probability value (\(P_{cross}\)), probability mutation value (\(P_{MUT}\)) and the preset maximum number of iterations (\(Niter\)). ```
Initializing the program and setting the data values: \(P\), \(P_{cross}\), \(P_{MUT}\), \(Niter\), \(i=0\), \(k=0\)  Generate randomly a solution Repeat \(i=0\)  While \(k<P\) do  Select randomly 2 parents of the population (2 solutions);  Apply the crossover operator;  Apply the mutation operator. \(k=k+1\)  End while  Test if a generated solution is feasible;  Evaluate the obtained and valid new sequences;  Arrange in ascending order these solutions based on the objective function;  Delete the worst solutions and record the best ones;  Record the best solution. \(i=i+1\) Until \(i=Niter\)  Print the optimal solution corresponding to minimum makespan

Figure 7: Example of new solution generation via the mutation operator. ## 7 Synthesis Method of Scheduling Supervisor

The main contribution, in this part, is to develop an efficient supervisor synthesis method (Algorithm 3), which tampers with the decomposed TPN, based on the transitions firing sequence and parameters provided by the mathematical model. The proposed supervisor is managed by two types of controllers: digital controllers and TPN controllers (i.e., see Section 3). * Step 1. Solving the firing sequence: This step is essential as it determines the firing global-clock of transitions \(H\big{(}t_{i,j}\big{)}\), the decision variable values \(A(t_{i,1},t_{i^{*},0})\) and \(Z_{i,j}\). * Step 2. Identifying the chronological order of jobs: Once \(A(t_{i,1},t_{i^{*},0})\) values are determined, one can identify the jobs' order. * Step 3. Deleting the inexistent direct arcs: Direct arcs \(t_{i,1},t_{i^{*},0}\) corresponding to \(A(t_{i,1},t_{i^{*},0})=0\) are removed from the decomposed TPN model. Remaining direct arcs \(\left(A(t_{i,1},t_{i^{*},0})=1\right)\) design the selected processing sequence. * Step 4. Determining the digital controllers: The digital controller reacts when the treatment of job \(i\) is accomplished through machine \(j\) while \(j+1\) is unavailable. Therefore, the controller functioning is displayed through \(Z_{i,j+1}=1\) in which the extra time \(\varphi_{t_{i,j}}(Z_{i,j+1})\) of this controller is computed. * Step 5. Determining the TPN controllers: The TPN controller ship is to ensure a correct order progression of jobs including among each other a time lag \(\theta_{(i,i^{\prime})}\). The TPN controllers operate in coordination with digital controllers, i.e., the determination of time lag \(\theta_{(i,i^{\prime})}\) takes into account the extra time \(\varphi_{t_{i,j}}(Z_{i,j+1})\) of the digital controller. Its value is computed as: \(\theta_{(i,i^{\prime})}=H\big{(}t_{i^{\prime},0}\big{)}-\left(H(t_{i,1})+ \varphi(Z(t_{i,1}))\right)\). * Step 6. Implementing the supervisor: The controllers calculated in Steps 4 and 5 take places in the decomposed timed Petri net. ```
1. Solve the firing sequence using the mathematical model (13)-(21) and genetic algorithm. 2. Identify the chronological order of jobs. 3. Delete the inexistent direct arcs  For each \(A\left(t_{i,1},t_{i^{*},0}\right)=0\)\(\forall\)\(i,\)\(i^{*}=1,2,\ldots,n\), \(i\
eq i^{*}\) Remove the direct arc \(\left(t_{i,1},t_{i^{*},0}\right)\) from the decomposed TPN
4.