# Sustainable Parking Space Management Using Machine Learning and Swarm Theory--The SPARK System
## 3 Methodology Concept
### Applied Algorithms and Technologies in This Study
#### 3.3.3 The You Only Look Once (YOLO) Algorithm for Object Segmentation in Images
No signs of overfitting were observed, indicating an effective balance between model precision and generalization. The achieved accuracy was 0.942, with the loss function stabilizing around 0.17, reflecting high-quality segmentation and a robust training process. By fine-tuning a pre-trained YOLO v9e model with a custom dataset of car images, high-precision segmentation of vehicles was achieved. The model was subsequently applied to detect car polygons in camera images transformed into the EPSG:3857 coordinate system. This alignment with the database of organized city parking space polygons facilitated the implementation of the ABC algorithm to detect potential free parking spots. 3.3.4. The Artificial Bee Colony (ABC) Algorithm for Parking Space Optimization  
This study applies the ABC optimization algorithm to optimize the placement of parking spaces in unoccupied areas, based on predefined dimensions. The algorithm aims to maximize the number of vehicles accommodated by identifying the most efficient positions and orientations for parking spaces. To enhance efficiency, ABC optimization is applied separately to each parking zone, rather than the entire area. This approach allows for real-time data updates and integration with a database, ensuring responsive and accurate suggestions for available parking. The optimization model is built upon three fundamental components: variables, constraints, and the cost function (or objective function). The variables represent the predefined parking space slots that are iteratively optimized to fit the maximum number of vehicles within the handled area. For each slot, random \(x_{i}\) and \(y_{i}\) coordinates and a rotation angle \(\beta_{i}\) are assigned within the boundaries of the parking area. The algorithm then seeks the optimal configuration of these variables (\(x_{i}\), \(y_{i}\), and \(\beta_{i}\) for each slot \(i\)) across all \(N\) parking spaces, effectively forming a solution space of \(N\times 3\) variables. The constraints, as the second key component, ensure the feasibility of the solution by imposing the following conditions:  
* Parking slots must remain within the designated parking area. * Slots must not overlap with existing occupied spaces. * Newly allocated slots must not overlap with one another. These constraints are enforced using geometric operations, such as inside-outside checks and intersection area calculations, leveraging vector geometry during the optimization process. The cost function is a critical component for evaluating the quality of a given solution in the optimization process. In this study, the optimization model minimizes a cost function specifically designed to evaluate vehicle placement. Each vehicle randomly positioned by the algorithm incurs penalties based on its location: 5000 points if placed outside the designated area, penalties proportional to overlap with occupied areas, and additional penalties for overlapping with other newly placed vehicles. The objective is to minimize this cost function iteratively, achieving an optimal configuration where the cost is zero. The choice of 5000 as the penalty for vehicles placed outside the parking area reflects the need to strongly discourage such placements, as external locations should be entirely avoided by the algorithm. A smaller penalty of 300 is applied for overlaps between occupied and newly placed vehicles, ensuring that the algorithm prioritizes minimizing overlap within the parking area without incentivizing external placements. While these values are arbitrarily chosen, they can be adjusted as needed to achieve the same strategy, as long as the balance between penalties effectively guides the optimization process. Within 20 s, the  
Figure 5: Training and validation loss and precision trends across 120 epochs. Early stopping at epoch 87 ensures optimal precision and prevents overfitting (Source: Author’s own elaboration). algorithm successfully identified the optimal parking locations, which were then mapped to real-world coordinates.