Abstract:Accurate prediction of ammonia nitrogen (ammonia-N )concentration is critical for water quality management in intensive aquaculture. However, ammonia-N dynamics exhibit pronounced nonlinear characteristics due to coupled environmental factors, making precise forecasting challenging. To address this issue, a hybrid prediction model integrating a convolutional neural network-gated recurrent unit-attention (CGA), optimized by a particle swarm optimization (PSO)-enhanced subtraction average- based optimizer (SABO), was proposed. Key environmental variables influencing ammonia-N dynamics were identified by using Pearson correlation analysis, with dissolved oxygen, nitrate-nitrogen, pH value, and water temperature selected as input features. To overcome hyperparameter optimization challenges, the PSO-SABO algorithm was developed by integrating the global memory mechanism of PSO into the update framework of SABO to enhance global exploration and accelerate convergence. Experimental results demonstrated that the proposed PSO SABO CGA model achieved superior prediction performance. For the 5-min prediction horizon, it attained a mean absolute error (MAE)of 0. 062 mg / L, a root mean square error (RMSE)of 0. 082 mg / L, and a coefficient of determination (R2 )of 0. 934. Comparative analyses revealed that PSO-SABO achieved faster and more stable convergence than the hippopotamus optimization (HO)and genetic algorithm (GA), reducing MAE and RMSE by up to 24. 26% and 25. 19% , respectively. Ablation studies confirmed the effectiveness of the GRU component and the necessity of PSO global guidance. Compared with the temporal convolutional network (TCN), bidirectional long short-term memory (BiLSTM ), backpropagation neural network (BPNN ), and standard GRU, the proposed model reduced MAE by up to 15. 07% for the 5-min horizon and maintained an R2 of 0. 842 for the 24 h horizons. These findings indicated that the PSO-enhanced global search, combined with SABO's adaptive mechanism, significantly improved hyperparameter optimization. This enabled the framework to effectively capture nonlinear ammonia-N dynamics under multi-factor interactions, offering superior accuracy, robustness, and generalization across both short-term and extended prediction horizons. This approach can provide a reliable technical foundation for intelligent water quality monitoring and precision management in aquaculture systems.