# Parallel Agent-Based Framework for Analyzing Urban Agricultural Supply Chains
## 4 Agent-Based Framework for Analyzing Urban Agricultural Supply Chains  
Our simulator includes the entire marketing process of the farmer-fairground workers-consumer chain. The purpose of our simulator is to model the commercialization process of the typical farmer-fairground workers-consumer chain. We aim to analyze the behavior of each participant and the environmental conditions faced by producers during the planting and selling of fruits and vegetables. The model includes agents representing people such as farmers, fairground workers (FWs) or vendors, and customers. The geospatial space is divided into regions of the city. We assume that each land has a single farmer, and each customer agent buys the products required by its family, aiming to simulate the consumption of the entire population without increasing the number of agents. The flow of tasks executed by our simulator is detailed in Figure 2. We use event-driven simulation, which allows for greater granularity in specific events, enabling the planning process to interweave events from different processes. The tasks detailed in Figure 2 include:  
* Sowing: A farmer--whose land is in an empty state--decides on the product to plant and begins sowing. To this end, the farmer perceives his/her land as empty before starting the crop. The decision about which product to sow involves considering internal elements of the agent (such as whether they have agricultural insurance) and other environmental factors, including the risk of planting a certain product, weather conditions, and price. Farmer agents also perceive environmental and pest risk. * Harvest: The farmer harvests the product. This process increases the stock of the product based on the size of their land and the efficiency of the product (some products may lose a certain percentage of the production). Then, the farmer restarts the sowing process and starts planning the sale. * Sale to Wholesale Market: Once the farmer has the inventory of the products, the sale process begins. The wholesale market is an interaction point between agents; it \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Product** & **Sowing Months** & **Selling Months** & **Days Cult.** \\ \hline Garlic & Apr.–Aug. & All & 180 \\ Arichoke & Jan.–Feb. & May–Nov. & 90 \\ Celery & All & All & 70 \\ Green Pea & May–Aug. & All & 90 \\ Broccoli & All & All & 90 \\ Corn & Sep.–Dec. & All & 120 \\ Caulfilower & All & All & 130 \\ Spinach & All & All & 90 \\ Broad Bean & Apr.–Jun. & Jan.–May-Dec. & 90 \\ Lettuce & All & All & 90 \\ Melon & Jan.–Feb.–Sep.–Dec. & Jan.–Mar–Dec. & 120 \\ Salad Cucumber & Sep.–Dec. & All & 120 \\ Cranberry Bean & Jan.–Oct.–Dec. & Jan.–May–Dec. & 80 \\ Green Bean & Jan.–Sep.–Dec. & All & 80 \\ Cabbage & All & All & 100 \\ Watermelon & Jan.–Feb.–Sep.–Dec. & Jan.–Mar.–Dec. & 120 \\ Tomato & Aug.–Sep. & All & 90 \\ Carrot & All & All & 120 \\ Zucchini & Jan.–Sep.–Dec. & All & 100 \\ Strawberry & Apr.–May & Jan.–May–Oct.–Dec. & 120 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Products used in our simulator, with their respective sowing months, commercialization months, and days required to cultivate. does not store the product. During this process, the farmer informs the market about the products available. That is, the products are stored in an index data structure. Additionally, once the product perishes, it is removed from the index. * Purchase between fairground workers and farmers: This process takes place in the wholesale market. The fairground workers buy the products during a limited period of time. The fairground workers buy the number of products they estimate they will sell during the day. * Purchase between fairground workers and customers: Customers go to the wholesale market or to the open-air fairs to buy products from the fairground workers. The wholesale market is open every day, while the open-air fairs are open only one day a week, in different locations. E.g., a given open-air fair located in Providencia, Chile, only opens on Sundays.