Abstract
The Fruit Fly Optimization Algorithm is a swarm intelligence algorithm with strong versatility and high computational efficiency. However, when faced with complex multi-peak problems, Fruit Fly Optimization Algorithm tends to converge prematurely. In response to this situation, this article proposes a new optimized structure—Quasi-affine Transformation evolutionary for the Fruit fly Optimization Algorithm. The new algorithm uses the evolution matrix in QUasi-Affine TRansformation Evolution algorithm to update the position coordinates of particles. This strategy makes the movement of particles more scientific and the search space broader. In order to prove its effectiveness, we compare Quasi-affine Transformation evolutionary for the Fruit fly Optimization Algorithm with five other mature intelligent algorithms, and test them on 22 different types of benchmark functions. In order to observe the multi-faceted performance of Quasi-affine Transformation evolutionary for the Fruit fly Optimization Algorithm more intuitively, we also conduct experiments on algorithm convergence analysis, the Friedman test, the Wilcoxon signed-rank test, and running time comparison. Through the above several comparative experiments, Quasi-affine Transformation evolutionary for the Fruit fly Optimization Algorithm has indeed demonstrated its strong competitiveness. Finally, we apply it to Capacitated Vehicle Routing Problem. Through comparing with the contrast algorithms, it is confirmed that Quasi-affine Transformation evolutionary for the Fruit fly Optimization Algorithm can achieve better vehicle routes planning.
Keywords
Introduction
Generally, the optimization problem is to select some parameters, so that the design index can reach the optimal value under a series of related constraints. It can usually be expressed as a problem in the form of mathematical programming.1,2 Metaheuristic algorithm is an efficient optimization method based on computational intelligence. It has strong versatility and can solve various continuous problems as well as discrete problems.3–5 Up to now, there have been many mature metaheuristic algorithms with good performance, such as Sparrow Search Algorithm (SSA),6–8 Genetic Algorithm (GA),9–11 Butterfly Optimization Algorithm (BOA),12–14 Differential Evolution (DE),15–18 Cuckoo Search (CS),19–21 Harris Hawk Optimization (HHO),22–24 Gray Wolf Optimization (GWO),25–28 Fish Migration Optimization (FMO),29,30 Particle Swarm Optimization (PSO),31–34 Phasmatodea Population Evolution algorithm (PPE),35,36 Cat Swarm Optimization (CSO),37–39 and Ant Colony Optimization (ACO)40–43.
Fruit Fly Optimization Algorithm (FOA) is also a metaheuristic algorithm evolved by simulating the foraging process of fruit flies. It was proposed by Pan 44 in 2012. However, the optimization process of fruit fly relies heavily on its sense of smell. It first uses the sense of smell to identify the direction in which the food is most likely to exist. Then, many other individuals in the group fly to this place quickly. This can easily induce the algorithm to fall into a local extremum.45,46 Therefore, for this shortcoming, many scholars had made efforts. In 2015, Wang et al. 47 proposed an elite selection mechanism and applied the algorithm to joint supply problem. Next, in 2016, Zheng and Wang 48 created a dual-strategy mechanism to allow FOA to carry out more detailed local exploitation. Then, in 2018, Kanarachos et al. 49 and his team adopted a dynamic multi-decision method, so that the algorithm had the ability to self-adjust and improved the diversity of solutions in the iterative process.
QUasi-Affine TRansformation Evolution (QUATRE) is an excellent optimization evolution structure proposed by Pan et al. 50 in 2016. The position update of its search agent uses an affine transformation formula. Then, Meng et al. 51 compared the performance of QUATRE with various variants of PSO and DE, and demonstrated the powerful global optimization capabilities of it. In view of the good performance of QUATRE, many scholars had proposed a lot of algorithms based on it. In 2020, Du et al. 52 introduced the timestamp mutation strategy to QUATRE, so the performance of the algorithm was further promoted. In 2018, Meng and Pan 53 and his partners proposed a multi-group multi-selection communication strategy, which greatly improved the ability of the original QUATRE to perform global search, and applied it to the received signal strength indication (RSSI)-based wireless sensor network (WSN) node positioning problem.
In this article, combining FOA and QUATRE, a new intelligent algorithm is proposed—Quasi-affine Transformation evolutionary for the Fruit fly Optimization Algorithm (QTFOA). At first, QTFOA randomly allocates the location coordinates of search agents based on the mechanism of FOA, and determines the global optimal individual. In this way, randomly initializing the positions of the particles can greatly enhance the distribution range of the population, which is conducive to the subsequent global optimization. After entering the iteration, the algorithm uses evolution matrix in QUATRE to update the positions of particles. QUATRE’s unique affine transformation matrix allows particles to affine from one position to another, so that the jump-type position transformation can make the movement of the particles more scientific and have a wider range of optimization. In this way, the evolutionary method in FOA can perform local exploitation in detail without any worries. Because it largely does not have to worry about falling into a local optimum. This combination of FOA and QUATRE not only provides a guarantee for the global exploration but also lays the foundation for the local exploitation.
Capacitated Vehicle Routing Problem (CVRP)54–56 is a typical problem in transportation. Its foundation is Vehicle Routing Problem (VRP),57,58 which is a common problem in life.59,60 CVRP is a further expansion of VRP, which adds capacity restriction condition on the basis of original problem. There are already many algorithms for solving CVRP. Among them, the metaheuristic algorithm is particularly prominent. Metaheuristic algorithm can use search agents to quickly find the optimal path. Examples of good results include Sine Cosine Algorithm (SCA), Bee Algorithm (BA), Tabu Search algorithm (TS), Simulated Annealing algorithm (SA), and so on. Here, we applied QTFOA to this practical scenario and compared it with several other mature algorithms. It was finally confirmed that QTFOA could always find the shortest path.
There are five remaining sections in this article. Section “Related works” is an introduction of the theoretical basis of FOA and QUATRE. Section “The proposed QTFOA” details the operating mechanism of the newly proposed QTFOA. Section “Simulation experiment and result analysis” presents the experimental results of a series of performance tests. Section “Application of QTFOA in CVRP” verifies the excellent effect of QTFOA on CVRP. Section “Conclusion” summarizes the whole article and indicates the potential shortcomings of QTFOA.
Related works
FOA
Since modern times, fruit fly has become a model organism that is very popular among researchers. It has outstanding sense of smell and vision. After the fruit flies perceive the concentration of the food odor, they will send information to their companions. Similarly, each search agent also receives the odor concentration information transmitted by the companions. In this way, fruit flies can compare the odor concentration of various parties, and then use their excellent vision to fly to the location with highest concentration. Repeat this process continuously, and eventually they have a good chance of finding food. To unify the standard, this article only studies the minimization problem. The following describes the specific steps of FOA:
1. Position initialization: there are ps search agents. The moving direction and distance of them are initialized around the best one in population casually. Equation (1) is used to solve the location of each search agent
The position of the ith search agent is represented by Xi and Yi [X_axis, Y_axis] is optimal position of the population. RandomValue is a random search distance.
2. Calculate taste concentration judgment value: initially, the location of food is not known, so we reckon the distance (Disti) between each search agent and origin. Later, we count the taste concentration judgment value Si at each particle’s location. The calculation formula is shown in equations (2) and (3)
3. Calculate taste concentration value: we calculate the taste concentration Smelli of each one by equation (4)
4. Choose the best individual: we choose the best search agent which has the global optimal concentration value bestSmell in the population
5. Fly to food: other individuals in the group will fly to the best individual.
6. Iterative optimization: repeat Steps 1–4 and continuously update the global optimal individual. Other fruit flies always fly to the best individual in each generation.
Through understanding the optimization process of fruit flies, combined with the existing references, the following three shortcomings of FOA can be summarized:
The most significant shortcoming of FOA is that the optimization process of it is blind and random, which makes the algorithm converge too fast and the population diversity is insufficient in the later stage.
According to equations (2) and (3), we see FOA implicitly stipulates optimal solution can only be a positive number. This largely limits the scope of the algorithm.
There is no certain mathematical formula to express the position relationship between the current generation and previous generation. So, the search agent’s location cannot be accurately described.
QUATRE
The position update process in QUATRE is similar to affine transformation in geometric transformation, which uses mathematical equations to linearly transform coordinates from one affine space to another. This process is shown in equation (6)
where X is the coordinate matrix of population, X = [x1, x2, …, xps]T, and G represents the current iteration. For each particle, xi = [xi1, xi2, …, xiD]. D is the dimension. ⊗ is a symbol for component multiplication.
B can be regarded as a mutation matrix, and there are six representation methods, as shown in Table 1. F is an important scale factor and in this article, it is set to 0.7. Xr1,G, Xr2,G, Xr3,G, Xr4,G, and Xr5,G are matrices obtained by randomly transforming row vector of X. Xgbest,G is composed of coordinate vector of the optimal particle position in current generation, as shown in equation (7)
Six strategies for calculating B.
M is a matrix of size ps * D,
However, we need to pay attention to the following situations. If ps < D, we can expand the matrix according to the value of population size. Suppose ps = E * D + i, then the first E * D rows can be divided into E lower triangular matrices, and the remaining i rows correspond to the first i rows of the matrix Mtmp. If ps > D, in the same way, we can expand Mtmp according to the value of D. The process is shown by equation (10)
The proposed QTFOA
Initialization
Like the original FOA, the position is initialized, and other individuals fly around the best search agent with random directions and distances. The position solution is shown in equation (1). At this time, two population position matrices of size ps * D are generated, which are defined as X and Y shown in equations (11) and (12)
We use equations (2) and (3) to calculate the taste concentration judgment value, and we use equation (4) to calculate the taste concentration value. new_X and new_Y are used to retain the position information of the current global optimal individual
Position change
Next, the algorithm enters the core. We change the particle’s position with the affine transformation evolution matrix in QUATRE, and the specific process is as follows:
1. Generate matrices M and
2. In order to strengthen the randomness of the particles, it is preferred to generate mutation matrices Bx and By according to the second mutation strategy in Table 1. Next, we randomly transform the row vectors of X and Y to generate six random matrices. Among them, posrx, posr1, and posr2 are obtained corresponding to X. posry, posr3, and posr4 are obtained corresponding to Y. The two mutation matrices Bx and By serve for the transformation of X and Y, respectively. The generation process is shown in equations (14) and (15)
3. X and Y are updated according to the principle of equation (6), and the update process is shown in equations (16) and (17)
Update the optimal value
We combine the updated X and Y with equations (3) and (4) to calculate the taste concentration value of the location of each search agent.
For each search agent, we compare the current taste concentration value with its previous taste concentration value. And then keep the minimum value bestmorei. The operation process is shown in equation (18)
As shown in equation (19), the minimum value among bestmorei is the contemporary global optimal value gbestvalG
The above is the main process of QTFOA. On one hand, QTFOA retains the inherent exploration and exploitation strategy of FOA. On the other hand, it adds the affine transformation in QUATRE, which helps the particles to change the position coordinates in a large range and effectively reduces the probability of falling into local extremes. The details of this process are described by the pseudo code of Algorithm 1.
Simulation experiment and result analysis
Benchmark functions
We select 22 benchmark functions to conduct experiment to test the optimization effect of QTFOA. Tables 2–5 show the specific details. Among them, f1–f8 are the universal unimodal functions, f9–f10 are the low-dimensional unimodal functions, f11–f17 are the universal multimodal functions, and f18–f22 are the low-dimensional multimodal functions.
Universal unimodal functions.
Low-dimensional unimodal functions.
Universal multimodal functions.
Low-dimensional multimodal functions.
Unimodal function has only one peak. So, it can explore whether the algorithm can find the global optimal value under limited optimization conditions (such as fewer particles). Multimodal function has multiple peaks, which can explore the ability of one algorithm to escape the trap of falling into local optima. This article adds low-dimensional test functions. In low-dimensional situations, algorithm is more likely to converge prematurely, so this can better detect the performance of QTFOA.
Compare with mature algorithms
In this part, we compare QTFOA with FOA, QUATRE, DE, PSO, and GWO. Specifically, we use 30 particles to run these six algorithms on 22 benchmark functions 30 times, and each single function performs 3000 iterations. Finally, we use error average (AVG) to compare optimization results and we use error standard deviation (STD) to evaluate the stability of solution. The win, lose, and draw are used to represent the number of functions that QTFOA is better than, worse than, and equal to corresponding algorithm’s optimized performance, respectively. The running results are shown in Table 6, and in order to highlight the optimal values, we bold them.
Performance comparison of FOA, QUATRE, QTFOA, DE, PSO, and GWO algorithms on 22 functions.
FOA: Fruit Fly Optimization Algorithm; QUATRE: QUasi-Affine TRansformation Evolution; QTFOA: Quasi-affine Transformation evolutionary for the Fruit fly Optimization Algorithm; DE: Differential Evolution; PSO: Particle Swarm Optimization; GWO: Gray Wolf Optimization.
From Table 6, for eight universal unimodal functions f1–f8, the performance advantage of QTFOA is absolute. QTFOA randomly generates the solution in the early stage, and then performs the affine transformation of the particle position coordinates, which greatly improves the position diversity and helps the particles to quickly find the optimal value. But for the two low-dimensional unimodal functions f9 and f10, neither of them can beat all other algorithms. This shows the performance of QTFOA is not very good on low-dimensional unimodal functions.
For the seven universal multimodal functions f11–f17, QTFOA ranks first in six functions of f11, f12, f13, f15, f16, and f17. And the data appear that the result of QTFOA is not only superior than other algorithms but also helps most universal multimodal functions find the theoretical global optimum. What multimodal functions urgently need to solve is the inability to escape the local extremum problem. In response to this, QTFOA introduces the affine transformation mechanism, which helps particles seek the optimal solution toward higher expectations and greater optimization potential.
For the five low-dimensional multimodal functions f18–f22, QTFOA ranks first in three functions of f18, f19, and f20. It can be seen that QTFOA is also excellent in low-dimensional multimodal functions. In short, through the above analysis and the values of win, lose, and draw in Table 6, the overall performance of QTFOA is higher than the other five algorithms.
Analysis of algorithm convergence
Convergence is another indicator for judging the quality of an algorithm. Table 7 shows the number of iterations of these six algorithms to get the optimal value on 22 functions. We set the maximum number of iterations to 500. At the same time, to evaluate experimental results faster, we assume that when the optimal value is less than 10−4, it is roughly considered that the algorithm has converged to 0. If the algorithm does not converge after 500 iterations, 500 is regarded as the number of iterations here. For each function, we bold the data that iterates fastest to the optimal value. That is, the smaller the value, the faster the algorithm iterates on this function.
The number of iterations of six algorithms reaches the global optimal on 22 functions.
FOA: Fruit Fly Optimization Algorithm; QUATRE: QUasi-Affine TRansformation Evolution; QTFOA: Quasi-affine Transformation evolutionary for the Fruit fly Optimization Algorithm; DE: Differential Evolution; PSO: Particle Swarm Optimization; GWO: Gray Wolf Optimization.
Figure 1 reveals the convergence curves of the six algorithms on functions f1, f9, f12, and f19. Four selected examples correspond to the four types of functions proposed, which can help us better analyze the algorithm. Please note that in Figure 1(a), the values of FOA and QTFOA in the whole iteration process are quite different from those of other algorithms. Therefore, Figure 1(b) adds the details of numerical changes of these two algorithms.

