# Predicting the Aggregate Mobility of a Vehicle Fleet within a City Graph
## 5 Two Approaches Using Neural Networks
### Application of Graph Neural Networks  
In this section, we assess the use of graph neural networks (GNNs) for the prediction problem defined in Section 3. GNNs are specially designed to process and learn from graph-structured data, the main applications being node classification, link prediction, and graph classification. To address the prediction of the number of assets associated with each node, a node representation or _embedding_ is constructed by the GNN. To perform this task, the GNN gathers and aggregates information from each node's neighbors, based on the connections within the graph. Such information is passed and updated between nodes and their neighbors through several layers of computation. Each layer typically involves two main steps: message passing, where information from neighboring nodes is aggregated, and node update, where the aggregated information is used to update the node representation. The application of GNNs in this paper is grounded on the assumption that the learned representation can capture complex relationships and dependencies inherent in the graph that may help for the prediction of the number of assets in each node. The main GNN architecture used in this paper is based on graph convolutional networks (GCNs) [18; 19], which is formalized as follows. Let us denote \(\mathbf{f}^{(i)}\) the feature vector that gathers the employed information associated with the \(i\)-th node of the network. Specifically, \(\mathbf{f}^{(i)}\) will be composed by a concatenation of the following elements:  
\[\mathbf{f}^{(i)}=\left(y_{\mathcal{F}}^{i}\parallel i_{id}\parallel T\right), \tag{12}\]  
where \(\mathcal{F}=\{T-W,\ldots,T-1\}\subset\{0,\ldots,T-1\}\) and \(y_{\mathcal{F}}^{i}=\left(y_{T-W}^{i},\ldots,y_{T-1}^{i}\right)\) is the vector of previous asset-occupation values at node \(i\) that are provided to the GNN, \(i_{id}\) is a (one-hot) encoding of the node \(i\) identification, and \(T\) is the time instant where the prediction is carried out. Note that \(W\), the number of samples used as node features, is a parameter of the model. Hence, if we accordingly denote \((y_{\mathrm{r}}^{p})^{i}\) to represent the \(i\)-th component of \(y_{\mathrm{r}}^{p}\) (i.e., the predicted occupation of such \(i\)-th node at time \(T\)), the node-wise input-output formulation of the GNN for our problem is as follows:  
\[h_{i} =\mathrm{AF}_{\mathbf{\Theta_{1}}}\left(\sum_{j\in\mathcal{N}(i) \cup\{i\}}\frac{e_{j,i}}{\sqrt{\hat{d}_{j}\hat{d}_{i}}}\mathbf{f}^{(i)}\right) \tag{13}\] \[(y_{\mathrm{r}}^{p})^{i} =\mathrm{MLP}_{\mathbf{\Theta_{2}}}\left(h_{i}\parallel\mathbf{f}^{( i)}\right) \tag{14}\]  
where AF defines a tunable affine transformation and MLP is a Multilayer Perceptron, their adjustable parameters being denoted by \(\mathbf{\Theta_{1}}\) and \(\mathbf{\Theta_{2}}\), respectively. The two sets of parameters are characterized by two hyper-parameters: the number of hidden layers and the number of neurons in each layer. \(\mathcal{N}(i)\) is the neighborhood of node \(i\) and \(\hat{d}_{i}=1+\sum_{j\in\mathcal{N}(i)}e_{j,i}\), where \(e_{i,j}\) denotes the edge weight between nodes \(i\) and \(j\). In our basic formulation, all edge weights are set to 1. The first step carries out a weighted feature aggregation of node \(i\) neighborhood nodes according to the topology and weights of the network. Then, the \(\text{AF}_{\mathbf{\Theta_{1}}}\) processes, via a tunable affine transformation, the aggregated feature vector gathering the previous asset-occupation values, node id and instant of time, in order to provide the embedding \(h_{i}\). Then, the \(\text{MLP}_{\mathbf{\Theta_{2}}}\) processes a concatenation of the AF output \(h_{i}\) with the node feature vector \(\mathbf{f}^{i}\), to provide the prediction value \((y_{\tau}^{p})^{i}\). The weights in the model described are trained through a stochastic gradient descent strategy on the whole set of nodes on a sufficiently large time series dataset (\(\mathcal{T}_{\text{train}}\)).