# Switched Auto-Regressive Neural Control (S-ANC) for Energy Management of Hybrid Microgrids
## 3 Switched Auto-Regressive Neural Control (S-ANC)
### Simple Definition of the Proposed Method  
To comprehend the concept underlying S-ANC, one must first comprehend the distinctions between MPC and S-MPC when solving the QP and the two main learning methods of RNN: AR and LSTM. The S-MPC controller must be capable of selecting the appropriate model and control strategy based on the system's current state, which necessitates additional computational resources and algorithmic complexity. In this paper, for instance, the system dynamics change significantly as the state of each accumulator in the hybrid MG changes; consequently, S-MPC can use different models for various states. This requires creating and validating multiple models, and the S-MPC controller must be able to switch between these models based on the current state.  
The construction of S-MPC is challenging and intricate, particularly for a hybrid MG, which must accommodate many operating modes and complex switching conditions. This complexity is caused by a number of factors, including  
* **Model development**: S-MPC requires the creation of multiple models that represent the system's behavior in different operating modes. This requires an efficient system architecture and behavior;
* **Mode detection**: The S-MPC controller must be able to detect the current mode of operation of the system, which can be difficult in certain circumstances;
* **Switching logic**: The S-MPC controller must select the appropriate model and control strategy based on the current operating mode and desired performance objectives. This necessitates the designing of switching logic that maps the system's current state to the appropriate model and control strategy (a mode's objective function and an operational mode's objective function may differ).  
The S-MPC solution method takes information from the hybrid MG, such as PV and load data and accumulator parameters, including their charging and discharging efficiencies. Then, the input \(u\), state \(x\), and output vectors \(y\) are defined. Based on the controller model, the objective function \(J\) is inferred at each control step using this method.  
Figure 3: Hybrid MG Structure.  
After that, the state vector is converted to an AR model \(X(k)\), in order to predict the value at the subsequent time step. This is a straightforward concept that can produce accurate forecasts for various time series problems. Nevertheless, the AR model needs a plant model and a prediction horizon, so the computational time of the model is still high. Therefore, the current state \(x\), input \(u\), and output vectors \(y\) are updated using the AR-LSTM method.  
S-ANC employs time series value-based AR-LSTM to estimate the value of being in a particular output vector \(\hat{y}\), as determined by S-MPC, with a prediction horizon of only one control step. By doing so, in S-ANC, the S-MPC method is truncated with the predicted output vector \(\hat{y}\) and optimized by the hybrid MG system during \(k\) steps ahead through employing the AR-LSTM method.Consequently, the principal components of the S-MPC, namely the reference, predictor, and switching logic, remain active in S-ANC; however, the time series value function is utilized to shorten the nonlinear program and enable learning. The interaction of S-ANC's primary components is depicted in a diagram in Figure 4. The merging of S-MPC and AR-LSTM in the S-ANC algorithm is intuitively depicted in Figure 4.