# A Heterogeneous Multi-Satellite Dynamic Mission Planning Method Based on Metaheuristic Algorithms
## 3 Algorithm Design
The second part is the main loop function, which primarily ensures that our optimization algorithm can update iteratively over time and that users who continuously initiate communication demands do not switch unnecessarily. In each iteration, the main loop function loads the current user data, compares user changes between iterations, updates the users' connection status and the satellites' capacity usage, and plots and saves bar charts of the satellites' capacity usage. Finally, it calls the Particle Swarm Optimization algorithm to update the optimal user connection status and saves the results, thus achieving continuous optimization of satellite connections, as illustrated in Algorithm 2. A key advantage of the proposed framework is its overall low computational complexity, which is evident in both the PSO algorithm and the main loop function. The modifications made to the PSO algorithm, particularly the elimination of the velocity component, reduce the number of calculations needed in each iteration, leading to faster convergence without sacrificing solution quality. Similarly, the design of the main loop function is streamlined to efficiently handle user data updates and connection status changes, thus minimizing resource usage during execution. The overall complexity of our algorithm can be analyzed as follows. Let \(U\) be the number of users, \(S\) the number of satellites, and \(T\) the number of iterations. The complexity arises from several key steps, including loading user data, updating connection statuses, and calling the PSO algorithm, which has a complexity of \(O(T\cdot P\cdot D)\), where \(P\) is the number of particles and \(D\) is the problem dimensionality. Thus, the total complexity can be expressed as \(O(T\cdot P\cdot D+U)\). ```
1:Function: MAIN (num iterations = 10, initial timestamp = \"26 Mar 202411:33:53.559\"
2: Initialize timestamp
3: Initialize prev users and prev best position to None
4:for iteration=1 to num iterations do
5: Reset satellite states using RESET SATELLITES
6: Load current user data from file using LOAD USERS
7:if iteration > 1 then
8: Compare current users with prev users using COMPARE USERS
9: Identify duplicate, missing, and added user IDs
10: Create user information using CREATE USER
11: Initialize sat cost capacity dictionary for satellites
12: Filter user information based on comparison results:
13:for each user in prev best position do
14:if user id in duplicate IDs then
15:if user satisfaction is l and satellite is still covered then
16: Keep the user in communication
17: Deduct user's traffic demand from satellite's capacity
18:else
19: Add user to the new users group
20:endif
21:else
22: Add user to the new users group
23:endif
24:endfor
25:else
26: Create user information for the first iteration using CREATE USER
27: Initialize sat cost capacity dictionary for satellites
28:endif
29: Initialize Satellite Manager with sat cost capacity
30: Perform PSO optimization using PSO FORSATELLITE CONNECTION
31:if iteration > 1 then
32:for each user in prev best position do
33:if user id in duplicate IDs then
34: Append user to the best _position
35:endif
36:endfor
37:endif
38: Save best position to file using SAVE BEST POSITION
39: Update prev users with current users
40: Update prev best position with best position
41: Increment timestamp by 1 h
42:endfor
43:endfunction
```  
**Algorithm 2** Main Function for Satellite Connection Optimization  
This low-complexity approach is crucial in dynamic satellite communication environments, where quick adjustments are necessary to maintain connection stability and user satisfaction. By integrating these efficient strategies, our algorithm not only optimizes user connections effectively but also ensures scalability and responsiveness in challenging operational conditions.