# Parallel Agent-Based Framework for Analyzing Urban Agricultural Supply Chains
## 1 Introduction  
Computer simulation is a powerful tool widely used to model, analyze, and evaluate dynamic aspects of a system at different scales of complexity and precision. There are two highly effective yet fundamentally distinct approaches: agent-based modeling and discrete event simulations (DESs). DESs, along with their respective models, describe real-world systems that are complex to model analytically, in which changes in system variables occur in a discrete manner [1]. They have been widely used to gain insight into linear and process-driven systems. Agent-based modeling (ABM) provides a framework that enables the exploration of systems with interactive, adaptive, diverse, and in some cases spatially explicit intelligent decision makers [2]. It is effective in capturing the complex interactions among autonomous entities within a system.  
Hybrid approaches [3, 4, 5, 6] that integrate DES and ABM capabilities mark a significant advancement in the field of computational simulation. These models leverage the strengths of both approaches but often demand more complex implementation designs and particular attention to the integration points between them.  
In this work, we present a framework that combines both ABS and DES approaches to model the supply chain of fruits and vegetables. In particular, we evaluate our proposal using data from two different regions of Chile, the metropolitan city of Santiago and theO'Higgins Region (the sixth region of Chile). Our model includes farmers, fairground workers (FWs) or vendors, and customers. Farmers determine which crops to sow and harvest based on external factors such as market prices, while yields can be impacted by conditions like frost, drought, and pests. FWs decide which products to purchase from farmers based on seasonality, pricing, and other factors. Meanwhile, customers make purchasing decisions based on their budgets and household size.  
The simulation of this complex case study requires the management of multiple agents and a large number of events related to product purchases and agent interactions. Consequently, these simulations demand significant execution time. To address this challenge, we present an approximate optimistic parallel [7] implementation of our simulator. The logical processors (LPs) of the model are distributed among the processors using the Simulated Annealing (SA) [8] metaheuristic. Our approach incorporates a load-balancing algorithm designed to minimize the impact of heterogeneous communication patterns and workload distribution. The algorithm uses the concept of credit, meaning that when an FW initially purchases a product from a farmer (both hosted by different processors), it is assumed that the purchase will be successful. If so, the credit is canceled. Otherwise, if the farmer does not have enough of the requested product, the FW incurs a debt with both the product and the farmer, which will be canceled once the original requested quantity is replenished. Therefore, the contributions of this paper are as follows:  
* A hybrid ABM-DES simulator to model the supply chain of fruits and vegetables.
* We parallelize the hybrid ABM-DES simulation using an approximate optimistic approach and the SA metaheuristic to partition the model among the processors.
* We present a load-balance algorithm based on credits to reduce communication among processors.  
The remainder of this paper is organized as follows. In Section 2, we present related work. In Section 3, we present the production and sales dynamics in the supply chain of fruits and vegetables as our case study. Section 4 presents the proposed simulation model. Section 5 presents the parallel design of our simulator and the proposed load-balance algorithm. Section 6 presents the experimental results. Section 8 concludes the paper.