Improved fruit fly algorithm on structural optimization

To improve the efficiency of the structural optimization design in truss calculation, an improved fruit fly optimization algorithm was proposed for truss structure optimization. The fruit fly optimization algorithm was a novel swarm intelligence algorithm. In the standard fruit fly optimization algorithm, it is difficult to solve the high-dimensional nonlinear optimization problem and easy to fall into the local optimum. To overcome the shortcomings of the basic fruit fly optimization algorithm, the immune algorithm self–non-self antigen recognition mechanism and the immune system learn–memory–forgetting knowledge processing mechanism were employed. The improved algorithm was introduced to the structural optimization. Optimization results and comparison with other algorithms show that the stability of improved fruit fly optimization algorithm is apparently improved and the efficiency is obviously remarkable. This study provides a more effective solution to structural optimization problems.


Introduction
With the rapid development of computer technology, the efficiency of structural optimization is greatly improved, and structural designers can have more time and energy to consider how to get better structural design scheme. In 1974, Schimit and Farshi proposed to combine finite element theory with mathematical induction theory to solve the optimal weight problem of engineering structure. Structural optimization has stepped into a new era [1]. After that, the intelligent optimization algorithm is also widely applied to the structural optimization, and the modern structural optimization method is gradually applied to the engineering practice. Now, after years of research and development, structural optimization has changed from the original optimization of structure size to the present optimization of topology and further optimization of material distribution. From a single objective optimization problem, multiple objectives are optimized simultaneously. Azamirad and Arezoo [2] proposed an improved software package for stamping die structure that can greatly reduce the weight. Ide [3] designed the lightweight structure with the structural optimization method, and successfully realized the lightweight gear box design by using the design method of reducing contact constraint stress. Kaveh [4] proposed water evaporation optimization algorithm (WEO), which is a population-based intelligent optimization algorithm inspired by physics and used for continuous structural optimization. In order to apply different optimization solvers to various finite-based structural topology optimization problems Rojas-Laband [5], developed a widely representative example library of mechanism design problems with minimum compliance, minimum volume and different sizes. Sivapuram [6] discussed various calculus methods and numerical methods commonly used to solve structural topology optimization problems.
Inspired by the foraging process of fruit flies, scholar Pan [7] proposed a more efficient swarm intelligence optimization algorithm in 2012: fruit fly optimization algorithm (FOA). The algorithm has the advantages of clear principle, fewer parameters and simple operation. However, there are also some shortcomings, such as weak ability to solve complex, high-dimensional and nonlinear optimization problems and easy to fall into local extremum. In view of the above typical problems, many scholars have proposed many improvements. As for the generation of candidate solutions [8], added an escape parameter that can be negative to the taste concentration judgment value, so that the candidate solution can take a negative value. A novel double strategy evolutionary fruit fly optimization algorithm (DSE-FOA) was proposed by Fang [9]. DSEFOA dynamically divided the fruit fly population into spermatogonium subgroups and ordinary subgroups, and adopted different strategies to update the evolution of drosophila at different levels of evolution, which improved the optimization ability of the whole population. In terms of search radius, Sang et al. [10] introduced adaptive parameters to adjust the search radius of drosophila so as to better balance the global search capability and local search capability. Cao [11] proposed to replace the traditional search mechanism with sector search mechanism, and the new fruit fly algorithm was generated to effectively improve the stability of the algorithm. In terms of flight strategy [12][13][14], added the operation of group collaboration and random perturbation to solve the problem of premature development of the algorithm. Sheng [15] proposed that the length of fruit fly search for Uber should be dynamically changed according to the change rate of concentration difference, which can effectively balance the global optimization ability and the local optimization ability. In terms of population diversity [16], divided the drosophila population into multiple subpopulations of the same size. Han [17] et al. proposed a dynamic twin group coevolutionary FOA to improve the search accuracy. Xin [18] used the gaussian sampling method to update the fruit fly. This method can increase the chance of jumping out of the local extremum in the early stage of the algorithm and conduct more accurate search in the later stage.
Aiming at improving the performance of the standard fruit fly optimization algorithm, the hybrid algorithm was designed to combine with fusion immune response. Immune algorithm was fully utilized to improve the deficiency of fruit fly algorithm that is prone to fall into local extreme value in the later stage. In other words, when the number of evolutionary stasis steps t is greater than the threshold value of evolutionary stasis steps T, immune operation is performed to overcome the defect of basic fruit fly algorithm. The improved algorithm was proved to have better robustness and intelligence through standard functions and tests for solving 0-1 knapsack problems [19][20][21]. Finally, it was applied to the optimization of truss structure [22] and compared with other algorithms to verify the feasibility of the improvements.

