## 4 Self-Adaptive Multi-Density Prediction Model
### Multi-Kernel Support Vector Machine Forecasting
#### 4.3.2 Double-Layer Alternating Optimization Parameters  
The selection of the kernel function weight determines the proportion of the influence of each influencing factor. Selecting the appropriate weight coefficient can effectively adjust the role of each kernel function in the regression function and control the influence of heteroscedasticity. Therefore, this section uses the double-layer iterative method to solve the optimization of the kernel function weight, Lagrange multiplier, and parameters alternately. Until the stopping time criterion is satisfied, the optimal regression function is obtained. Compared to other methods, the biggest advantage of this method is that the weight coefficient can be obtained by learning to dynamically adjust the proportion of each single kernel function. In the first-layer kernel learning, according to the objective function and constraint conditions based on the normal LP form in Equation (4), the Lagrange multiplier is kept unchanged, and the optimal weight coefficient is calculated. The calculation process is shown in Equation (12):  
\[ \begin{split} L&=\sum_{i,j=1}^{l}y_{i}(\hat{\alpha }_{i}-\alpha_{i})-\varepsilon\sum_{i=1}^{l}(\hat{\alpha}_{i}-\alpha_{i})\\ &-\frac{1}{2}\sum_{i=1}^{n}\mu_{k}\sum_{i=1}^{l}\sum_{j=1}^{l}( \hat{\alpha}_{i}-\alpha_{i})\cdot(\hat{\alpha}_{j}-\alpha_{j})K_{MKL_{p}}(x_{ i},x_{j})\\ &+\beta\left(\frac{1}{2}\|\mu\|_{p}^{2}-\frac{1}{2}\right)- \gamma^{T}\mu\end{split}  \tag{12}\]  
After finding the partial derivative of L, we can obtain Equation (13):  
\[ \begin{split}\mu_{k}=\frac{1}{2\beta}\bigg{(}&\sum _{k}\sum_{i=1}^{1}\sum_{j=1}^{1}(\widehat{\alpha}_{i}-\alpha_{i})(\widehat{ \alpha}_{j}-\alpha_{j})k_{MKL_{p}}(X_{i},X_{j})\bigg{)}^{\frac{1}{q}-\frac{1} {p}}\\ &\times\bigg{(}\sum_{i=1}^{1}\sum_{j=1}^{1}(\widehat{\alpha}_{i} -\alpha_{i})(\widehat{\alpha}_{j}-\alpha_{j})k_{MKL_{p}}(X_{i},X_{j})\bigg{)} \end{split}  \tag{13}\]  
In the above formula,  
\[\frac{1}{p}+\frac{1}{q}=1,k=1,2,\ldots,k \tag{14}\]  
In the second layer, with the weight vector unchanged, the Lagrange multipliers are solved by the improved sequential minimum optimization algorithm, and then the gradient descent method is used to optimize alternately, until the termination condition is satisfied. The optimization steps are as follows if \(\widehat{\alpha}_{i}=\widehat{\hat{j}}_{i}=\widehat{\hat{j}}_{hi}=0\) and \(\alpha_{i}=\widehat{f}_{i}=f_{hi}\ \forall i=1,2,\ldots,N\). Step 1: initialize parameters; assume that \(\mu_{k}=\sqrt[]{\frac{1}{m}}\) and L \(=s=\infty\); the threshold \(\varepsilon\leq\left|1-\frac{L-S}{L_{s}-S_{x}}\right|\). Step 2: using a sequential minimum optimization algorithm to generate the working set X, \(\widehat{\alpha}_{X}=\widehat{\alpha}_{X1}\), \(\widehat{\alpha}_{X2},\ldots,\widehat{\alpha}_{XXX}\); \(\alpha_{X}=\alpha_{X1}\), \(\alpha_{X1},\ldots,\alpha_{XX}\). Step 3: \(\widehat{\alpha}_{X}^{M}=\widehat{\alpha}\); \(\widehat{\alpha}_{X}^{M}=\alpha\); update the Lagrange multiplier with Formula (2). Step 4: update the gradient by the gradient descent method. Step 5: calculate the step size \(S_{k}\): \(S_{k}=\frac{1}{2}\sum_{i=1}^{N}(f_{i,j}-g_{k,i})(\widehat{\alpha}_{i}-\alpha_{ i})\); \(\forall k=1,2,\ldots,m\). Step 6: \(L_{x}=\sum_{i}y_{i}(\widehat{\alpha}_{i}-\alpha_{i})-\sum_{i}\varepsilon( \widehat{\alpha}_{i}+\alpha_{i}),S_{x}=\sum_{k}d_{k}S_{k}\). Step 7: if the threshold termination condition is met, bring two multipliers into (6) and calculate the final Lagrange multipliers \(\alpha_{i}^{*},\alpha_{i}\) and weight vector \(\mu\); otherwise, return to Step 3. Overall, the proposed SAMD prediction model contains two main processing, multi-density clustering, and multi-kernel support vector machine models, which can better meetthe time variability of real-time electricity prices for the dynamic change in demand in the prediction model.