# Bayesian Network Demand-Forecasting Model Based on Modified Particle Swarm Optimization
## 2 Bayesian Network Model Construction
### Model Prediction Process
\begin{table}
\begin{tabular}{c c c} \hline \hline \multicolumn{1}{c}{**Name**} & **Benchmark Functions** & **Range** & \(f_{opt}\) \\ \hline Schwefel 2.22 & \(f_{1}(x)=\sum\limits_{i=1}^{D}|x_{i}|+\sum\limits_{i=1}^{D}|x_{i}|\) & [\(-\)10,10] & 0 \\ Ackley & \(f_{2}(x)=-20 exp(-0.2\sqrt{\frac{1}{D}\sum\limits_{i=1}^{D}{(x_{i})^{2}}})-exp \big{(}\frac{1}{\sum\limits_{i=1}^{D}{cos(2\pi x_{i})}}\big{)}+20+e\) & [\(-\)32,32] & 0 \\ [PERSON] & \(f_{3}(x)=\frac{1}{400}\sum\limits_{i=1}^{D}{x_{i}^{2}}-\sum\limits_{i=1}^{D}{ cos(\frac{x_{i}}{\sqrt{i}})}+1\) & [\(-\)600,600] & 0 \\ [PERSON] & \(f_{4}(x)=\sum\limits_{i=1}^{D}{\big{[}{x_{i}^{2}}-10\alpha(2\pi x_{i})+10\big{]}}\) & [\(-\)5.12,5.12] & 0 \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Benchmark functions. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Function** & **Index** & **MPSO** & **PSO** \\ \hline \multirow{2}{*}{\(f_{1}\)} & Mean & \(1.1605\times 10^{-34}\) & \(2.2009\times 10^{-4}\) \\  & Std & \(7.5208\times 10^{-34}\) & \(3.4046\times 10^{-4}\) \\  & Mean & \(4.4409\times 10^{-16}\) & \(2.2597\times 10^{-5}\) \\  & Std & 0 & \(3.4402\times 10^{-5}\) \\  & Mean & 0 & \(8.7885\times 10^{-7}\) \\  & Std & 0 & \(2.1279\times 10^{-6}\) \\  & Mean & 0 & \(6.3885\times 10^{-4}\) \\  & Std & 0 & \(4.5000\times 10^{-3}\) \\ \hline \hline \end{tabular}
\end{table} 
Table 5: Comparison of operation results. In the process of model prediction, different initialization parameters may have an impact on the prediction results, so the experiment was repeated 10 times for each dataset, and the final result was taken as the average of the 10 experiments. The prediction results are summarized as shown in Table 7:

In order to better verify the effectiveness of the model and algorithm, datasets DS-1, DS-2, DS-3, DS-5, and DS-6 were selected to conduct experiments in the predicted length of 10, 20, and 30 days, respectively. Due to the relatively small amount of data in dataset DS-4, this experiment was not carried out on it. In addition, it can be seen from Figure 5 that the demand for datasets DS-5 and DS-6 fluctuates greatly, and there are many zero values. Hence, we use the Croston method to predict these two datasets. When the real value is 0, the prediction error evaluated by the MAPE index will approach infinity, so the results measured by the MAPE index are invalid. Therefore, when MAPE is used as the evaluation index in this paper, when the actual value is 0, the mean value of the actual value in the sample is used for correction. MAPE reflects the relative size of the error between the predicted value and the actual value, and a smaller value of MAPE indicates a higher accuracy of the prediction. The experimental results are shown in Table 8: \begin{table}
\begin{tabular}{c 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-9}  & \(\sigma_{\gamma}{}^{-2}\) & \(\sigma_{\beta}{}^{-2}\) & \(\sigma_{\mu}{}^{-2}\) & \(\sigma_{\phi}{}^{-2}\) & \(c_{1}\) & \(c_{2}\) & \(\delta\) & \(n\) \\ \hline DS-5 & 0.1 & 100 & 1 & 0.5 & 1.5 & 1.5 & 0.6 & 61 \\ DS-6 & 0.1 & 100 & 100 & 0.5 & 1.5 & 1.5 & 0.6 & 61 \\ \hline \hline \end{tabular}
\end{table} 
Table 6: _Cont._ \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**The Dataset** & **ARIMA** & **PSO** & **MPSO** \\ \hline DS-1 & 9.4635 & 7.8649 & 6.7964 \\ DS-2 & 11.7463 & 5.9422 & 5.0250 \\ DS-3 & 11.8518 & 105.5616 & 9.9798 \\ DS-4 & 259.9827 & 105.4191 & 98.6192 \\ DS-5 & 5.7647 & 5.6727 & 5.6445 \\ DS-6 & 3.3200 & 3.2255 & 3.2073 \\ \hline \hline \end{tabular}
\end{table} 
Table 7: The RMSE value of the prediction result.