Basic fruit fly algorithm
FOA (fruit fly optimization algorithm) is a new heuristic algorithm that simulates the foraging activities of fruit flies in nature to seek the optimal solution of the objective function. The foraging iteration diagram of fruit flies is shown in Fig. 1.
The basic steps are as follows [23][24][25][26]: Step 1: initialize parameters. Set Sizepop and Maxgen of the population size, and initialize the population position: Step 2: fruit fly searches in the olfactory system, which can make the search direction and the search step randomly. Random value (RV) is to be the search distance, and the position of the population is updated simultaneously: Step 3: since the exact location of the food is unknown, it is necessary to calculate the distance ( Dist i ) between the fruit flies and the origin of the coordinate and then calculate the taste concentration parameter ( S i ): (1) X _axis , Y _axis .
(2) Step 4: substitute the fruit fly flavor concentration determination value (S i ) into the taste concentration decision function, the fitness function, then we will obtain the individual taste concentration of the fruit flies Smell i .
Step 5: identify the individual with the highest flavor concentration in the drosophila population.
Step 6: retain the best flavor concentration value and coordinate, and other individuals in the population fly to this position: Step 7: termination condition, judge whether the concentration of the best position is better than that of the previous generation, and reach the maximum number of iterations; otherwise, skip step 2 to enter the iterative optimization.

Improved fruit fly algorithm with immune response
Since fruit fly has a relatively developed olfactory and visual system, it first carries out a wide range of search through the sense of smell and sends out food odor information to the surrounding drosophila in the process of foraging. When a fly is found to have a higher concentration by comparison, the individual flies will rely on visual function to fly to that location [27,28]. It is precisely because of such population characteristics that the diversity of the population is reduced, the algorithm that simulates its characteristics, like other bionic intelligent algorithms, has the defect that it is easy to fall into local optimization, which leads to the problem of early maturity [29]. The immune algorithm was inspired by somatic cell theory and network theory [30]. And it can realize the function of self-regulation by generating different antibodies similar to the immune system [31]. This algorithm has strong local search ability. By using this, we can introduce it into the later stage of fruit fly algorithm execution to improve the basic fruit fly algorithm. The new algorithm IAFOA can be used to balance the deficiency of fruit fly algorithm that is prone to fall into local optimal, and improve the search efficiency.

Immune algorithm
Immune algorithm (IA) is a kind of bionic optimization algorithm. In 1990, Bersini [32] first used immune algorithm to solve problems. By simulating biological immune system identify antigen (objective function), simulation of the principle of the memory in the immune system, combination of antigen and antibody (optimization) solution, and diversity of imitation immune system, IA algorithm can realize the antigen recognition, cell differentiation, and memory of the immune system and selfregulating function [2,33,34]. The basic steps of IA are as follows: Step 1: antigen recognition. Input objective function and constraint conditions as antigen of immune algorithm; Step 2: generate the initial antibody. Generate initial antibodies randomly within the solution space; Step 3: calculate the compatibility (fitness evaluation). According to the given fitness evaluation function, the affinities between antibodies and antigens and between antibodies and antibodies were determined. The compatibility between antigen and antibody A v is defined as follows: where O Pt v represents the matching degree of antigen and antibody, and the value of A v is between 0 and 1.
indicating that the antibody matches the antigen very well, that is, the antibody is the optimal solution.
Step 4: update memory units. The antibody with the highest affinity to antigen calculated in step 3 was added into the memory unit and replaced by the original antibody.
Step 5: promote and inhibit node production. Calculate the expected value E xi of antibody i, the low expected value of antibody will be suppressed.
where A i is the affinity between antigen and antibody i, and C i is the number of antibody i; Step 6: generate new antibodies. The father generation produces the next generation antibody through heredity, mutation and crossover.
Step 7: whether termination conditions are met. Yes, stop the algorithm; No, skip to step 3.

Population diversity improvement of IAFOA
The immune system is the basic defense system to maintain the normal metabolism of living organisms by blocking the [27]. The system recognizes gene types to produce different antibodies, promotes the emergence of new individuals and inhibits the excessive production of individuals through regulatory mechanisms, so as to achieve biological diversity [4]. Suppose the immune system has N antibodies, and each antibody has M genes, as shown in Fig. 2. The information entropy H j (N ) of the j gene is: If all the alleles of the antibody are the same at position j, then H j (N ) is equal to 0. Therefore, the average information entropy H (N ) of the system is as follows:

