## 5 Prediction of Photovoltaic Output Power Based on MHPSO-LSTM  
### Photovoltaic Panel Motion Prediction  
In this section, we analyze and discuss the improved MHPSO-LSTM method and the effect toward forecasting the inclination of the photovoltaic panel on board to predict the change of PV power output within 10 s. The proposed LSTM structure includes structural optimization and photovoltaic panel motion prediction. The flow chart of the algorithm structure is shown in Figure 6. \begin{table}
\begin{tabular}{c c c c c c c} \hline \hline
**Parameter** & \(\omega\) & \(c1\) & \(c2\) & \(r1\) & \(r2\) & \(r_{\text{max}}^{t}\) & \(r_{\text{min}}^{t}\) \\ \hline PSO & 0.6 to 0.2 & 2.5 to 0.5 & 0.5 to 2.5 & \begin{tabular}{c} Standard normal \\ distribution \\ \end{tabular} & \begin{tabular}{c} Standard normal \\ distribution \\ \end{tabular} & - & - \\ \hline MHPSO–LSTM & 0.6 to 0.2 & 2.5 to 0.5 & 0.5 to 2.5 & \
\begin{tabular}{c} Standard normal \\ distribution \\ \end{tabular} &
\begin{tabular}{c} Standard normal \\ distribution \\ \end{tabular} & 1.3 & 0.4 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Parameter summary. Figure 5: Multilayer heterogeneous particle swarm optimization (MHPSO) algorithm flow chart. In this work, we forecast the future motion data of a PV panel swing state through known historical swing data. In order to verify the precision and advantage of the MHPSO-LSTM method, we used a BP (back propagation) neural network, Kalman filter, LSTM neural network, PSO-LSTM network, and MHPSO-LSTM network model for comparative experiments. We used Equation (19) to normalize the data to a [0,1] interval in order to converge quickly. For the evaluative indicators of the forecast results, we took the mean absolute percentage error (MAPE) and root mean square error (RMSE), where \(\hat{x}_{t}\) is the prediction results of PV panel motion and \(x_{t}\) is the actual values of panel motion. \[M_{i}=\frac{x_{i}-x_{\min}}{x_{\max}-x_{\min}} \tag{19}\]  
\[MAPE=\frac{1}{n}{\sum\
olimits_{i=1}^{n}}\left|\frac{\hat{x}_{t}-x_{t}}{x_{t} }\right|\times 100\% \tag{20}\]  
\[RMSE=\sqrt{\frac{\sum\limits_{j=1}^{n}{(\hat{x}_{t}-x_{t})^{2}}}{x_{t}}} \tag{21}\]  
In the simulation process, the measured data input was sourced from level 5 and level 3 sea states. The sea state is divided into 10 levels according to the sea surface fluctuations, and the shape of the wave peaks and the degree of breakage, which is expressed as 0-9 level from low to high. The sampling frequency of the measured PV tilt change was 0.193 s, the quantity of training samples was 250, and the number of predicted samples was 50, respectively. Additionally, the forecast duration was 9.65 s, and in the improved LSTM structure, the hidden layers were set to 3, the number of neurons was 50, number of iterations was 200, epoch times was 200 and the output data were the tilt angles of the photovoltaic panel, include the roll and pitch, which was then calculated by the matrix proposed in the second section for the Z-axis rotation matrix to get \(\delta\). The above models (Kalman, BP, PSO-LSTM, LSTM, and MHPSO-LSTM) were used to predict the inclination of the PV panel under the level 5 and level 3 sea states. Figure 7 shows a comparison of the angle prediction results of the different prediction methods under the fifth-level sea state. Figure 8 shows a comparative group under a level 3 sea state. Figure 6: Neural network structure of the LSTM model based on MHPSO. MAPE: Mean absolute percentage error. RMSE: Root mean square error. Figure 7a indicates the prediction curve of the pitch angle under a level 5 sea state, which corresponds to \"pitch\" in Equation (4). Similarly, Figure 7b corresponds to \"roll\" in Equation (4). Figure 9 shows that the prediction error of the proposed PSO algorithm can be controlled to within \(\pm\)0.1 degree. It can be seen in Table 2 that the values of the MAPE and RMSE are used for the forecast.