# Adaptive PI Control Strategy for Optimal Microgrid Autonomous Operation
## 5 Phase of Optimization
### LMSRE Algorithm  
As shown in Figure 3, adaptive filtering (AF) techniques are commonly employed to calculate the impulse response (IR) filter (\(\mathrm{J_{0}}\)) parameter [25]. On the other hand, the input \(\mathrm{I_{G}}\) is a Gaussian noise \(\mathrm{N_{G}}\) that passes through an FIR filter. As a result, it is determined by the error (\(\mathrm{e_{G}}\)) equation:  
\[\mathrm{e_{G}} =\mathrm{d_{G}}-\mathrm{X_{G}^{T}}\mathrm{J_{G}} \tag{7}\] \[\mathrm{d_{G}} =\mathrm{X_{0}^{T}}\mathrm{J_{G}}+\mathrm{N_{G}} \tag{8}\]  
where \(\mathrm{N_{G}}\) is the noise signal, \(\mathrm{X_{G}}\) is the estimated weight vector, \(\mathrm{X_{0}}\) is the unknown weight vector, and \(\mathrm{d_{G}}\) is the predicted signal.  
Figure 3: System prototypal of FIR filter.  
Equation (9) shows that the AF algorithms are iterated utilizing a gradient approach [25]:  
\[\mathrm{J}_{\mathrm{G}+1}=\mathrm{J}_{\mathrm{G}}-\upmu\cdot\
abla_{\mathrm{J}} \cdot\mathrm{T}(\mathrm{J}_{\mathrm{G}}) \tag{9}\]  
where \(\mathrm{G}\) is the number of iterations, and \(\mathrm{J}_{\mathrm{G}}\) is the input vector. The gradient (\(\
abla_{\mathrm{J}}\)) of the cost function (\(\mathrm{T}\)) is then calculated using Equation (10):  
\[\
abla_{\mathrm{J}}\mathrm{T}(\mathrm{J}_{\mathrm{G}})=\mathrm{sign}(\mathrm{ e}_{\mathrm{G}})\cdot(-\mathrm{I}_{\mathrm{G}})-\left[\frac{\exp(-|\mathrm{e}_{ \mathrm{G}}|)}{\sqrt{1+\exp(-|\mathrm{e}_{\mathrm{G}}|)}}\right] \tag{10}\]  
Equation (7) is substituted into Equation (8) to get:  
\[\mathrm{J}_{\mathrm{G}+1}=\mathrm{J}_{\mathrm{G}}-\upmu_{\mathrm{G}}\cdot \beta_{\mathrm{G}}\cdot\mathrm{sign}(\mathrm{e}_{\mathrm{G}})\cdot\mathrm{I}_{ \mathrm{G}} \tag{11}\]  
where \(\upmu_{\mathrm{G}}\) is configured to limit the errors, \(\upmu_{\mathrm{G}}\) must be signed for a colossal error to allow for fast convergence. In contrast, \(\upmu_{\mathrm{G}}\) must be lowered for minor errors. As a result, \(\upbeta_{\mathrm{G}}\) deviates from [0, 1] and is reduced for little mistakes and vice versa. As a result, \(\upmu_{\mathrm{G}}\) diverges in proportion to \(\upbeta_{\mathrm{G}}\) specified in Equation (12):  
\[\upmu_{\mathrm{G}}=\upmu\cdot\beta_{\mathrm{G}}^{\upalpha-1} \tag{12}\]  
where \(\upmu\) and \(\upalpha\) are constants in charge of \(\upmu_{\mathrm{G}}\)'s deviance. At that point, substituting Equation (11) for Equation (12) obtains:  
\[\mathrm{J}_{\mathrm{G}+1}=\mathrm{J}_{\mathrm{G}}-\upmu\cdot\beta_{\mathrm{G} }^{\upalpha}\cdot\mathrm{sign}(\mathrm{e}_{\mathrm{G}})\cdot\mathrm{I}_{ \mathrm{G}} \tag{13}\]  
The LMSRE technique alters PI Controller gains that employ Equation (13). The modified PI gains are as follows:  
\[\mathrm{k}_{\mathrm{p}(\mathrm{G}+1)}=\mathrm{k}_{\mathrm{p}(\mathrm{G})}+ \Delta\mathrm{k}_{\mathrm{p}(\mathrm{G})} \tag{14}\]  
\[\mathrm{T}_{\mathrm{i}(\mathrm{G}+1)}=\mathrm{T}_{\mathrm{i}(\mathrm{G})}+ \Delta\mathrm{T}_{\mathrm{i}(\mathrm{G})} \tag{15}\]  
\[\Delta\mathrm{k}_{\mathrm{p}(\mathrm{G})}=\Delta\mathrm{T}_{\mathrm{i}(\mathrm{ G})}=\upmu\cdot\beta_{\mathrm{G}}^{\upalpha}\cdot\mathrm{sign}(\mathrm{e}_{ \mathrm{G}})\cdot\mathrm{I}_{\mathrm{G}} \tag{16}\]  
The initial PI gains for all PI controllers are manually determined by evaluating the system within its limits specified in Table 4. The LMSRE results were derived from [25].