The implementation of IAFOA
Based on the standard fruit fly algorithm, FOA algorithm was first used to construct the feasible solution set. Then, the number of evolutionary stasis steps t was used as the trigger condition [35]. When t > T (threshold of evolutionary stasis steps), the IA search process was invoked, and the process of immune factors in the immune algorithm (corresponding to individual drosophila) seeking antigens (corresponding to food source in the drosophila algorithm) producing antibodies (optimal solution) was used to expand the search space. The elite retention strategy was carried out in the feasible solution set obtained after IA search. And the obtained optimization solution was used together with the original feasible solution set to update the concentration of odor information in the search space, so as to guide other fruit fly's path search mechanism.
The threshold value of evolutionary stagnation step T is the index to enter the IA algorithm. The premature introduction of IA algorithm is not conducive to the search ability of IA, or even the convergence of feasible solutions. Through multiple independent experiments, T = 6 was adopted as the trigger value for entering IA algorithm.
If the trigger condition is satisfied, a fixed immune factor redistribution probability P * was employed to the optimization of space. And the different individuals were given different adaptive immune probability P(i) according to their fitness values: where in order to avoid the algorithm falling into the local optimal solution, the initial probability of immune factor in IA algorithm was given P * = 0.25 to randomly allocate it and increase the diversity of solutions.
The process of IAFOA is as follows: Step 1: initialize parameters. Set Sizepop and Maxgen of population size, initialize population positions X _axis and Y _axis , and the number of evolutionary stagnation steps t = 0; Step 2: randomly generate fruit fly population according to Eq. (3); Step 3: use Eqs. (4)-(7) to operate the population; Step 4: record and retain the best flavor concentration value according to Eq. (14), and update the evolutionary iteration step number t; Step 5: judge whether t < T is true, if directly go to step 7; otherwise, according to Eq. (13), the adaptive immunity probability of individual fruit fly was calculated, and the immune operation was carried out according to the immune algorithm. For individuals who did not perform the immune operation, step 7 was taken.
Step 6: repeat steps 2-4 for iterative search of the new population obtained by immunization; Step 7: set gen = gen + 1; if gen < Maxgen, go to step 2; otherwise terminate the iteration.
IAFOA flowchart is shown in Fig. 3. Fig. 2 Information entropy of genes

Simulation results
In order to verify the effectiveness of the improved algorithm, four standard test functions [5,36] were selected for numerical simulation test to test the performance of IAFOA algorithm. In addition, 0-1 knapsack problem was selected for simulation experiment [37], and the results are compared with other algorithms. Initialization parameters: population size Sizepop = 200, max iteration number Maxgen = 1000, dimension D = 30, P* = 0.25, T = 6.

Standard function test
The first standard function: Rosenbrock function: The second standard function: Ackley function: The third standard function: Cross-in-tray function: (16) (1). (17) The fourth standard function: Levy function: Figures 4,5,6,and 7 show the graphs of the four functions, where Rosenbrock function is a single peak function, which is mainly used to test the convergence performance of the improved algorithm in the process of operation. Both Ackley function and Cross-in-tray function are complex multi-peak functions, which tend to make the algorithm fall into local optimization, so that the real optimal value cannot be obtained, which is used to test the ability of the improved algorithm to deal with falling into "premature". The Levy function has a complex spatial property and is used to test the computational accuracy, convergence stability and time complexity of (18) (ω i − 1) 2 1 + 10sin 2 (πω i + 1) for all i = 1, 2, . . . , d.   Table 1. Four different standard functions were used to test the convergence performance, operation efficiency, handling of "local optimal" and "premature" problems, and the optimal value and average value in the optimization test. The standard deviation reflects the robustness of the algorithm. The running time reflects the convergence speed and accuracy of the algorithm. It can be seen from the calculation results in Table 2 that the fusion immune response hybrid fruit fly algorithm performs better than the standard fruit fly algorithm in different standard functions. The improved algorithm is feasible and effective.
In order to more intuitively see the effectiveness of improved algorithm performance, Fig. 8 shows immune algorithm (IA), particle swarm optimization (PSO), standard fly optimization algorithm. FOA) and fruit fly optimization algorithm based on immune algorithm (IAFOA) under the above four standard functions. The average value of multiple runs was used as the final result to avoid accidental errors.
It can be seen from the iterative curve of Fig. 5 that the algorithm can search the local optimal solution, in addition it reflects high convergence speed and convergence accuracy, especially at the initial stage of iterative algorithm. Take (a) in Fig. 5 as an example, when the algorithm runs about 78 times, it can jump out of the local optimal solution. When the number of iterations is about

