# Enhancing Air Quality Prediction with an Adaptive PSO-Optimized CNN-Bi-LSTM Model
## 3 Model Introduction
### PSO Based on Adaptive Inertia Weight
Unlike the conventional linear decrease, where the inertia weight reduces monotonically in a predetermined fashion, this adaptive strategy offers a smoother transition that aligns more closely with the varying needs for exploration and intensification during different optimization stages [44]. The formula for calculating this inertia weight is as follows:  
\[\omega_{current\_iter}=\omega_{min}+\frac{1}{2}(\omega_{max}-\omega_{min})(1+ \cos(\frac{\pi*current\_iter}{max\_iter}))\]  
Among them, current_iter is the current number of iterations, \(\omega_{min}\) and \(\omega_{max}\) are the minimum and maximum values of weight \(\omega\). Furthermore, max_iter refers to the maximum permissible iteration count, with \(\pi\) representing the mathematical constant pi. In this study, the max_iter was 1500, and the acceleration factors \(c_{1}=1\) and \(c_{2}=2\), the number of particles was 4, the search dimension was 3, and the Early Stopping mechanism (Patience = 29) was added to save computing resources and prevent over-fitting. APSO-CNN-Bi-LSTM algorithms are shown in Figure 8.  
The outlined implementation procedure for integrating the Adaptive Particle Swarm Optimization (APSO) algorithm with a predictive model for air quality prediction embodies a systematic and iterative approach aimed at refining model parameters and enhancing prediction accuracy. Summarizing the steps provided:  
1. **Initialization**: Commence by initializing the predictive model and the APSO algorithm. This includes setting up the model structure and parameters and defining the swarm characteristics for PSO, such as the number of particles and their initial positions in the solution space. 2. **Objective Function Definition**: Define the objective function that the PSO algorithm will aim to minimize or maximize. In this case, Mean Absolute Error (MAE) is chosen as the fitness function f(x), reflecting the error between predicted and actual air quality measurements. Establish a fitness threshold Y to determine the quality of the acceptable solution
3. **Initial Fitness Calculation**: Introduce the initial parameter set into the model and compute its fitness value y. If this initial fitness surpasses the predefined threshold Y, record the parameters \(\theta^{*}\) and their corresponding fitness y as a candidate solution. Otherwise, proceed to the optimization stage. 4. **APSO Optimization**: Initialize the swarm by assigning random positions and velocities to each particle, each representing a unique configuration of model parameters. Train the model using each particle's position (parameter set), evaluate its fitness using MAE, and retain the particle's state (\(\theta^{*},y\)). 5. **Particle Update**: Iterate through generations or iterations, adjusting each particle's position and velocity using adaptive inertia weights. This dynamic adjustment balances exploration and exploitation to progressively steer the swarm toward better solutions--Recalculate fitness after each update. 6. **Termination and Selection**: Repeat the parameter update process until maximum iterations are reached. Upon termination, review all recorded (\(\theta^{*},y\)) pairs and identify the set with the best fitness score. Employ this optimal parameter configuration in the model for the final air quality prediction task. By systematically refining model parameters through APSO, this methodology seeks to optimize the model's predictive power, thereby enhancing the accuracy and reliability of air quality forecasts. Figure 8: Algorithm Flowchart.