The convergence curve of the six algorithms on f1, f9, f12, and f19. (a) Convergence curve of f1-1. (b) Convergence curve of f1-2. (c) Convergence curve of f9. (d) Convergence curve of f12. (e) Convergence curve of f19.
From Table 7 and Figure 1, we can see that for most functions, QTFOA can efficiently converge in the fastest time. Whether the speed of convergence or the quality of the solution, QTFOA has demonstrated strong competitiveness. However, the performance of QTFOA on low-dimensional unimodal functions is not good. For example, it can be seen from the iterative curve of f9 that QTFOA tends to fall into local optimal values.
Significant difference analysis
To detect the difference of experimental results samples, we compare QTFOA with other five algorithms for significant differences test by the Friedman test and the famous Wilcoxon signed-rank test. Tables 8 and 9 respectively show the experimental results. Among them, when the p-value is greater than 0.05, it means that this sample result is not statistically significant.
Friedman’s test of six comparison algorithms.
Wilcoxon’s signed-rank test of six comparison algorithms.
FOA: Fruit Fly Optimization Algorithm; QUATRE: QUasi-Affine TRansformation Evolution; QTFOA: Quasi-affine Transformation evolutionary for the Fruit fly Optimization Algorithm; DE: Differential Evolution; PSO: Particle Swarm Optimization; GWO: Gray Wolf Optimization; N/A: not available.
We bold the data which are greater than 0.05. From the experimental results, we can see only a small amount of data has been annotated. This shows the optimization result of QTFOA is indeed very different from other algorithms significantly.
Comparison of the running time of six algorithms
Time complexity is also one of the indicators for judging the capability of an algorithm, which can roughly characterize its computational efficiency. For each function, we run it 500 times with six algorithms, respectively, and then take the average of the corresponding time as the algorithm’s optimization time for this function. The unit of time is seconds. The experimental result is shown in Table 10, and the shortest time is bolded.
Running time of six comparison algorithms.
FOA: Fruit Fly Optimization Algorithm; QUATRE: QUasi-Affine TRansformation Evolution; QTFOA: Quasi-affine Transformation evolutionary for the Fruit fly Optimization Algorithm; DE: Differential Evolution; PSO: Particle Swarm Optimization; GWO: Gray Wolf Optimization.
From Table 10, it can be seen that QUATRE and PSO have higher operating efficiency, but the QTFOA has a long running time. In QTFOA, the random optimization process and matrix operations increase the computational complexity. So, the calculation efficiency of QTFOA is not high. How to reduce the running time of QTFOA can be a point of future research.
Application of QTFOA in CVRP
Principle of CVRP
The problem can be described as: there is a central warehouse (numbered 0) transporting goods to L shipping points (numbered 1, 2, …, L) through K vehicle. Each shipping point has a different demand gi (i = 1, 2, …, L) for goods and the demand for each shipping point can only be met by one car. The model requires that every shipping point must receive the delivery service of a vehicle. The capacity of each vehicle is qk (k = 1, 2, …, K). For each vehicle, the total cargo volume of its transportation path shall not exceed its own maximum capacity. Now, it is required to find the shortest vehicle travel path.
First, two variables yki and xijk are defined by equations (20) and (21)
Cij is the distance between shipping point i and j. Z is the sum of all vehicle paths and Q represents the maximum capacity of transport vehicles. CVRP is to find minZ and the related formula is shown below
Equations (23) and (24) can ensure that the requirements of each shipping point are met. Equation (25) can ensure that the needs of each shipping point can only be met by one car. For each vehicle, equation (26) can ensure the total cargo volume of whole transportation path shall not exceed its own maximum capacity.
Simulation experiment and result analysis
First, to study whether QTFOA is suitable for solving CVRP, we use a simple example in Table 11 for testing. The serial number 0 represents the central warehouse, and the serial numbers 1–7 represent seven shipping points. Set the number of transport vehicles to 3, and stipulate the capacity of each vehicle cannot exceed 100. Location information and cargo requirements are given in Table 11. The theoretical optimal path value is known to be 217.8. The optimization result of QTFOA is shown in Figure 2.
Coordinates and requirements of each task point.

