# Joint Iterative Satellite Pose Estimation and Particle Swarm Optimization
## 3 Materials and Methods
### Joint Iterative Pose Estimation and Particle Swarm Optimization (PE-PSO) Method
Weight (\(\omega\)) is an important parameter for identifying motion during PSO. Weight (\(\omega\)) controls how much of the previous velocity of the particle is retained in the current velocity. A larger weight (\(\omega\)) encourages global exploration, while a smaller one promotes local exploitation. Typical values of Weight (\(\omega\)) range between 0.4 and 0.9. However, it can also be dynamically adjusted during the optimization process to balance between global and local exploration [44]. In this experiment, the varied weight (\(\omega\)) has been tested as present in Section 4 to seek the suitable value. \(r_{1}\) and \(r_{2}\) are random matrices whose sizes are the batch size (\(i\)). \(pbest_{k,t}\) is the local best value, whereas \(gbest_{k,t}\) is the global best value. The velocity conditions of the population or a particle are as follows:  
\[Velocity_{max}=0.1*(UB-LB)Velocity_{min}=-Velocity_{max} \tag{8}\]  
where \(UB\) and \(LB\) are the upper bound and lower bound of the velocity, which are set as 20 and \(-20\), respectively, in the current experiment. Algorithm 1 and the workflow of the proposed method (shown in Figure 2) clearly depict the above processes. The proposed method begins with initial parameters for PE, such as the learning rate, number of epochs, number of batches, and batch size. PSO also has initial hyperparameters, namely, the positions and weights of the particles, the inertia weight damping ratio, the local learning coefficient, the global learning coefficient, and the lower and upper bounds of the population velocity. The key parameters of the joint (PE-PSO) method are the numbers of PE and PSO epochs. Moreover, it is important to set the population size or swarm size equal to the number of batches. In each epoch, PSO computes the velocity via Equation (7) with the predefined constraint imposed by Equation (8) and updates the corresponding position. The updated position is then applied as a part of the input (as Equation (6)) of the objective function to train the PE model of the spacecraft. The loss value is calculated via Equation (5) as the average of all losses involved in the training process, i.e., the total loss, location loss, and orientation loss. Consequently, the algorithm checks and updates the process based on the local (personal) and global losses by using fewer conditional operations than the previous stacking value. The weight (\(\omega\)) is adjusted by the inertia weight damping ratio (\(\omega_{damp}\)) in every epoch. The PE-PSO process continues until the maximum number of epochs is reached. ```
Input: number of batches (epochs), batch size (\(i\)), weight (\(\omega\)), inertia weight damping ratio \(\left(\omega_{damp}\right)\), local learning coefficient (\(c_{1}\)), global learning coefficient (\(c_{2}\)), lower bound (\(LB\)) and upper bound (\(UB\)) of the population velocity, learning rate. Output: The PE-PSO model. for\(t\)<epoch: for\(k\)<number of batches: * Prepare the input and build batch logs for PE; * Calculate the particle velocity (\(Velocity_{k}\)) via Equation (7); * Check for and apply velocity limits via Equation (8); * Update the position of the particle (\(Position_{k}\)); * Compute \(Loss_{k}\) via Equation (5); * Check and update the positions of the local and global best particles. Update weight as \(\omega=\omega*\omega_{damp}\)
```  
**Algorithm 1**The PE-PSO method