## 3 Proposed ESN-MPC Strategy for PMSM
### Proposed ESN-MPC Controller and Online Learning Process  
To improve the robustness of the ESN-MPC controller in response to PMSM model parameter mismatch, an efficient online learning mechanism is developed to enable adaptive  
Figure 3: The process of ESN training data generation of proposed strategy.  
processing of new input-output samples collected from the control system. Inspired by the methodology described in [22], this paper integrates an online learning scheme called the Woodbury Online Learning Echo State Network (WOLESN). As described in Section 3.1, given a historical dataset \(\{\mathbf{Z}_{i},Y_{i}\}\), \(I=1\), \(2\), \(\ldots\), \(k-1\), the goal is to determine an appropriate matrix \(\mathbf{W}\) by minimizing the following objective function:  
\[\mathbf{J}(\mathbf{W})=\sum_{i=1}^{k-1}{(\mathbf{Y}_{i}-\mathbf{W}\mathbf{Z}_{i})(\mathbf{Y}_{i}-\mathbf{W} \mathbf{Z}_{i})^{T}} \tag{21}\]  
Taking the objective function's partial derivative with respect to \(\mathbf{W}\) and solving for zero yields the following expression:  
\[\frac{\partial\mathbf{J}(\mathbf{W})}{\partial\mathbf{W}}=0\Longrightarrow\sum_{i=1}^{k- 1}{(\mathbf{Y}_{i}-\mathbf{W}\mathbf{Z}_{i})(-\mathbf{Z_{i}}^{T})}=0 \tag{22}\]  
Assuming \(k-1\) samples are accumulated, the previously computed \(\mathbf{W}_{\text{old}}\) satisfies the solution below:  
\[\mathbf{W}_{\text{old}}=\mathbf{A}_{\text{old}}\mathbf{\Gamma}_{\text{old}}^{-1} \tag{23}\]  
where  
\[\mathbf{\Gamma}_{\text{old}}=\sum_{i=1}^{k-1}\mathbf{Z}_{i}\mathbf{Z}_{i}\mathbf{T};\mathbf{A}_{ \text{old}}=\sum_{i=1}^{k-1}\mathbf{Y}_{i}\mathbf{Z}_{i}\mathbf{T} \tag{24}\]  
When encountering a new data sample \(\{\mathbf{Z}_{k},\mathbf{Y}_{k}\}\) at \(k\), the updated matrices \(\mathbf{\Gamma}_{\text{new}}\) and \(\mathbf{A}_{\text{new}}\) become  
\[\mathbf{\Gamma}_{\text{new}}=\mathbf{\Gamma}_{\text{old}}+\mathbf{Z}_{k}\mathbf{Z}_{k}\mathbf{T}; \mathbf{A}_{\text{new}}=\mathbf{A}_{\text{old}}+\mathbf{Y}_{k}\mathbf{Z}_{k}\mathbf{T} \tag{25}\]  
The updated \(\mathbf{W}_{\text{new}}\) also satisfies the following relation:  
\[\mathbf{W}_{\text{new}}\Big{(}\mathbf{\Gamma}_{\text{old}}+\mathbf{Z}_{k}\mathbf{Z}_{k}\mathbf{T} \Big{)}=\mathbf{W}_{\text{old}}\mathbf{\Gamma}_{\text{old}}+\mathbf{Y}_{k}\mathbf{Z}_{k}\mathbf{T} \tag{26}\]  
To alleviate computational burdens associated with direct matrix inversion, the online updating can be efficiently calculated via the Sherman-Morrison formula. Specifically, the new updated \(\mathbf{W}_{\text{new}}\) is given by  
\[\mathbf{W}_{\text{new}}=\mathbf{W}_{\text{old}}+(\mathbf{Y}_{k}-\mathbf{W}_{\text{old}}\mathbf{Z} _{k})\mathbf{Z}_{k}\mathbf{T}\mathbf{K}_{k} \tag{27}\]  
Here, \(\mathbf{K}_{k}\) represents the inverse of \(\mathbf{\Gamma}_{\text{new}}\), computed recursively by  
\[\mathbf{K}_{k}=\mathbf{\Gamma}_{\text{new}}^{-1}=\mathbf{\Gamma}_{\text{old}}^{-1}-\frac{ \mathbf{\Gamma}_{\text{old}}^{-1}\mathbf{Z}_{k}\mathbf{Z}_{k}\mathbf{T}\mathbf{\Gamma}_{\text{old }}^{-1}}{1+\mathbf{Z}_{k}\mathbf{T}\mathbf{\Gamma}_{\text{old}}^{-1}\mathbf{Z}_{k}} \tag{28}\]  
As depicted in Figure 4, the prediction part is now replaced by the trained ESN, and the predicted current value at \(k+1\) is used to evaluate the optimal switching state and implement online learning. At each control instant \(k\), the controller stores the predicted output and activates the online learning block once the actual system response has been sampled at step \(k+1\). The newly updated output matrix \(\mathbf{W}_{\text{out}}\) is then employed to guide inverter actions in the subsequent control cycle prediction. In this manner, the proposed ESN-MPC strategy exhibits improved adaptive capabilities, effectively addressing the model mismatches.