# Bee Swarm Metropolis-Hastings Sampling for Bayesian Inference in the Ginzburg-Landau Equation
## 3 The Proposed BeeSwarm-MH Algorithm
### Hybrid Sampling Framework Integrating Bee Swarm Intelligence with MH
#### 3.1.4 Adaptive Step Size Adjustment  
The adaptive step-size adjustment module is a critical component of the BeeSwarm-MH sampling algorithm, which is designed to dynamically balance exploration and exploitation while enhancing overall sampling efficiency and robustness. This module implements a two-level strategy, enabling both individual-level adaptation and the global coordination of step sizes. At the individual level, each bee tracks its proposal count and acceptance count. Once the number of proposals exceeds the threshold \(n_{0}\), the local acceptance rate is computed as  
\[r=\frac{\texttt{accept\_count}}{\texttt{proposal\_count}}.\]  
Drawing on the adaptive sampling principle of balancing exploration and exploitation in MCMC methods [12], a local adjustment factor is then calculated:  
\[\kappa(r)=1+0.2(r-0.5).\]  
This coefficient (0.2) is determined through empirical tuning specific to the BeeSwarm-MH framework, ensuring the appropriate responsiveness of individual step sizes to local acceptance rate variations. This function ensures that when acceptance rates are high, the step size is moderately increased to expand the search range; conversely, when acceptance rates are low, the step size is reduced to improve sampling success. The updated step size is clipped within a predefined range using  
\[\texttt{clip}(\cdot,\sigma_{\text{min}},\sigma_{\text{max}})\]  
to prevent numerical instability or degradation. After adjustment, the proposal and acceptance counters are reset for the next cycle. At the global level, the module computes the overall acceptance rate across the swarm:  
\[R=\frac{\texttt{total\_accept}}{\texttt{total\_proposal}},\]  
Following the same adaptive logic inspired by [12] and optimized for swarm coordination, it uses this rate to evaluate the global scaling adjustment function:  
\[\alpha(R)=1+0.1(R-0.5).\]  
The smaller coefficient (0.1) here is tailored to maintain stable swarm-level coordination while still enabling collective adaptation to the global sampling landscape. The global scaling factor \(c\) is updated accordingly and clipped within the range  
\[[c_{\text{min}},c_{\text{max}}].\]  
Subsequently, all individual step sizes are multiplied by this updated global scaling factor, achieving coordinated adjustment across the entire swarm. In summary, this two-level step-size adjustment mechanism leverages individual feedback and collective coordination to prevent step-size degeneration and premature convergence, thereby significantly improving the algorithm's adaptability and sampling quality in complex parameter spaces. The full procedure is detailed in Algorithm 4. ```
0: Swarm state \(\mathcal{B}\), current iteration \(t\), stage thresholds \(T_{1},T_{2}\), global scaling factor \(c\)
0: Updated local and global step sizes
1: Define local adjustment function: \(\kappa(r)\gets 1+0.2(r-0.5)\)
2: Define global adjustment function: \(\alpha(R)\gets 1+0.1(R-0.5)\)
3:for each \(a\in\mathcal{B}\)do
4:if\(a\_\text{proposal\_count}>n_{0}\)then
5: Compute acceptance rate: \(r\leftarrow\frac{a\_\text{accept\_count}}{a\_\text{proposal\_count}}\)
6: Update local step size: \(a\_\text{step}\leftarrow\text{clip}(a\_\text{step}\times\kappa(r),\;\sigma_{ \text{min}},\;\sigma_{\text{max}})\)
7: Reset counters: \(a\_\text{proposal\_count}\gets 0\), \(a\_\text{accept\_count}\gets 0\)
8:endif
9:endfor
10: Compute global acceptance rate: \(R\leftarrow\frac{\text{total\_accept}}{\text{total\_proposal}}\)
11: Update global scaling factor: \(c\leftarrow\text{clip}(c\times\alpha(R),\;c_{\text{min}},\;c_{\text{max}})\)
12:for each \(a\in\mathcal{B}\)do
13: Scale local step size: \(a\_\text{step}\leftarrow\text{clip}(a\_\text{step}\times c,\;\sigma_{\text{ min}},\;\sigma_{\text{max}})\)
14:endfor
```  
**Algorithm 4** Adaptive Step Size Adjustment  
This adaptive step-size adjustment mechanism effectively improves sampling efficiency and convergence stability.