# An Improved Spider Wasp Optimizer for Green Vehicle Route Planning in Flower Collection
## 4 Algorithm Design
### Mutation Operators
#### 4.10 Complexity Analysis of the GN_CSW Algorithm  
In analyzing the time and space complexity of the GN_CSWA, we consider various steps of the algorithm, including initial solution generation, fitness function calculation, selection operations, PMX operation in the global search phase, six neighborhood search operators in the local search phase, and mutation operations. The complexity analysis for each step is detailed below:  
1. The initial solution generation employs both the random method and the nearest neighbor algorithm. The random method involves simply sorting the customers randomly, so its time complexity is \(O(n)\). The nearest neighbor algorithm requires  
Figure 6: The discretized SWO mating behavior procedure. Figure 7: The reverse mutation procedure. traversing each customer and calculating the distance to the unvisited customers. For each customer, selecting the nearest unvisited customer requires traversing \(n\) customers, resulting in a time complexity of \(O(n^{2})\). Therefore, the overall time complexity is dominated by the nearest neighbor algorithm, which is \(O(n^{2})\). The space complexity is \(O(n)\). 2. The calculation of the fitness function involves summing multiple cost components and performing numerical computations, which require traversing customers or edges. The time complexity is \(O(pop\times n^{2})\), where \(pop\) is the population size and \(n\) is the number of customers. The space complexity is \(O(pop\times n)\). 3. The selection operation includes roulette wheel selection, elite selection, and best individual retention strategy. Each selection mechanism requires only a single traversal of the parent population, resulting in a time complexity of \(O(n)\) and a space complexity of \(O(n)\). 4. The time complexity of the PMX operation in the global search phase is \(O(n)\), involving gene exchange and repair. The space complexity for storing the offspring is \(O(n)\). 5. The time complexity of the six search operators involved in the local search is as follows: For DRO_FC, the time complexity for counting the frequency of each gene in the elite population is \(O(n^{2})\), and the time complexity for calculating the connection probability is also \(O(n^{2})\), resulting in a total time complexity of \(O(n^{2})\). Similarly, for DRO_CC, the time complexity for calculating the longest common subsequence and the connection probability are both \(O(n^{2})\), leading to a total time complexity of \(O(n^{2})\). For the Internal 2-opt operator, which involves selecting two edges and reconnecting them, the time complexity is \(O(n)\). The Internal or-opt operator, which functions similarly to the 2-opt operator, also has a time complexity of \(O(n)\). Both DRS_DR and TES_DR operators, which involve delete-insert operations and node swapping between two routes, respectively, have time complexities of \(O(n)\). Since only one search operator is executed at a time during each local search, the overall time complexity is dominated by DRO_FC and DRO_CC, resulting in a total time complexity of \(O(n^{2})\). In terms of space complexity, it is \(O(n)\), as it is primarily used for storing paths and intermediate results. 6. The mutation operations consist of two components: the discretized SWO crossover operation and the reverse mutation operation. The time complexity of the discretized SWO crossover operation is \(O(n)\), as it generates offspring by exchanging genes between parent individuals, and the process is linear. The space complexity of this operation is \(O(n)\), which is used to store the paths and intermediate results. The time complexity of the reverse mutation operation is \(O(lr)\), where \(lr\) is the length of the reversal interval, typically at most \(n\), so its time complexity is \(O(n)\). The space complexity of this operation is also \(O(n)\), used for storing paths and intermediate results.