# Deep Learning Forecasting for Supporting Terminal Operators in Port Business Development
## 3 Materials and Methods
### The Model  
This section describes the neural network models developed. Let \(\mathcal{S}=\{s_{1},s_{2},\dots\}\) be the ordered set of the different seasons considered (i.e., quarterly data have \(|\mathcal{S}|=4\) and monthly data \(|\mathcal{S}|=12\)) and \(\mathcal{Y}=\{y_{1},y_{2},\dots\}\) be the set of years under investigation. Wedenote by \(\mathbf{r}^{(t)}\in\mathbb{R}^{l}\) the multivariate time series of the container traffic volume with a given level of detail at time \(t\). The index \(t\) is supposed to vary in \(\mathcal{T}=\{t\in\mathbb{N}:t\leq|\mathcal{Y}\times\mathcal{S}|\}\) such that each integer \(t\in\mathcal{T}\) uniquely identifies a pair \((y,s)\in\mathcal{Y}\times\mathcal{S}\) according to the chronological order of the seasons and the years.  
We model \(\mathbf{r}^{(t)}\) as a function of the season \(s\in\mathcal{S}\) and its previous \(|\mathcal{S}|\in\mathbb{N}\) time lags:  
\[\mathbf{r}^{(t)}=f(s,\mathbf{r}^{(t-1)},\mathbf{r}^{(t-2)},\dots,\mathbf{r}^{(t-|\mathcal{S}| )}). \tag{13}\]  
We modelled the function \(f(\cdot)\) using neural networks since they are known to be universal approximators [56]. Our neural network architecture combines some of the network architecture described in Section 3.1.  
The season \(s\) is modelled using embedding networks. When choosing an embedding size \(q_{s}\in\mathbb{N}\), an embedding layer maps  
\[\mathbf{z}_{\mathcal{S}}:\mathcal{S}\rightarrow\mathbb{R}^{q_{s}},\qquad p\mapsto \mathbf{z}_{f}(s). \tag{14}\]  
where \(\mathbf{z}_{f}(s)\) is a set of new features that summarises the information concerning the seasonal effect and represents \(s\) in a way that is optimised with respect to the desired output in a \(q_{s}\) real-valued dimensional space. Information related to the previous \(|\mathcal{S}|\) time lags of \(\mathbf{r}^{(t)}\) is processed by neural networks layers specifically designed to process sequential data such as LSTM, GRU, or CNN layers. For illustrative purposes, we will consider the LSTM networks, but an interesting comparison among these different neural networks architecture will be carried out in the numerical experiments section.  
Let \(R^{(t)}=\{\mathbf{r}^{(t_{0})}\}_{t-|\mathcal{S}|\leq t_{0}<t}\in\mathbb{R}^{l \times|\mathcal{S}|}\) be the matrix that contains the previous \(|\mathcal{S}|\) observations of \(\mathbf{r}^{(t)}\). An LSTM layer with \(q_{r}\in\mathbb{N}\) units processes it as illustrated in equations \(R^{(t)}\), and the output is  
\[\mathbf{z}_{r}(r)=f(R^{(t)}).\]  
The set of new features \(\mathbf{z}_{r}(r)\in\mathbb{R}^{q_{r}}\) summaries the information related to the container traffic volume of the previous \(|\mathcal{S}|\) time lags. Let \(\mathbf{z}=(\mathbf{z}_{s},\mathbf{z}_{r})^{\prime}\in\mathbb{R}^{q_{s}+q_{r}}\) be the full set of features obtained concatenating the output of the embedding and LSTM layer. The quantity of interest \(\mathbf{r}^{(t)}\) can be calculated by processing \(\mathbf{z}\) with a fully connected layer:  
\[\mathbf{r}^{(t+1)}=\mathbf{\phi}(\mathbf{b}_{0}+\mathbf{W}\mathbf{z}). \tag{15}\]  
The embedding weights \((\mathbf{z}_{s},\forall s\in\mathcal{S})\), the LSTM weights \((W^{(p)},\,U^{(p)},\mathbf{w}_{0}^{(p)},\forall p\in\{r,z,c\})\), and the weights of the fully connected layer (\(\mathbf{b}_{0}\) and \(\mathbf{W}\)) must be properly optimised in order to minimise the error of the network outputs with respect to the reference values. A graphical representation of the proposed neural network model is provided in Figure 2.