Optimization results of QTFOA on CVRP.
In the above test case, QTFOA can optimize the path to 221.4 quickly, which is very close to 217.8. This shows that the QTFOA is suitable for CVRP and can achieve good optimization results.
Later, we compare QTFOA with QUATRE, FOA, and SA. Four algorithms are tested on 10 sets of data from the CVRP international standard example VRPLIB. The numerical results of this comparison can be observed in Table 12. Here, in order to ensure fairness, for each algorithm, we run 3000 generations with 150 particles.
Comparison results of four algorithms to solve CVRP.
FOA: Fruit Fly Optimization Algorithm; QUATRE: QUasi-Affine TRansformation Evolution; QTFOA: Quasi-affine Transformation evolutionary for the Fruit fly Optimization Algorithm; SA: Simulated Annealing algorithm.
Table 12 shows that QTFOA can obtain the shortest path on each set of test cases. At the same time, in general, as the number of shipping points and transportation vehicles increases, the advantages of QTFOA become more obvious. This shows that when faced with a complex transportation environment, QTFOA can play a better role. In short, QTFOA has performed very well in solving CVRP.
To further explore the optimization process of QTFOA to CVRP, we have done an analysis of the convergence process of four algorithms. Figure 3 reveals the convergence curves of A-L32-k5 andA-L33-k5. As can be seen from Figure 3, QTFOA can get the highest quality solution, that is, the shortest path. However, from the image, we can see that QTFOA converges very slowly. When solving the situation with large quantities of data, the calculation speed and efficiency must be specially considered. So, this can be an aspect of future research.

