# A Method of Dual-AGV-Ganged Path Planning Based on the Genetic Algorithm
## 3 Proposed Dual-AGV-Ganged Path-Planning Method
### Dual-AGV-Ganged Fitness Function  
The fitness function directly influences the selection and retention of paths, making it crucial for the algorithm's outcomes. During the path initialization stage, this paper prioritized the shortest path points toward the goal direction, thus considering the shortest distance. In subsequent iterations, the goal was to achieve a collision-free operation for the dual-AGV-ganged system. Therefore, a dual-AGV-ganged fitness function was designed, as shown in Equation (8):  
\[\text{fitness}=\frac{1}{C_{\text{Start}}+C_{\text{Middle}}+C_{\text{Goal}}}, \tag{8}\]  
where \(C_{\text{Start}}\) is the starting-point steering cost value, \(C_{\text{Middle}}\) is the middle point steering cost value, and \(C_{\text{Goal}}\) is the goal-point steering cost value. The calculation steps of \(C_{\text{Start}}\) are as follows: Using the starting point as \(P_{A}\) and the second point in the path as \(P_{B}\), calculate \(\theta_{B}\) using Equation (6) and then rotate it clockwise by 180\({}^{\circ}\). \(\theta_{\text{Start}}\) is taken as \(\theta_{A}\). If \(\theta_{A}\) and \(\theta_{B}\) are equal, then \(N_{\text{Sobstacle}}\) is 0. Otherwise,  
Figure 4: Population initialization flowchart. a detailed analysis needs to be conducted according to the following steps, as shown in Figure 5. The black rectangular box and arrow represent the dual-AGV system's outline and orientation, the red line segment represents the planned path, the black circles represent path nodes, and the green circles represent obstacles. Begin using \(P_{A}\) as the center, with \(R_{\text{Turm}}\) as the radius. Calculate the number of grid cells occupied by obstacles within the sector formed by the two angles, resulting in \(N_{\text{Sobstacle}}\). Then, calculate \(C_{\text{Start}}\) based on Equation (9). \[C_{\text{Start}}= \begin{cases}1,&N_{\text{Sobstacle}}=0\\ N_{\text{Sobstacle}}\times 100,&N_{\text{Sobstacle}}>0\end{cases} , \tag{9}\]  
where \(C_{\text{Start}}\) is the steering cost value at the starting point, and \(N_{\text{Sobstacle}}\) is the number of obstacle points during the steering process at the starting location. The calculation steps of \(C_{\text{Middle}}\) are as follows: Starting from the path's starting point, iterate through all path points. Compute the turning cost \(C_{\text{Turm}}\) between three adjacent path points \(P_{i}\), \(P_{i+1}\), and \(P_{i+2}\). Specifically, take \(P_{i}\) as \(P_{A}\), \(P_{i+1}\) as \(P_{B}\), and calculate \(\theta_{\text{point}}\) using Equation (6). Rotate it clockwise by \(180^{\circ}\) to obtain \(\theta_{A}\) and \(\theta_{B}\), respectively. If \(\theta_{A}\) and \(\theta_{B}\) are equal, then \(N_{\text{Mobstacle}}\) is 0. Otherwise, a detailed analysis needs to be conducted according to the following steps, as shown in Figure 6. Using \(P_{i+1}\) as the center, with \(R_{\text{Turm}}\) as the radius, calculate the number of grid cells occupied by obstacles within the sector formed by the two angles, resulting in \(N_{\text{Mobstacle}i}\). Then, calculate \(C_{\text{Middle}}\) based on Equation (10). Repeat the above steps until reaching the goal point and then sum up the \(C_{\text{Middle}}\) values to obtain \(C_{\text{Middle}}\), as shown in Equation (11). \[C_{\text{Middle}}= \begin{cases}1,&N_{\text{Mobstacle}i}=0\\ N_{\text{Mobstacle}i}\times 100,&N_{\text{Mobstacle}i}>0\end{cases} , \tag{10}\]  
where \(C_{\text{Middle}}\) is the steering cost value at the \(i\) intermediate node in the path, and \(N_{\text{Mobstacle}i}\) is the number of obstacle points during the steering process at the \(i\) intermediate node location in the path. \[C_{\text{Middle}}= \begin{cases}\sum_{i=1}^{n}C_{\text{Middle}}\end{cases} , \tag{11}\]  
where \(C_{\text{Middle}}\) is the steering cost value at the middle point, and \(n\) is the number of intermediate nodes in the path, excluding the starting and goal points. Figure 5: Starting-point turning diagram.