Introduction
Tomato, scientifically known as (Lycopersicon esculentum Mill), is one of the most widely consumed vegetables worldwide. In Iran, it ranks among the major vegetable crops and accounts for about 41.6% of the total vegetable production. The area under cultivation of this crop has been steadily expanding, and in 2023-2024, more than 130,000 hectares were allocated to tomato farming, resulting in an estimated yield of 5,049,910 tonnes (Ahmadi et al., 2022). Despite its importance, tomato production is continuously threatened by various pests that reduce both yield and quality. Among them, the tomato fruit worm Helicoverpa armigera (Hubner) (Lep: Noctuidae) is recognized as one of the most destructive species. This pest has become a major concern for tomato producers in Iran and many other countries due to its increasing economic impact (Guo et al., 2020; Singla & Singh, 2020). H. armigera feeds on the vegetative and reproductive structures of host plants, such as stems, leaves, flowers, and fruit, during various larval stages (Liu et al., 2004). Their strong preference for reproductive organs makes them especially damaging to crop yield. Early instar larvae typically feed on leaves near the oviposition site, whereas later instars move to reproductive structures such as flowers and fruits (Liu et al., 2007).
The larvae of this insect prefer to feed on plant organs with high nitrogen content, such as the reproductive parts and growth points of host plants (Sharma, 2001). The greatest damage to crops is caused by older larvae. In tomatoes, unripe fruits are attacked early in the season, and secondary infection by microorganisms leads to fruit rot, ultimately causing serious damage and a significant reduction in yield (Diatte et al., 2017; Sousa et al., 2021).The costs associated with yield reduction and control of this pest in tomato crops in Asia, Europe, and Africa are estimated to be approximately five billion dollars (Jones et al., 2019).
Farmers typically rely heavily on chemical pesticides to control the tomato fruit worm (Vivan et al., 2016). However, repeated use of these pesticides has not only led to resistance development but also caused environmental pollution and significantly increased production costs. Therefore, the use of integrated management is essential to prevent the improper application of pesticides (Fite & Tefera, 2022). To develop integrated management programs, knowledge of its population changes on farms over time (Garzia et al., 2011). Generally, for providing more efficient and accurate information when examining pest population trends and, consequently, ensuring timely pesticide application, innovative on-farm methods can be used to generate more realistic estimates at lower cost and in less time. Multiple studies have shown that artificial neural networks (ANNs) are highly capable of recognizing spatial distribution patterns of ecological populations (Irmak et al., 2006). An artificial neural network is an artificial intelligence tool used for studying the spatial and temporal dynamics of pest populations. For example, a study developed a prediction system for a system for predicting the risk level of western flower thrips using artificial neural networks and an adaptive neuro-fuzzy inference system. The numerical results demonstrated strong performance of both models, confirming their efficiency in pest monitoring (Tay et al., 2023). Artificial neural networks have also been used as a tool for seasonal prediction of Spodoptera spp. attack intensity in soybean fields. The selected artificial neural network incorporated weather data from 25 days before the pest density assessment. The prediction of the artificial neural network and pest density in soybean fields showed a correlation of 0.863 (de França et al., 2024). Heuristic search optimization methods are typically used to minimize errors in these networks; however, such methods may cause the network to become stuck in local optima, thereby limiting its overall performance. Therefore, it is necessary to utilize metaheuristic algorithms to provide better solutions or to achieve near-optimal values for optimization problems in neural networks. Metaheuristic algorithms offer three categories of solutions—near-optimal, optimal, and best—depending on real-world application areas (Alfa et al., 2020).
The Artificial Bee Colony (ABC) optimization algorithm and the Ant Colony Optimization (ACO) algorithm are two well-known metaheuristic algorithms. The Ant Colony algorithm is an optimization method inspired by the foraging behaviour of natural ant colonies. The Artificial Bee Colony algorithm, introduced by Karaboga, is inspired by the food foraging behavior of honey bees (Karaboga, 2005). These two approaches are highly effective because they can address a wide range of optimization challenges and employ randomized processes that improve the likelihood of reaching the global optimum. Furthermore, they are specifically tailored to boost the performance of artificial neural networks. Ant colony and bee colony algorithms have the potential to significantly enhance the effectiveness and efficiency of the training process, particularly when dealing with complex and high-dimensional datasets. The primary objective of these algorithms is to address the shortcomings of heuristic search methods and enhance the efficiency of weight optimization within artificial neural networks (Lamjiak et al., 2024; Socha & Blum, 2007). As a result, they expand the search efficiency of neural networks, improving the likelihood of achieving optimal solutions in complex problems. The application of these two algorithms is widespread and plays a significant role in almost all fields, including engineering, industry, and agriculture. Owing to their priority and superiority over other competitive optimization algorithms, these algorithms are widely preferred (Bourhis et al., 2021). However, no comprehensive and systematic research has been conducted using Ant Colony and Artificial Bee Colony algorithms to estimate pest dispersion in farms. Therefore, this study examined the performance of two nature-inspired algorithms, namely the Artificial Bee Colony Optimization algorithm and the Ant Colony Optimization algorithm, to determine the dispersion pattern of the tomato fruit worm population across the farm. Network-derived maps provide a basis for the precise and judicious application of chemical pesticides, leading to more effective and sustainable pest management in tomato cultivation. Therefore, there is hope that the optimized artificial neural network can be integrated in integrated pest management programmes on tomato farms.
Materials and methods
Geographic location and sampling method
For this research, a plot of land covering about 2,000 square meters was chosen, located at the geographical coordinates (38S, 693942E, 3800263N). Tomato seedlings of the Karoon variety were planted at the site. The field was organized into 32 rows, each spaced 150 cm apart, with a distance of 40 cm between the plants within each row and 110 plants were planted per row. Pest population fluctuations were monitored every five days using a systematic sampling pattern, counting H. armigera larvae at different developmental stages on plants numbered 5, 13, 21, and 29 within rows 2, 5, and 8. No pesticide was applied to maintain its natural spatial distribution. All planting, cultivation, and harvesting activities were conducted uniformly across all rows to ensure consistency in operations.
Data preprocessing
Data normalization, also known as data preprocessing, is a critical step for improving the performance of neural networks. This process, usually carried out before training the network, involves transforming the input data to enhance their clarity and usability for the model (Zou et al., 2009). Data normalization can be achieved using various methods, with min-max normalization being one of the most widely used approaches. This method involves transforming the feature values into a range typically between 0 and 1. The scaling process, known as min-max normalization, is mathematically expressed in Equation (1).
xnormalized=x-xmin/xmax-xmin
In the given expression, X represents the value of a random feature that requires normalization. In addition, xmin and xmax denote to the minimum and maximum values of the desired feature, respectively.
Perceptron neural networks
Multilayer perceptron neural networks are composed of one or more intermediate layers, where the input signals are initially standardized using normalization coefficients. Once the necessary calculations are completed, the final result is mapped back to the actual values (Wu & Feng, 2018). The calculated output values were compared with the actual values, and the error rate was determined. If the error rate differed from the predetermined desired value, the process returned to the previous step, the correlation coefficients were changed, and the calculations were repeated. These networks utilize the error backpropagation algorithm as the foundation of their training process (Novikov et al., 2015). Despite the overall success of the error backpropagation algorithm, it faces several fundamental challenges. One of the prominent problems is the slow convergence of the algorithm. Additionally, the success rate in convergence is strongly affected by the choice of initial values of the network weights, bias vectors, and fine-tuning of parameters such as the learning rate (Zhang & Zhang, 2018). To address the limitations of this algorithm, metaheuristic algorithms are employed to enhance convergence speed and optimize network weights Therefore, this study employs the Ant Colony Optimization (ACO) algorithm and the Artificial Bee Colony (ABC) algorithm.
Artificial neural network architecture
In the process of designing the structure and architecture of a neural network, the number of elements in the input vector is dictated by the specific nature of the problem under analysis and cannot be arbitrarily chosen. However, aspects such as the number of hidden layers, quantity of neurons, connectivity between neurons, choice of activation function, and number of iterations are entirely under the designer's control. Therefore, to enhance performance, an optimal design of the neural network is essential (Desjardins et al., 2015). A structured eight-step process was implemented to determine the model parameters and refine the design for optimal performance (Kaastra & Boyd, 1996). In this study, the optimized neural network employing the Ant Colony Optimization (ACO) algorithm with eight hidden neurons and the Artificial Bee Colony (ABC) algorithm with six hidden neurons demonstrated strong performance.
The sigmoid function was used as the activation function in the hidden layer, whereas a linear function was applied in the output layer. The total number of iterations for all steps was fixed at 1500 to ensure computational stability and maintain accuracy (Fig. 1).
Optimizing neural network weights using the Ant colony algorithm
The ant colony algorithm mimics the natural behavior of ants by employing simulated ants to navigate through a graph, offering an effective method for problem-solving. The key advantage of this method over genetic algorithms lies in its ability to handle dynamic graphs, allowing the ant algorithm to operate continuously and adapt to changes in real time (Ebid et al., 2024).
The main steps include four important stages: 1- Determine the initial values for ant colony parameters, such as the number of generations and the initial amount of pheromone 2- Represent the features as nodes of a graph (in this step, a number of ants are created and randomly placed on the nodes of the graph). Each ant starts with a random feature and then calculates the goodness of fit of all ants) 3- All representative ants collaborate simultaneously to construct a new solution. During this process, the (K) ant is randomly positioned on the (i) node (feature). From this starting point, ant k at node (i) chooses its next node (j) based on the probabilistic criteria outlined in Equation (2).