Solve the TSP problem
Traveling salesman problem (TSP) is a classical combinatorial optimization problem, which is a typical NP hard problem. It has important research value in the field of logistics distribution and vehicle route planning. The TSP problem can be described as: we know the coordinate position of N cities or the distance between two cities. A salesman needs to go to N cities to sell goods. To start from one city, salesman must pass through other cities only once, and then return to the starting city. Finding out the shortest path for saleman. The mathematical model is as follows.
If S = (P 1 , P 2 , . . . , P N ) can satisfy the minimum value of f (S) , then access order S is the optimal solution of TSP problem under the condition of N cities, that is, the optimal path [38].
where P i is the city code, i ∈ (1, 2, . . . , N ) ; d P i , P j is the distance between city P i and city P j . If only the city coordinates are known, then: where X i − X j is the coordinate position of P i ;d P i , P j = d P j , P i .
In order to verify the performance of the IFOA in solving the TSP problem, this paper selected Oliver30, Att48 and Eil51 standard examples from the international TSP database (The Library of TSP, TSPLIB) for parameter testing. The result is shown in Table 2.
The above analysis results show that IAFOA can not only effectively solve the TSP problem, but also has a higher robustness than other algorithms.

The optimization model
The optimization model problem of truss with sectional area as the design variable is described as follows [6]: where g i (x) is the constraint function; m is the number of constraints.

The objective function
where W (A) is the weight of the structure; A i and L i are, respectively, the cross-sectional area and length of the ith root. ρ is the density of the material; n is the number of design variables.

The constraint
Each member of the structure shall meet the requirements of strength, stiffness, stability and section size: where σ i is the normal stress of the ith root element.
[σ ] is the allowable stress of the material. µ j represents the displacement of node j; allowable displacement of µ max node j; A min and A max are the upper and lower limits of the member section, respectively.

Example 1
The 25-bar truss structure model [39] is established as shown in Fig. 9 and Table 3 The results are shown in Table 4 and Fig. 10. Under the same constraint conditions, IAFOA was used to optimize the 25-bar truss structure, and the total mass of the optimized structure was 206.591 kg.
is superior to the other three optimization algorithms. It is proved that IAFOA is stable in the face of complex optimization problems in the optimization process, and    it is not easy to fall into the local optimal solution. Thus, IAFOA is effective.

Example 2
The 72-bar truss structure model [39] is established as shown in Fig. 11. 72 bars are divided into 16 groups, and the grouping condition is shown in Table 5. Material density is ρ = 2.678 × 10 3 kg/m 3 , elastic modulus is E = 6.895 × 10 4 MPa , and the maximum displacement of each bar in all directions cannot exceed 6.35 mm, and maximum allowable stress is [− 172.375, 172.375], and the optimized results are shown in Table 6.
The results are shown in Table 7 and Fig. 12

Example 3
The 200-bar truss structure model [39] is established as shown in Fig. 13. 200 bars are divided into 29 groups, and it is relatively high-dimensional optimization problem. The grouping condition is shown in Table 7. Material density is ρ = 7.86 × 10 3 kg/m 3 , elastic modulus is E = 2.1 × 10 11 N/m 2 . The minimum permitted cross-sectional area for the truss members is taken as 0.1 cm 2 , a non-structural mass of 100 kg is attached for all free nodes.
The results are shown in Table 8 and Fig. 14

Conclusion
With the development of civil engineering, the structural optimization is more and more important. To find a new method for the truss structure optimization, an improved FOA was proposed. To overcome the shortage of the basic FOA, the IA was introduced into FOA, and a new IAFOA algorithm was proposed. Combining the global search capability of the original standard FOA algorithm and the strong local search capability of IA algorithm itself, the IAFOA achieves  good results in numerical simulation with high ability of solving optimization problems. Although these improvements can overcome some shortcomings of the algorithm, it lacks the adjustment of parameter stagnation step number wide value T and fixed probability P * . In the future, more detailed improvements are needed to make IAFOA algorithm converge faster and more accurately. In addition, the example in this paper is relatively simple, and the application of the algorithm in the optimization of complex structures needs to be further studied.