## 4 Hybrid Ant Colony Optimization for Optimization of the Machining Line Balancing Problem
### Pseudocode for Ant Colony Optimization and Gantt Diagram Display Module
\begin{tabular}{l l} \hline \hline No. & Details for hybrid ant colony search algorithm and Gantt chart display module \\ \hline
1 & Read task sequencing constraint data from an Excel file \\
2 & Read the information of processing position, cutting tools, and processing time of task from the Excel file \\
3 & Enter the number of iterations \(V\) and the number of ants \(H\), and set the initial iterative control variable \(v\) (initial value is 1) \\
4 & Start the search process for generation \(v\) and set \(h\) to 1 \\
5 & Start the search for the \(h\) \(n\) ant in generation \(v\), set \(s=1\), \(m=0\) \\
6 & Start a new station, \(m=m+1\). \\
7 & Build a task set that satisfies the cycle time constraint \\
8 & According to formula 5, filter from the set of cycle time constraint tasks to form a set that satisfies the sequential constraint relationship \\
9 & Filter from the set of successive constraints to form a set that satisfies the constraints of the close relationship \\
10 & Filter from the set of close relationship constraints to form a set that satisfies the tool relationship constraints \\
11 & Enter the ant colony comprehensive task selection process \\
12 & If the tight constraint set is not empty, go to the next step. If it is empty, go to step 17 \\
13 & According to Formula 11, priority is given to the tasks that satisfy the tight constraints \\
14 & According to the selection result of step 13, analyse whether this task is consistent with the current tool information of the current station, and then proceed to the next step \\
15 & Update the accumulated processing time information of the current station, the current tool information of the current station, and \\  & then proceed to the next step \\
16 & Update the task chain position \(s=s+1\), if \(s\) is less than or equal to \(n\), return to step 7. If \(s=n+1\), go to step 22 \\
17 & If the tool or time constant set is not empty, go to the next step. If they are all empty, go to step 6 \\
18 & According to Formula 11, generate random number \(r\), and enter the next step \\  & If \(r\) is less than or equal to \(r_{1}\), select the task according to rule I\({}_{2}\). If \(r\) is greater than \(r_{1}\), select the task according to rule I\({}_{3}\), and go to the next step \\  & \\
20 & According to the selection result in step 19, update the accumulated processing time information of the current station, the current tool information of the current station, and then proceed to the next step \\
21 & Update the position of task chain \(s=s+1\), and if \(s\) is less than \(n\), return to step 7. If \(s=n+1\), go to the next step \\
22 & \(h=h+1\), if \(h\) is less than or equal to the set number of ants \(H\), return to step 5; otherwise, go to the next step \\
23 & Update the pheromone of all ants of the current generation \(v\) and go to the next step \\
24 & \(v=v+1\), if the current iteration number \(v\) is less than or equal to \(V\), return to step 4; otherwise, go to the next step \\
25 & Ant colony optimization iteration is completed \\
26 & Enter the Gantt chart display module \\
27 & Read the optimal solution of the task scheduling sequence and the task information \\
28 & Read the station arrangement information cell of the optimal solution, the number of stations \(m\), and the cycle time \(C\) \\
29 & Enter the Gantt chart display algorithm flow, and set the initial iteration value \(g=1\) \\
30 & Open the display of station \(g\), and proceed to the next step \\
31 & Read the station arrangement information cell of station \(g\) \\
32 & Read the task number in order d from the cell, the number of tasks in cell D, and set the task display iteration variable \(d\); the initial value of \(d=1\) \\
33 & Whether this task is the first task of the current station, if it meets the conditions, go to the next step; otherwise, go to step 35 \\
34 & Set the task display colour to blue, display the task progress bar according to the task information, and display the start time and end time. Go to Step 37 \\
35 & Judge whether the tool information used in this task and the previous task is the same, if the display colour is red. If not, go to the next step \\
36 & The task progress bar is displayed based on the task information, and the start time and end time are displayed. Go to the next step \\
37 & \(d=d+1\), if \(d\) is less than or equal to D, return step 32; otherwise, go to the next step \\
38 & \(g=g+1\), if \(g\) is less than or equal to the number of stations m, return step 30; otherwise, go to the next step \\
39 & Gantt chart display algorithm is finished, and the program is finished \\ \hline \hline \end{tabular}