Convergence curve of A-L32-k5 (a) and A-L33-k5 (b).
Conclusion
Combining FOA and QUATRE, a new optimization algorithm QTFOA is proposed in this article. To effectively avoid sinking into the local optimum, QTFOA uses affine transformation formula in QUATRE algorithm, which helps the particles to expand the search range greatly. To explore the optimization ability of QTFOA, we select 22 functions of four types for testing, and compare the algorithm with FOA, QUATRE, PSO, DE, and GWO. It is obvious from the above experiment result that the optimization performance of QTFOA is higher than the other five algorithms as a whole. To evaluate the capabilities of QTFOA in multiple aspects more comprehensively, we also design experiments for algorithm convergence analysis, the Friedman test, the Wilcoxon signed-rank test, and running time comparison. Most experiments have proved that QTFOA is excellent in different evaluation indexes. In the end, we apply QTFOA to CVRP. Through 10 sets of cases on VRPLIB, QTFOA is compared with QUATRE, FOA, and SA and the experimental result proves that QTFOA can always find the shortest effective path. But QTFOA still has three obvious shortcomings. First, QTFOA has poor performance on low-dimensional unimodal functions. Second, it has a particularly slow running time. Finally, when solving CVRP, the convergence speed of it is very slow. How to solve these three problems of QTFOA is an improvement direction that can be considered in the future.
Footnotes
Handling Editor: Yanjiao Chen
Declaration of conflicting interests
The author(s) declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.
Funding
The author(s) received no financial support for the research, authorship, and/or publication of this article.