Here, nij represents the exploration information, and Jk(i) refers to the collection of neighboring nodes of node (i) that ant (K) has not yet visited. Parameters α and β are used to balance the significance of pheromones relative to the exploration information, which is calculated calculated as shown in Equation (3).

(N) represents the total number of training samples. Node (j) is added as equation (4):

where (q) represents a uniform random number between 0 and 1, (q₀) serves as the threshold parameter, and J ∈ Jk(i) denotes the node that is selected randomly based on the associated probabilities.
Once the next node is chosen, a new subset of features is created, and the goodness-of-fit of the ant is evaluated. The traversal process terminates when a stopping condition is satisfied (which may include reaching a predefined number of selected features, observing no improvement upon adding a new feature, or detecting negligible progress below a set threshold). 4- The fourth step focuses on updating the paths using pheromones. After selecting the ant with the lowest squared error, indicating the best solution, the overall update process begins. The only ant that succeeds in finding the best solution highlights a part of the optimal solution by increasing the pheromone level along its path. This process directs the search towards the neighborhood of the best solution. The update of this path is performed using Equations (5) and (6).

Parameter (p), where 0 < p ≤ 1, regulates the rate of pheromone degradation.
The operation terminates when meeting the stopping condition; otherwise, it proceeds to restart at the second step. It also stops if the default maximum solution is achieved and the comprehensive solution exhibits only minor successive changes (Li et al., 2024).
Optimizing neural network weights using the artificial honey bee colony
The artificial bee colony algorithm consists of three basic components: 1- worker bees, 2- non-worker bees, and 3- food resources. In this model, there are two behavior-guiding methods: recruiting new bees to explore rich food resources upon receiving positive feedback and abandoning poor food resources when negative feedback is received (Kıran & Fındık, 2015). In the artificial bee algorithm, a colony consists of three groups of bees: 1- worker bees associated with specific food sources 2- observer bees that monitor the selection of food sources, and 3- pioneer bees that search for food sources randomly. Both observer and pioneer bees are called non-worker bees. Initially, the forerunners identifiy the location of all available food sources. Once discovered, both forerunners and worker bees extract nectar from these sources. Over time, persistent harvesting depletes resources. Consequently, the worker bees transition into forerunners, restarting the cycle by searching for new food sources. In an artificial bee colony, each potential solution to the optimization problem is represented by the location of a food source, and the quantity of nectar at that source reflects the fitness of that specific solution. The population size matches the number of worker or observer bees, ensuring that every bee is linked to a single food source. The algorithm begins by generating an initial population of SN solutions, randomly distributed across potential food source locations. Here, SN corresponds to the number of worker or observer bees, and each solution (Xi) is represented as a (D) dimensional vector, with (D) denoting the number of optimization parameters. Within the framework of the artificial bee colony algorithm, each primary iteration is composed of three key steps; 1. Worker bees are dispatched to their respective food sources, where they evaluate the nectar quantity available. 2. Information about food sources is shared within the colony, enabling observer bees to select specific areas and extract nectar from the newly identified food sources for assessment. 3. Pioneer bees are then determined and sent randomly to explore potential food source locations, further bolstering the search for optimal solutions (Karaboga et al., 2011.( These steps are repeated a specific number of times, referred to as the maximum number of repetitions. During this cycle, the artificial observer bee chooses a food source based on the probability value (Pi) associated with it. This probability is determined using Equation (7).

In this equation, fitness (Si) represents the fitness value of the solution (Si), reflecting the quantity of nectar available at the food source located at the (i) position. Meanwhile, (Sn) denotes the total number of food sources, corresponding to the number of worker or observer bees in the colony. To establish a new food location based on the existing location stored in memory, the artificial bee colony uses the formula given in in Equation (8), as follows:

In the equation (8):

Indices are selected randomly, with the condition that while k is chosen arbitrarily, its value is different from (i). The parameter (øij), determined as a random number within the range of -1 to 1, plays a pivotal role in regulating the generation of neighboring food resources surrounding Xij. This equation demonstrates that as the gap between (Hij) and (Xkj) narrows, the deviation from the initial point position decreases proportionally. As the search progresses closer to the optimal solution, the step length gradually decreases. If any parameter surpasses its permissible limit, it is modified to be within an acceptable range. By employing this approach, the pioneer bee can identify a new food source using Equation (9).

Once the artificial bee generates and assesses the candidate source location (Vij), its efficiency is compared with that of the previous location. If the new source contains an equal or greater amount of nectar than the previous one, it replaces the earlier location in memory; otherwise, the prior location remains unchanged. In essence, this process reflects a greedy selection mechanism comparing the current and newly proposed locations (Kaya et al., 2022).
Stopping condition
The total number of algorithm iterations for all algorithms was considered to be 1500 and if there was no improvement in the fitness value after 400 iterations, the algorithms terminated. The neural network implementation, along with the artificial ant and honeybee colony algorithm, was developed using MATLAB version 24.2. Statistical comparisons were performed using SPSS version 21.
Results
To evaluate the ability of the trained neural network to predict the distribution pattern of H. armigera, a statistical comparison was conducted between the actual data and the predictions generated by the neural network, optimized using the artificial ant colony and honey bee algorithms. Here, the null hypothesis implies that the means are equal. A t-test was used to compare the means. Table (1) shows the calculated P-values for both the ant colony and artificial honey bee algorithms. The results indicate that the actual and predicted values by the neural network combined with the ant colony and the artificial honey bee algorithms were not statistically significantly different. The coefficients of explanation comparing the actual values from each sample with the predicted values generated by the neural network combined with the ant colony algorithm are presented in Table 2, and those derived from the artificial honey bee algorithm are displayed in Table 3. The findings indicate that the artificial neural network, enhanced with the artificial honey bee algorithm, demonstrates superior generalizability in estimating tomato fruitworm density under field conditions.
Spatial distribution maps of H. armigera using ant colony and artificial honey bee colony algorithms
A spatial distribution map of the tomato fruitworm was developed using an artificial neural network model. This model was enhanced using optimization techniques involving the ant colony and artificial honey bee colony algorithms, as illustrated in Fig. 2.
Discussion
Pests are widely regarded as a significant challenge and a major obstacle to improving the productivity of agricultural crops and their effective management plays a vital role in maintaining crop health and increasing yields. One major challenge in achieving effective pest management lies in the lack of comprehensive understanding of the numerous factors that shape pest dynamics and behavior.

|
Fig. 1. Pseudocode for artificial bee colony (right side of the image) and ant colony algorithm (left side of the image)
|
|
Table 1. Statistical comparisons between the observed and estimated to H. armigera by artificial neural network optimized whit ant colony optimization and artificial bee colony algorithm
|
|
Compear mean ANN whit Artificial bee colony
|
Compear mean ANN whit Ant colony
|
Date Sampling
|
|
0.54
|
0.78
|
2019/07/17
|
|
0.62
|
0.81
|
2019/07/22
|
|
0.76
|
0.73
|
2019/07/27
|
|
0.73
|
0.75
|
2019/08/02
|
|
0.73
|
0.78
|
2019/08/07
|
|
0.62
|
0.79
|
2019/08/11
|
|
0.68
|
0.80
|
2019/08/16
|
|
0.48
|
0.79
|
2019/08/21
|
|
0.74
|
0.89
|
2019/08/27
|
|
0.69
|
0.84
|
2019/09/01
|
|
0.71
|
0.80
|
2019/09/06
|
This study explores the development of an intelligent system designed to effectively predict the population dynamics of H. armigera in tomato fields, leveraging advanced techniques based on artificial neural networks. Developing such a system not only deepens the understanding of this pest's behavior but also facilitates more effective and efficient management strategies to control it. In this study, an artificial neural network optimized with two artificial bee and ant colony algorithms was able to accurately determine the distribution pattern of H. armigera and draw a map of the distribution of this species in the field. Based on the guide in Figure (2), the red areas are the most contaminated areas of the field. The resulting maps also show the cumulative distribution of this pest at different dates. These results were obtained based on data collected from a pilot field, during a planting to harvest period. Our findings showed that combining neural networks with artificial ant and honeybee colony algorithms can be used as an effective tool for predicting and managing H. armigera populations in farms. By integrating a standard multilayer perceptron neural network with metaheuristic algorithms, we found that the system delivers results with very high accuracy, making it an optimal choice for developing a pest prediction model. These predictions can help farmers plan pest management, leading to reduced crop losses and less pesticide use.
|
Table 2. Coefficient of determination between actual and predicted values of the optimized artificial neural network with the artificial ant colony in the Training and testing phase
|
|
Test Phase
|
Training Phase
|
Date Sampling
|
|
0.9323
|
0.9541
|
2019/07/17
|
|
0.9678
|
0.9811
|
2019/07/22
|
|
0.9678
|
0.9899
|
2019/07/27
|
|
0.9701
|
0.9971
|
2019/08/02
|
|
0.9711
|
0.9762
|
2019/08/07
|
|
0.9725
|
0.9984
|
2019/08/11
|
|
0.9755
|
0.9961
|
2019/08/16
|
|
0.9797
|
0.9801
|
2019/08/21
|
|
0.9801
|
0.9911
|
2019/08/27
|
|
0.9599
|
0.9701
|
2019/09/01
|
|
0.9645
|
0.9873
|
2019/09/06
|
|
Table 3. Coefficient of determination between actual and predicted values of the optimized artificial neural network with the Artificial bee colony in the Training and testing phase
|
|
Test Phase
|
Training Phase
|
Date Sampling
|
|
0.9741
|
0.9868
|
2019/07/17
|
|
0.9877
|
0.9974
|
2019/07/22
|
|
0.9799
|
0.9826
|
2019/07/27
|
|
0.9716
|
0.9848
|
2019/08/02
|
|
0.9811
|
0.9861
|
2019/08/07
|
|
0.9799
|
0.9901
|
2019/08/11
|
|
0.9810
|
0.9936
|
2019/08/16
|
|
0.9722
|
0.9987
|
2019/08/21
|
|
0.9643
|
0.9899
|
2019/08/27
|
|
0.9780
|
0.9901
|
2019/09/01
|
|
0.9884
|
0.9901
|
2019/09/06
|


Fig. 2. Distribution map of H. armigera by neural network optimized by ant colony algorithm and artificial honey bee colony
As a result, such an approach will reduce environmental pollution. Once the input variables are known, they can be loaded into the aforementioned models to predict the population of this pest and this allowing for timely and effective control strategies to be deployed, such as utilizing biological or chemical pesticides, based on threshold values. This study's findings align closely with those of earlier research. For instance, one such study focused on developing a system to predict the risk level of western flower thrips (Frankliniella occidentalis) in rose greenhouses. Using artificial neural networks and an adaptive neurofuzzy inference system (ANFIS), the study demonstrated the remarkable effectiveness of these two networks in tracking and monitoring western flower thrips (Tay et al., 2023).
Also, in a study that compared the performance of an optimized artificial neural network with the colonial competition algorithm and the mixed frog mutation to predict the distribution pattern of the seven-spotted ladybird (Coccinella septempunctata) in a hay field in Zarqan County, the results showed that the mixed frog mutation algorithm had higher accuracy than the colonial competition algorithm in detecting the distribution of this predator (Mohammadi & Alosfour, 2022). A study utilized the LVQ4 neural network to examine the spatial distribution of the tomato leaf miner moth across three distinct scales. Findings revealed that the LVQ4 neural network demonstrated remarkable accuracy and efficiency in analyzing the pest's distribution patterns, effectively identifying its cumulative distribution trend (Shabani nejad et al., 2016). Although previous research in the field of pest spatial distribution analysis has shown impressive accuracy and efficiency, but this study opted for ant colony and artificial honey bee colony algorithms because of their exceptional capability to determine optimal weights for the neural network. These algorithms, by utilizing their unique mechanisms, are not only capable of passing through local minima, but also capable of exploring the numerical search space with high accuracy and without deviation from the optimal path to determine the most accurate weights for the neural network. These features make them an ideal solution for addressing complex optimization challenges across diverse scientific disciplines.
The research documented in this article using ANN models in agriculture is precisely suited for integrated pest management. By employing advanced techniques like optimized neural networks, it becomes possible to achieve significant objectives, such as minimizing pesticide usage while preserving or enhancing crop yields, making this approach one of the most impactful advancements in modern agricultural practices. Using advanced technologies, the pest population in different parts of the farm is identified and evaluated in precise detail, and a map of the population density of these pests is prepared. This map allows the identification of areas where the pest population has exceeded the economic threshold, enabling farmers to take targeted action only in these areas.