# Parallel Agent-Based Framework for Analyzing Urban Agricultural Supply Chains
## 4 Agent-Based Framework for Analyzing Urban Agricultural Supply Chains
### Time Series  
We use time series to estimate the prices of the products. We use a neural network with an architecture based on transformers. We trained a model based on the architecture proposed by [36] for long-term time series forecasting. In this architecture, a time series decomposition process is used to enrich the internal layers of the network and improve information utilization. The decomposition blocks extract data on the seasonality and trends, which are then used to enhance the processes in subsequent blocks.  
A single model was generated that takes 24 months of context and the type of product to which the series belongs. This model consists of 32 encoder layers and 32 decoder layers and is capable of predicting 12 months. We tested different network sizes, and this one  
\begin{table}
\begin{tabular}{c c} \hline \hline
**Range of Number of Days** & **Threat Level** \\ \hline
1 to 3 days & Low \\
4 to 7 days & Medium \\
8 or more days & High \\ \hline \hline \end{tabular}
\end{table}
Table 4: Number of days in a month with a heat wave and the associated threat level.  
\begin{table}
\begin{tabular}{c c} \hline \hline
**Frost Intensity [\({}^{\circ}\)C]** & **Threat Level** \\ \hline
0 a –0.9 & Low \\ \(-1\) a –1.9 & Low \\ \(-2\) a –2.9 & Medium \\ \(-3\) a –3.9 & Medium \\ \(-4\) a –4.9 & High \\ \(-5\) a –inf & High \\ \hline \hline \end{tabular}
\end{table}
Table 2: Frost intensity and corresponding threat level.  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**SPI Value** & **Description** & **Threat Level** \\ \hline greater than 0 & Normal or rainy & None \\ between 0 and 0.5 & Normal & Low \\ between 0 and \(-0.5\) & Slightly dry & Low \\ between \(-1\) and \(-1.5\) & Moderately dry & Medium \\ between \(-1.5\) and \(-2\) & Dry & Medium \\ less than \(-2\) & Extremely dry & High \\ \hline \hline \end{tabular}
\end{table}
Table 3: SPI ranges and their corresponding threat levels, obtained from [32].  
produced the best results. We used a 70/30 train-test split and 5697 training series (across all products), each consisting of 36 data points, constructed from historical price data obtained from the official sources provided by ODEPA [37]. It contains the price records for the trade of fruits and vegetables in the metropolitan city of Santiago, Chile. The same prices are used for the sixth region of Chile. These data represent the nominal prices of the products listed in Table 1, excluding VAT. For some products, prices can be obtained either per unit or per kilogram. These series start from January 1994 onward; however, some products have missing months, while others have a shorter history, such as carrots with data available since 2004. We used linear interpolation to compensate for missing months in some products. Additionally, to increase the volume of data available to train the network, we concatenated the annual series, and we tested samples of fixed length, varying the initial month in each sample.  
Figure 6 presents the symmetric mean absolute percentage error (sMAPE), an accuracy metric based on percentage errors, along with the mean absolute scaled error (MASE). The figure indicates that the errors fall within the first quadrant, suggesting that the time series model can predict the cost of simulated products with minimal error.  
Figure 7 shows the actual price excluding VAT from 2017 to 2020 (blue line). We show the price in UF, which is a financial unit adjustable according to inflation, used in Chile. We also show the predicted values and their corresponding standard deviation, which is notably small. The results demonstrate that the predicted values closely align with the actual prices.  
Figure 6: Symmetric mean absolute percentage error (sMAPE) and mean absolute scaled error (MASE) of the predicted values.