## 3 PV Generation Forecaster Models
### Artificial Intelligence Models
#### 3.2.2 Non-Linear Autoregressive with Exogenous Input Neural Network  
NARX neural networks are considered a type of recurrent neural network (RNN) that have been widely used in the literature for time series prediction due to, on the one hand, their easy implementation and, on the other hand, their fast-training procedures. As can be seen in Figure 5, the predictions carried out by dynamic neural networks, such as NARX, are driven by the historical input-output pairs, as well as by the previous states of the network, that is to say, by the input and feedback delays.  
Figure 4: Structure of an FFNN.  
In Figure 5, \(X\) and \(Y\) represent the input and outputs vectors, respectively, \(W_{i}^{h1}\) is the weight matrix, \(b_{hi}\) is the bias, and finally, the TDL block represents the tapped-delay lines, that is to say, the number of time delay steps applied to the input and the feedback (output).  
NARX neural networks are based on a Multi-Layer Perceptron (MLP) structure, which consists of an input layer, hidden layer, and output layer that are connected by adjustable weights, and the neurons that compose the hidden and output layer are associated with bias values [24]. The weights and biases are adjusted during the training process of the network, aiming to achieve their optimal values and make the best approach between the input and output of the network.  
In each layer, each neuron carries out a scalar multiplication of the input vector \(x_{j}\) and the weight matrix \(w_{ij}\) Likewise, the activation function (\(\varphi\)) is added, obtaining the following equation in the output of each neuron:  
\[y_{i}=\varphi\left(\sum_{j=1}^{n}x_{j}*w_{ij}\right) \tag{3}\]  
The activation function that is chosen for each layer may change depending on the application in which the neural network is used. Usually, the activation function applied in the input and hidden layer is the sigmoid, and the one used in the output layer is the linear function.  
The following equation shows the input-output relationship using a NARX:  
\[y^{t+1}=f\left(x_{1}^{t},x_{1}^{t-1},x_{1}^{t-2},\ldots,x_{p}^{t-D_{xp}},y^{ t},y^{t-1},y^{t-2},\ldots,y^{t-D_{y}}\right), \tag{4}\]  
where \(y^{t+1}\) is the future value of the target variable, \(p\) is the total exogenous inputs, \(D_{xp}\) is the time lag of each exogenous input \(x_{p}\) and \(D_{y}\) is the time lag of the historical targeted values \(\left(y^{t},y^{t-1},y^{t-2},\ldots,y^{t-D_{y}}\right)\).  
The number of time delay steps of the output, \(D_{y}\), is the one that gives recurrence to the NARX, in contrast to the structures of other RNNs, in which the recurrence is given by the internal state of the network [23]. Additionally, \(f\) is the non-linear mapping function performed by the MLP. MLP is a powerful structure very appropriate for learning any kind of nonlinear mapping [25].  
In the first place, the training of the network is performed in open-loop (series-parallel) architecture (see Figure 6a) whenever the historical data of the targeted output are available. The network can be trained using different types of training algorithms, with the Levenberg-Marquardt backpropagation algorithm being the most widely used. After the training is concluded, the loop is closed (see Figure 6b), and this time backs, signaled estimations are introduced to the model. In the second phase, also called simulation or operational mode, the step-ahead forecasting is carried out.  
Figure 5: A general NARX diagram is used for forecasting purposes in operational mode [23].