# Adaptive Solar Power Forecasting based on Machine Learning Methods
## 3 The Algorithms to Realize ASPF
### Closed-Loop Feedbacks and Updates  
ASPF not only has the ability to compensate the error existed in original predictive solar power day-ahead, but also uses the historical solar actual power as the revised value. So, it is necessary to search for a similar day in the system. Besides, it should be feasible to use \(P_{sdm}\) as a substitute of \(P_{\textit{Free}}\), and important to guarantee this \(P_{sdm}\) with high accuracy. All above requirements are accomplished by the closed-loop feedback and updating mechanism.  
In this paper, we use \(\Delta_{2}\) to define the MxAE of the current forecasting model. In addition, the criteria for judging similar days is related to network parameters and determined by the maximal absolute error of the current BPNN. with the input data of \(\left|x_{i}-x_{j}\right|\), BPNN can get the difference of the predictive PV power and the actual values, if this difference is less than \(\Delta_{2}\), their corresponding actual values will be replaced by each other with acceptable errors. So the actual solar power of the similar data can be used as the revised value directly when this similarity meets certain conditions. Here, the specific relationship of the \(\Delta_{1}\) with the BPNN and this condition are shown below.  
The original forecasting models are built in Section 3.3, and after the models are trained, MxAE, weight \(\omega\) and bias \(b\) can be obtained from BPNN. BPNN can be formulated as the non-linear function, expressed as:  
\[\hat{y}=f(x^{{}^{\prime}}\omega+b) \tag{12}\]  
and for any input data \(x_{i},x_{j}\in\mathbb{S}\), if it satisfies:  
\[\left\{\begin{array}{l}\left|y_{i}-\hat{y}_{i}\right|\leqslant\Delta_{2}\\ \left|y_{j}-\hat{y}_{j}\right|\leqslant\Delta_{2}\end{array}\right. \tag{13}\]  
and the function \(f(\cdot)\) has the properties of monotonically increasing and derivable. So \(\left|\hat{y}_{i}-\hat{y}_{j}\right|\leqslant\left|f(\left|x_{i}-x_{j}\right|^ {{}^{\prime}}\omega+b)\right|\).  
In case 1, if \(y\geqslant f(x^{{}^{\prime}}\omega+b)\), the actual solar power will be larger than the revised one. Thus,  
\[(y_{i}-y_{j})\leqslant(f(x^{{}^{\prime}}_{i}\omega+b)-f(x^{{}^{\prime}}_{j} \omega+b)) \tag{14}\]  
so,  
\[\left|y_{i}-y_{j}\right|\leqslant(f(\left|x_{i}-x_{j}\right|^{{}^{\prime}} \omega+b))\leqslant\Delta_{2} \tag{15}\]In case 2, if \(y\leqslant f(x^{{}^{\prime}}\omega+b)\), the relationship of Equation (15) also can be obtained.  
Therefore, with the difference obtained by input data \(|x_{i}-x_{j}|\), \(f(\cdot)\) is known, if the result of \(f(\cdot)\) is less then \(\Delta_{2}\), \(y_{i}\) and \(y_{j}\) will be replaced by each other with acceptable errors. On the other hand, when the prediction model is invariant, by comparing the similarity of predicted input information, the actual solar power of similar historical day can be used as the revised PV power directly if it satisfies certain condition. In addition, we give this condition below.  
In practice, through comparing the maximal \(|x_{i}-x_{j}|\) and the corresponding value calculated by the \(f(\cdot)\) is known, it can be found that if \(\Delta_{1}\leqslant\max|x_{i}-x_{j}|\), then \(|y_{i}-y_{j}|\leqslant\Delta_{2}\). So the initial \(\Delta_{1}\) can be chosen as \(\max|x_{i}-x_{j}|\), and thus \(\Delta_{1}\) has a close relationship with the updated network. As the accuracy of the updating network increases, the precision of the similar days' solar power prediction becomes higher and higher. So it is reasonable to adopt historical actual solar power as the day-ahead revised data when the similar input message exists. Our proposed method is available for reusing the historical data to achieve better forecasting revision.