# Bayesian Network Demand-Forecasting Model Based on Modified Particle Swarm Optimization
## 2 Bayesian Network Model Construction
### Model Prediction Process
Similar to the adjustment process of parameter H, in each experiment, the work randomly selected the first 90% of the data from the training dataset for model fitting and the remaining 10% as model validation. The range of \(\alpha\) is defined in the set \(\{2^{-20},2^{-19},\ldots,2^{-1}\}\), the value of \(H\) is shown in Table 2, RMSE is taken as the measurement standard, and the experimental results are shown in Figure 7: \begin{table}
\begin{tabular}{c c c c c c c} \hline \hline  & **DS-1** & **DS-2** & **DS-3** & **DS-4** & **DS-5** & **DS-6** \\ \hline \(H\) & 9 & 16 & 17 & 8 & 17 & 28 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Set \(H\) on DS-1 to 6. Figure 6: The adjustment results of period \(H\) on DS-1–6. According to Figure 7, the value of \(\alpha\) on each dataset can be obtained, as listed in Table 3:

### Comparative Analysis of Prediction Results

In order to verify the effectiveness of the model and algorithm, firstly, this section selects four classic test functions and compares the MPSO algorithm with the standard PSO algorithm. The relevant descriptions of the four test functions are shown in Table 4. Secondly, this section compares the prediction effect of the proposed method on the above six datasets with the prediction effect of the ARIMA method. \begin{table}
\begin{tabular}{c c c c c c c} \hline  & **DS-1** & **DS-2** & **DS-3** & **DS-4** & **DS-5** & **DS-6** \\ \hline \(\alpha\) & \(2^{-11}\) & \(2^{-18}\) & \(2^{-16}\) & \(2^{-19}\) & \(2^{-3}\) & \(2^{-4}\) \\ \hline \end{tabular}
\end{table} 
Table 3: Set \(\alpha\) on DS-1 to 6 (\(\alpha={\sigma_{y}}^{-2}\)). Figure 7: (**a–f**) The adjustment results of period \(\alpha\) on DS-1–6. The population size is set to \(N=100\), the maximum number of iterations \(T_{\text{max}}=1000\), and the variable dimension \(D=30\). The two algorithms run 50 times independently, and the average and standard deviation of the results of 50 runs are recorded to evaluate the performance of the algorithm. The results are shown in Table 5.

It can be seen from Table 5 that the solution accuracy of the MPSO algorithm is better than that of classical PSO algorithm. Furthermore, this section uses the classical PSO algorithm and the MPSO algorithm to solve the parameters of the Bayesian network model and uses the solution results for prediction. In terms of the time complexity of the algorithm, the time complexity of the standard PSO algorithm is \(O(nmD)\), where \(n\) is the number of particles, \(m\) is the number of iterations of the algorithm, and \(D\) is the dimension of the problem. The MPSO algorithm uses Equations (21) and (22) to update the particle velocity and position, which is only one more adaptive decision than the standard PSO algorithm. The improved strategy does not increase the time complexity of the algorithm. Through the above experiments and analysis, the MPSO algorithm has better performance in solving multimodal function problems with higher dimensions. Next, we apply the algorithm to solve the actual prediction problem and further prove that the algorithm is better than the PSO algorithm through the prediction effect. In the process of model prediction, other parameters also have an impact on the data fitting and solving efficiency. Through several experiments, the values of other parameters are shown in Table 6: \begin{table}
\begin{tabular}{c c c c c c c c} \hline \hline \multirow{2}{*}{**Datasets**} & \multicolumn{3}{c}{**Variance Parameters**} & \multicolumn{3}{c}{**MPSO Parameters**} & \multicolumn{3}{c}{**Prediction Length**} \\ \cline{2-7}  & \(\sigma_{\gamma}{}^{-2}\) & \(\sigma_{\beta}{}^{-2}\) & \(\sigma_{\mu}{}^{-2}\) & \(\sigma_{\phi}{}^{-2}\) & \(c_{1}\) & \(c_{2}\) & \(\delta\) & \(\pi\) \\ \hline DS-1 & 0.01 & 0.001 & 0.01 & 0.5 & 1.5 & 1.5 & 0.6 & 7 \\ DS-2 & 0.01 & 0.001 & 0.01 & 0.5 & 1.5 & 1.5 & 0.6 & 7 \\ DS-3 & 1 & 1 & 1 & 1 & 1.5 & 1.5 & 0.6 & 7 \\ DS-4 & 1 & 1 & 1 & 1 & 1.5 & 1.5 & 0.6 & 5 \\ \hline \hline \end{tabular}
\end{table} 
Table 6: MPSO parameter settings.