# Switched Auto-Regressive Neural Control (S-ANC) for Energy Management of Hybrid Microgrids
## 2 Identifying the Distinctions between S-MPC and AR-RNN-LSTM
### Strategy  
There are typically two ways to approach an optimal control problem: by employing the S-MPC-inherent receding horizon principle or formalizing the problem as an AR-LSTM. S-MPC is a control strategy that involves using a mathematical model of the system being controlled to predict the system's future behavior and optimize a control signal over a finite time horizon. At each time step, the control signal is updated based on the current state of the system and the predictions made by the model. This is widely used in industrial control applications, such as process control, automotive control, and robotics, where it is important to consider the system dynamics being controlled and to optimize performance over a prediction horizon. At each time step \(k\) in S-MPC, switching logic controls multiple modes for the accumulators, which fully describe the controller model at the current time.Then, the trajectories of the future state \(x\) and input \(u\) are optimized for a prediction horizon \(N_{P}\) based on the explicit representation of an objective function \(J\) and a controller model \(F\). \(J\) is the minimization of the imported energy and maximization of the exported energy. The constraints \(H\) are also introduced explicitly in the optimization problem. The objective function, model, and constraints may also depend on the model outputs \(y\) and time-invariant parameters \(p\). In addition, \(r(k)\) is the reference variable representing the PV, load data, and zero along the prediction horizon \(N_{P}\). \(w_{x}(k)\) and \(w_{u}(k)\) are weighting coefficients reflecting the relative significance of \(x(k)\) and penalizing relatively large variations in \(u(k)\), respectively. Only the initial control input from the optimized trajectory [16] is Implemented. Figure 1a depicts the full S-MPC procedure. \[J(k)=\sum_{k=0}^{N_{P}}w_{x}(k)(r(k)+x(k))^{2}+\sum_{k=0}^{N_{P}}w_{u}(k) \Delta u(k)^{2}+\sum_{k=0}^{N_{P}}w_{y}(k)y(k)^{2}+p^{2} \tag{1}\]  
In the application of S-MPC to EM of MGs, the state vector \(x\) represents the state of charge of the accumulators (\(SOAcc\)), such as the battery, fuel tank, and water tank, and the model output \(y\) illustrates the imported and exported energy, such as a grid to the load \(GR_{LD}\) and PV to the grid, and the battery (\(PV_{GR}+PV_{BAT}\)). Depending on whether or not the controller model employs physical insights, the set of time-invariant parameters \(p\) may or may not represent the physical properties of the MG. In contrast to RNN-LSTM, AR models are not neural network architectures. On the contrary, they are statistical models that identify dependencies and patterns within a time series, based on its own lagged values. The AR model predicts the future values of a variable based on its historical values and the estimated coefficients during model training. In other words, AR models are a statistical modeling technique that assumes a variable's current value is a function of its previous values. They are frequently utilized for time series analysis and forecasting. Therefore, AR models can be viewed as a linear regression, in which the predictors are the values of the same variable at a prior time [32]. AR models can be used to model the system's dynamics within the context of control systems or reinforcement learning. A model can predict future states or observations by estimating the AR coefficients. These predictions can then be fed into control algorithms or reinforcement learning agents, in order to optimize control signals or decision-making. Unlike neural network architectures, AR models are not adaptive by nature. The estimation of AR coefficients requires training on historical data, and their performance may degrade if the underlying dynamics of the system change significantly over time.