**4. Multiobjective Optimization Algorithm for Multiarm Cooperative Harvesting Trajectory**

As discussed in Section 1, there are the following two main difficulties required to overcome: (1) The SSIS region restricts the working area of the harvesting arm as mentioned in Section 2.2; (2) The allocation of cluster fruits to ensure the non-destructive success rate.

For the first problem, the stepwise algorithm, which can divide the MTSP into mindependent TSPs to reduce the complexity of the problem, is an appropriate approach.

For the second sequence planning problem, the normal approach is to regard the clustered fruits as a whole and assign them to a certain arm. However, when the number of fruits in the same cluster is large and the distribution density of mature fruits in the harvesting area is uneven (for example, most of the mature fruits are located on the left and a few on the right), and if the fruits of a cluster can only be assigned to one arm, there will be more harvesting tasks for one arm and fewer for the other arms, which will greatly affect the harvesting efficiency. Therefore, for clustered fruits, it is necessary not only to ensure that they can be harvested in order but also to be assigned to different arms to help achieve the balanced allocation of the total harvesting task to each arm.

Therefore, an improved genetic algorithm and ant colony stepwise multiobjective optimization algorithm (IGAACMO) is proposed. The algorithm flow is shown in Figure 6.

**Figure 6.** The flow chart of the multitarget optimization algorithm proposed in this paper.

In the first step, an improved local density bi-directional clustering algorithm is designed to identify the clustered fruits to provide preparation for harvesting the clustered fruits in the specified order; Then, in the second step, the MTSP problem is decomposed into m independent TSP problems by a genetic algorithm with strong global optimization ability, so as to settle uneven task assignment of the MTSP problem with SSIS region; The third step is to use the fast convergence speed of the ant colony algorithm to plan the trajectory of the above M-independent TSP respectively, and combined it with the auction mechanism to resolve the allocation issue under the restriction of clustering fruit sequence planning.

#### *4.1. Clustering Algorithm Optimization for Fruits of Straw-Rotting Fungus*

The clustering algorithms in the current research can be roughly divided into the following five categories: partitional-based, hierarchical-based, grid-based model-based, and density-based [39]. The partitional-based algorithm is suitable for identifying datasets with small sample sizes and spherical cluster shapes. However, it depends on the user to specify the number of clusters in advance, and the processing for large-scale datasets and clusters with complex shapes still needs to be improved further [40]. The hierarchicalbased clustering algorithm is sensitive to the noise and abnormal data points in the data and cannot be rolled back after the upward or downward iteration [41]. The grid-based algorithm runs at a high speed because its processing time is only related to the number of cells and has nothing to do with the number of objects. However, the grid-based division method may also reduce the clustering accuracy [42,43]. The advantage of a model-based clustering algorithm is that it can find noise and isolated data points and can automatically identify the number of classes. The disadvantage is that it is not suitable for clustering with a large amount of data [44]. The density-based clustering algorithm can identify clusters with different shapes. It can effectively eliminate abnormal data points or isolated data points in the dataset, and has good noise resistance, but are sensitive to the density of adjacent data points [45,46].

The fruit clustering state of straw-rotting fungus is relatively complex. Taking Agaricus bisporus as an example, as shown in Figure 7a, it has the characteristics of complex and different cluster shapes, and the number of clusters is unpredictable in advance, which makes the partitional clustering algorithms and hierarchical clustering algorithms unsuitable to discriminate against it. In addition, as shown in Figure 7b, it also has the characteristics of many small clusters and many discrete values globally, which makes grid clustering algorithms and model clustering algorithms less suitable.

**Figure 7.** Cluster shape of Agaricus bisporus (**a**) clusters with different shapes and densities; (**b**) clusters with many small clusters and many discrete values.

The density-based clustering algorithm can identify clusters with different shapes. However, due to the different diameters of each fruit of the straw-rotting fungus, the density of the fruit clusters of the straw-rotting fungus is uncertain, while the general density-based algorithm is not effective in solving such clusters with variable density. Therefore, an improved local density bi-directional clustering algorithm is designed in this paper. The designed local density calculation method can better adapt to the problems of complex and different cluster shapes, especially for uncertain density, so that the algorithm can better meet the requirements of fruit cluster analysis of straw-rotting fungus.
