## 1 Introduction
Aiming to improve the accuracy of power fluctuation forecasting by means of predicting the photovoltaic panel tilt angle, this paper proposes an improved multi-layer heterogeneous particle swarm optimization (MHPSO) algorithm to optimize the parameters of long short-term memory (LSTM) neural networks. The concept of attracting particles is applied in a multi-layer heterogeneous PSO structure, and the speed update equation is updated to make the optimization performance of the particle swarm optimization algorithm more complete, which also improves the optimization effect on the selection of initial parameters of the LSTM structure, combining to build an improved MHPSO-LSTM model to forecast the output power of a PV system. The prediction time can reach 10 s, which can reduce the requirements for motor and energy storage response time in the algorithm's applications for power generation control. In this work, we use measured data from level three and five sea states as input to predict the movement results of the photovoltaic panel. The solar illuminance data are sourced from a ship route from the north of China to the east of Arabia. The radiation amount, corrected by the latitude and longitude, is used for calculation in the photovoltaic system output power prediction model. The aim of this paper is to forecast rapid power fluctuations caused by the swing of shipborne photovoltaic panels traveling on the sea and the uncertainty of renewable energy in a short time (within 10 s). The contributions of this paper are as follows: This article provides a more reliable method for calculating the output power of photovoltaic systems on ships following known routes. At the same time, by predicting the inclination of the PV panel, the output power is forecasted in the short-term. 1. Aiming at shipborne PV systems, this paper proposes a power calculation model for shipborne photovoltaic panels. Sea wave fluctuation has a non-negligible effect on the output power of the PV system. The measured roll and pitch are reduced to one single angle through a rotation matrix, which is used as an important variable in our model. Then, we calculate the output power through the proposed model and the proposed model is tested with a solar ship swing platform. 2. The accuracy of short-term power prediction is of great significance to power control, so we propose to predict and calculate the power of a photovoltaic system by predicting the inclination of the photovoltaic panel. We use an improved LSTM algorithm to complete this work. 3. According to the year-round weather data of known routes, the solar radiation along the route should be corrected for. The radiation is also variable, according to the season, latitude, and longitude, which provides a reliable reference source for the power scheduling of shipborne PV system. This paper is organized as follows: Section 2 establishes the inclination motion model of the shipborne photovoltaic panel and Section 3 presents the LSTM neural network. Section 4 presents the improved MHPSO algorithm and Section 5 describes the MHPSO structure for optimizing the weights of the LSTM neural network and discusses the proposed structure of the MHPSO-LSTM algorithm and its effectiveness in the prediction of the pitch angle of the photovoltaic panel. In addition, we build a more accurate mathematical model of photovoltaic power based on the proposed prediction algorithm and make ultrashort-term power predictions. Finally, some conclusions are drawn in Section 6.