Optimal measurement area determination algorithm of articulated arm measuring machine based on improved FOA

The determination of the optimal measurement area of the articulated arm measuring machine belongs to the multi-dimensional function optimization problem under complex constraints. To realize high-precision measurement of low-precision articulated arm measuring machine, we analyze the working principle and error source of the measuring machine, and establish the optimization target model of the optimal measurement area in this paper. We propose a method for determining the optimal measurement area of an articulated arm measuring machine based on improved FOA. The basic FOA algorithm is improved, the historical optimal individual and population centroid information are added in the population iteration update process, and the fruit fly individuals in each iteration are directly used as the taste concentration judgment value, which increases cooperation and information sharing among fruit fly individuals, and improves the global optimization ability and stability of the algorithm. In the designated area of the measuring machine, we have carried out comparative experiments on the optimization results of improved FOA and basic FOA, ACO, PSO, AL-SC-FOA, LGMS-FOA, IPGS-FFO. Experimental results show that the improved FOA, ACO, PSO, and IPGS-FFO algorithms do not fall into local optimum, and the optimal measurement area determined by them is consistent with the optimization results of other algorithms, and is superior to other algorithms in convergence speed and stability, so it is more suitable for determining the optimal measurement area of articulated arm measuring machine.


Introduction
The error sources of articulated arm coordinate measuring machine (AACMM) mainly include circular encoder measurement errors with a sinusoidal variation law, structural parameter errors, thermal deformation errors, force deformation errors, motion errors, and data acquisition system errors; in addition, these error sources include probe errors and measurement errors caused by improper measurement methods and measurement environment 1 with complex variation laws given the series mechanical structure of the AACMM, thereby resulting in amplification effect of each joint error; thus, the measurement accuracy of the measuring machine is lower. 2 The object measured can be placed in the optimal measuring zone of the measuring machine to achieve high-precision measurement of the low-precision AACMM; the maximum measurement error in this zone is the minimum. 3 To determine the precise location of the optimal measuring zone for the measuring machine, the variation law of each error component, transfer relation, and comprehensive error distribution law of the measuring machine must be analyzed to find a precise determination location of the optimal measuring zone through an appropriate optimization algorithm.
Domestic and foreign scholars have conducted research on this issue. Qin 4 used optical autocollimator and metal polyhedral prism combination method to measure the circular indexing error of six grating circular encoders of the measuring machine, and matched the six encoders to determine the deviation range of different areas of the measuring machine. The ant colony algorithm was used to solve the optimal measurement area, but the ACO convergence speed was slow and the single optimization time was long. Jiang 5 simulated the distribution law of the maximum measurement error of the articulated arm measuring machine in the measurement space by using the distribution of points and the extended algorithm, and used the particle swarm optimization (PSO) to optimize the error in a certain area. However, the efficiency of the algorithm in solving the optimal measurement area is low and the program running time is long. Zheng 6 selected v-SVM and RBF kernel function to construct the spatial error distribution model of flexible coordinate measuring machine, and obtained the optimal measurement area model aiming at single point measurement and spatial distance measurement by using support vector machine theory. However, this method is not practical, and the model is based on a large number of measured data, and its measurement error does not include the angle measurement error of circular encoder. Hu et al. 7 determined the measurement space according to the structural parameter analysis of AACMM, divided the measurement space of the measuring machine into several small cubic areas at equal intervals, and used the improved ant colony algorithm to find the maximum measurement error of each small area, but the convergence speed of the algorithm was slow and it was easy to fall into local optimum. Given the complex error sources, transmission relationship, and error distribution law of the AACMM, solving the optimal measuring zone for the AACMM can be classified as a high-dimensional optimization problem. Simultaneously, the optimal measurement zone of the measuring machine under various measurement conditions is different and must be determined in real-time under the measurement condition. Therefore, the stability and real-time performance of the determination algorithm of the measuring machine is proposed. This determination algorithm is poor in search speed and real-time performance. There are many popular intelligent algorithms with good optimization results, such as DE (Differential Evolution algorithm), 8 which starts from a random initial population, so it has wide applicability and nonlinearity. However, when the number of individuals in the population is small, the fitness value of the newly generated population is poor and it is difficult to converge to the extreme point, and the accuracy of determining the best measurement area needs to be further improved.
Fruit fly optimization algorithm (FOA), proposed by Taiwan scholar Pan 9 in 2011, is a global optimization algorithm based on simulating the foraging behavior of Drosophila. Compared with other algorithms, it has the advantages of less control parameters, simple principle, fast search speed and good real-time performance. 10,11 It has been successfully applied to solve many practical problems. For example, Wang et al. 12 applied the improved FOA algorithm to China's industry. An improved fruit fly optimization algorithm (FOA) considers the time delay effect of input variables, which is helpful to select input variables. Wang et al. 13 predicted the remaining service life of lithium-ion batteries based on fractional brownian motion and fruit fly optimization algorithm, and optimized the Hurst index H in the brownian motion FBM model by FOA. Peng et al. 14 applied FOA algorithm to the determination of LSTM super parameters for long and short memory to solve the problems of handwriting recognition and time series prediction, and verified the effectiveness of FOA-LSTM model through experiments. However, the FOA also has some shortcomings, such as random blindness in search, slow convergence rate in subsequent period, low convergence accuracy, easy to fall into local optimization, and unsuitable for optimization problems with negative values in the domain of independent variables 15,16 ; the expected effect is difficult to achieve, especially when solving complex problems, such as multi-peak, high-dimensional, and large-scale issues; therefore, solving the optimal measurement zone of the measuring machine is a complex high-dimensional optimization problem. To apply the FOA with fast search speed and good real-time performance to the real-time determination of the optimal measurement area of the measuring machine, an improved FOA is proposed to enhance its global optimization ability and algorithm stability, and the optimization results of different algorithms are compared and verified.
The remainder of this paper is organized as follows. Section ''Related works'' describes the related works, including introduce the optimization model of the optimal measuring area of the measuring machine and the improved FOA optimization algorithm. Section ''Experiments and analysis'' reports the implementation details, the experimental results. At the end of the paper, we conclude the proposed algorithm.

Model building
Working principle of the AACMM. The structure of the AACMM is illustrated in Figure 1. This structure consists of three flexible measuring arms, six movable joints, and one measuring head. The joints of the mechanical arms are equipped with circular encoder angle sensors. In accordance with the angle value of each joint and the length of the measuring arm, a computer calculates the 3D coordinates of the measured points using the measurement model expressed in equation (1), which is established through the D-H method. 17 where l i is the shortest distance between the axes of the two joint shafts, u i is the output of each joint circle encoder, d i is the joint offset amount (the distance intercepted by the adjacent rod long line on the joint), a i is the adjacent joint axis relative torsion angle, and l is the length of the measuring head of the measuring machine.
The structural parameters l i , d i , a i , l of a certain type of the AACMM are calibrated through parameter identification before delivery. These parameters are constant values (the measuring machine parameters studied in this work are listed in Table 1).
Error analysis of the AACMM Error analysis of the AACMM. In this work, simplifying the algorithm model only considers the influence of the main error sources (circular encoder angular measurement error with progressive error amplification effect) on the measuring accuracy of the AACMM. The error fitting models of six circular coders measured by a certain type of the AACMM are expressed in equation (2), We use the method of combining autocollimator with metal polyhedral prism to measure the error of circular encoder, establish the eccentric error model of circular encoder, then fit the error curve by using the thirdorder Fourier series, and calculate the undetermined coefficient by using the least square method, and finally get the error characteristic curves of six circular encoders, as shown in Figure 2, all of which are sinusoidallike curves with a period of 2p, with different error amplitudes. The model parameters are shown in Table 2, and the relevant model parameter data refer to Jiang. 5 e i (u i ) = a i + b i cos (u i ) + c i sin (u i ) + d i cos 2(u i ) + e i sin (2u i ) + f i cos (3u i ) where i = 1, 2, 3, 4, 5, 6: Ã l sin (u 6 + e 6 (u 6 )) sin a 6 + l 6 cos (u 6 + e 6 (u 6 )) Àl cos (u 6 + e 6 (u 6 )) sin a 6 + l 6 sin (u 6 + e 6 (u 6 )) l cos a 6 + d 6 1   The rotation angle of each encoder can be expressed as u i + e i (u i ), which is substituted into equation (1), and the calculation result of the 3D coordinates for the measured point, including the joint rotation angle error, is expressed in equation (3). The subtraction of the calculation results of equation (3) and equation (1) obtains a 3D coordinate measurement error of the measuring machine, as presented in equation (4).
For measuring the same point, measuing errors will be different with various measuring attitudes. Given that the AACMM can measure the point at any point in the space with numerous measuring attitudes (corresponding to different circular encoder angles and errors), the 3D space coordinate error of the measurement point exhibits a ''fruit-like'' distribution law and has a certain continuity. Thus, an optimal measurement zone with the maximum error being the minimum exists.
Algorithm model of the optimum measuring area for the AACMM. In accordance with the measurement model equation (1) and equation (4) of the AACMM, the optimal target algorithm model of the maximum measurement error of the points in each partition can be determined as: where x k min , x k max correspond to the upp-er and lower bounds of the x-axis in the opt-imization region; y k min , y k max are the upper a-nd lower bounds of the yaxis in the optimi-zation region, respectively; and z k min , z k max a-re the upper and lower bounds of the zaxis in the optimization region, correspondingly. A minus sign is added before d(u 1 , u 2 , u 3 , u 4 , u 5 , u 6 ), which are then converted to calculate the minimum value. The converted form is: Clearly, equation (6) is a constrained optimization problem. The most common method for handling constraints is the penalty function. 18 In this work, the constraints are treated using an external penalty function, which is transformed into the external penalty function and then added to the objective function. The feasible field is x À x kmin 50, x kmax À x50, y À y kmin 50, y kmax À y50, z À z kmin 50, z kmax À z50 The penalty function is: The target augmented function is  P(u 1 , u 2 , u 3 , u 4 , u 5 , u 6 , s) where s is the penalty factor and takes a large positive number, andP(u 1 , u 2 , u 3 , u 4 , u 5 , u 6 ) is a penalty function. When the combination of six encoder angles of the measuring machine is substituted into the measuring model, the calculated coordinate is located in the area to be optimized, andP(u 1 , u 2 , u 3 , u 4 , u 5 , u 6 ) = 0; when the calculated coordinate is not inthe area to be optimized,P(u 1 , u 2 , u 3 , u 4 , u 5 , u 6 ) . 0, and the objective function is punished extra. A large s indicates a heavy punishment. Then, the optimization model for solving the maximum error of measuring points in each partition of the measuring machine can be rewritten as follows: Apparently, equation (10) expresses the optimization problem of complex high-dimensional functions for solving the minimum value without specific requirements for solving this problem. In this function, six independent variables (six circular encoders) are presented in equation (10). Thus, the optimization algorithm adopted must be suitable for multi-dimensional function optimization and must have an improved multidimensional variable coding scheme. Given that the algorithm for determining the optimal measurement zone of the AACMM must be embedded in the DSP subsequently, this algorithm is used to determine the optimal measurement zone of the AACMM for different measurement objects, strategies, and environments in real-time. This real-time requirement of the optimization algorithm is proposed. The six variables in equation (10) have a large range of values, and the whole range of values has positive and negative values. The candidate solution of the optimization algorithm must cover the entire domain as much as possible and coordinate the global and local optimization.
The basic FOA has the advantages of minimal control parameters, simple principle, fast search speed, and favorable real-time performance. Thus, it can be used to solve the real-time problem of the optimal measurement zone of the AACMM. However, the basic FOA is unsuitable for solving the minimum value of equation (10). Therefore, the basic FOA must be improved to make this algorithm suitable for solving this question.
Optimization algorithm Basic FOA. Fruit fly optimization algorithm (FOA) is a swarm intelligence optimization algorithm based on drosophila foraging behavior evolution. Drosophila has a keen olfactory system, which can search for food sources far away, and then find the location of food and other flies through the visual system, and fly to them. 19 The drosophila foraging behavior is applied to the field of intelligent optimization algorithm, and the fruit fly optimization algorithm is formed. The optimal solution of the specific problem is finally found through the communication between individual foraging information and group foraging information. In accordance with this characteristic of the fruit fly population, the basic steps of the FOA are presented as follows: (1) Initialize the population location, and set the population size (Sizepop) and the maximum number of iterations (maxgen).
(2) Fruit fly individuals search for food through random directions and distances.
(3) Estimate the distance (Dist) between the fruit fly and the origin, and then calculate the taste concentration judgment value S, which is the reciprocal of Dist.
(4) Substitute the taste concentration det-ermination value (S) into the taste concentrat-ion determination function to determine the t-aste concentration (Smell(i)) of the current p-osition of the fruit fly.
(5) Find the location of the fruit flies with the lowest taste concentration (bestindex) and minimum taste concentration (bestSmell) in the fruit fly population (in the case of minimum value).
(6) Preserve the optimal taste concentration value and x, y coordinates, at which time the fruit flies use the visual organ to fly to the position.
Improve FOA. To make the FOA suitable for solving the optimal measurement zone of the AACMM, the present work combines ACFOA (The algorithm determines whether FOA is in local convergence state by the value of population fitness variance. If so, chaotic algorithm is used for global optimization, so as to jump out of local extremum and improve the convergence accuracy and convergence speed of FOA.) and LGMS-FOA 20 (In LGMS, a parameter called inertia weight is introduced to balance global search and local search. LGMS-FOA tends to have more global search ability at the beginning of operation and more local search ability at the end of operation) to make the following improvements to the basic FOA are as follows 21,22 : (1) A reasonable multi-dimensional variable coding scheme is designed. (2) The basic FOA only uses the optimal individual information of the current population in the iterative optimization, and the local optimal solution is easily reached. To solve this problem, the information of historical optimal individuals and population centroid is added to increase cooperation and information sharing among fruit fly individuals, thus improving the accuracy and robustness of the algorithm.

(3) The taste concentration determination value S(i)
is the reciprocal of Dist(i). Generally, the value of Dist will be large, and thus the range of the S(i) value will be very small. When it is substituted for the taste concentration determination function (the objective function of the optimal measuring area of the AACMM), it will probably cause premature convergence and reach the local optimal solution. Furthermore, the basic FOA cannot solve the function optimization problem with negative numbers in the definition domain given the S(i)50 of the basic FOA, while the angle range of the six circular encoders in the target model of the optimal measurement area of the joint arm measuring machine has negative values. To solve this problem, the individual of each iteration is directly considered the judgment value S(i) of flavor concentration. Thus, the candidate solution can cover the whole function definition domain as far as possible, thus improving its global optimization ability and algorithm stability.
The improved FOA is used to solve the optimal measurement zone of the AACMM. The specific steps of the algorithm are presented as follows: (1) Initialize the location of the fruit fly population (X axis), and set the population size (Sizepop), the maximum number of iterations maxgen, the learning coefficients C1 and C2, popmin1, popmax1 and popmin2, and popmax2 (angular range of motion of the circular encoder).
X axis = u i min + (u i max À u i min ) Ã rand(), (i = 1, 2, 3, 4, 5, 6) ð22Þ  (2) Provide the fruit fly individuals the random direction and distance to search for food using the sense of smell.
X(i) = X axis + cons tan t Ã (2 Ã rand(1, 6) À 1) ð23Þ (3) Substitut X(i) for the taste concentration determination value S(i), and execute Steps (4)-(5) in section ''Error analysis of the AACMM.'' (4) Record the optimal taste concentration value of fruit fly individuals (bestSmell) in the current population, and retain the historical optimal fitness value and position information of everyone in P and PX, respectively. (5) Calculate the population center of mass using equations (24)-(27), and assign the value to C g X.
where P g X is the optimal individual position of the population history?   Figure 4 shows the algorithm flow chart of the improved FOA optimization algorithm.

Experiments and analysis
Algorithm test for solving the optimal measurement zone Space À100mm4X4100mm, À100mm4Y4100mm, a-nd À100mm4Z4100mm of the AACMM is divided into 1000 small cubic spaces with 20 mm interval of 3D coordinates, and the minimum of equation (10) in each small cubic space (i.e. the maximum measurement error of each small 3D space) is solved. In comparison with the maximum measurement error of each small 3D space, the 3D space with the smallest measurement error is the optimal measurement area of the AACMM in the specified measurement space.
To test the performance of the algorithm, the PSO algorithm, LGMS-FOA, ACO algorithm, and improved FOA are used to solve the maximum measurement error determined by the objective function of equation (10) in the small 3D space 80mm4X4100mm, À 100mm4Y4 À 80mm, and À40mm4Z4 À 20mm in the specified measurement space of the measuring machine. These algorithms are implemented in MATLAB R2016b and run on a PC with Intel(R) Xeon(R) E31270 and CPU@3.40 GHz with 16 GB RAM.
In order to compare the influence of the maximum and minimum particle velocity parameters on PSO algorithm performance, V max = 0:5, 1:5, 2:5, 3:5, V min =À 0:5, À 1:5, À 2:5, À 3:5 are used to solve the maximum measurement error determined by the objective function of formula (10), and other parameters are set as: particle size Sizepop = 100, maximum iteration number Maxgen = 1000, penalty factor s = 1000 the algorithm optimization result is shown in Figure 5. The analysis shows that the convergence speed of the algorithm is the fastest when the speed value is V max = 3:5, V min =À 3:5. Therefore, the parameters of PSO algorithm are set as follows: Particle size Sizepop = 100, maximum iteration number Maxgen = 1000, maximum and minimum velocities V max = 3:5, V min =À 3:5, penalty factor s = 1000, inertia weight selection equation (31), acceleration factor 23 c1 = c2 = 1:49445 (according to Liu et al. 23 , and the comparison of the algorithm optimization effect of multiple groups of acceleration factor values, the value is finally obtained), and v s = 0:9, v e = 0:4. 24 v(k) = v s À (v s À v e )(k=T max ) 2 ð31Þ Figure 5. PSO algorithm optimization results at different particle velocities.
Similarly, after several parameter adjustment and analysis, the optimal parameter settings of each algorithm are obtained as follows: The LGMS-FOA parameters: population size Sizepop = 100, maximum iteration number Maxgen = 1000, search coefficient n = 0:005, penalty factor s = 1000, initial weight v o = 1, and weight adjustment coefficient a = 0:95.
In accordance with the algorithm parameters set above, the PSO algorithm, LGMS-FOA, ACO algorithm, and improved FOA are run 100 times. The single optimization results of the four algorithms are depicted in Figure 6, and the test results are compared, as summarized in Table 4.
To test the performance of the improved FOA further, the basic FOA, LGMS-FOA, IPGS-FFO algorithm, AL-SC-FOA, and improved FOA are used to solve the maximum measurement error determined by the objective function of equation (10) in the small 3D space 80mm4X4100mm, À100mm4Y4 À 80mm, and À40mm4Z4 À 20mm in the specified Table 3. Parameter setting of four algorithms.
The parameters of the IPGS-FFO algorithm are set as follows: population size Sizepop = 20, 50, 80, 100; maximum iteration number Maxgen = 1000; penalty factor s = 1000; and other algorithm parameters presented in Literature. 25 The parameters of the AL-SC-FOA are set as follows: population size Sizepop = 20, 50, 80, 100; maximum iteration number Maxgen = 1000; penalty factor s = 1000; and other algorithm parameters mentioned in Literature. 26 The The test and optimization results of the five algorithms are displayed in Table 6 and Figure 7 respectively. The specific parameter settings are shown in Table 5.
To verify the feasibility of the improved FOA further, the improved FOA algorithm and PSO algorithm which has successfully solved the optimal measurement area in AACMM in the early stage of the project team are adopted. These algorithms are applied to solve the minimum value using equation (10) (maximum measurement error of each small 3D space of 1000 small stereo spaces that are divided in section ''Algorithm test for solving the optimal measurement zone''). Then, the optimization results of the two algorithms are compared. The parameters of the PSO algorithm are set as follows: particle size Sizepop = 100, maximum iteration number Maxgen = 1000, maximum and minimum velocities V max = 3:5, V min =À 3:5, penalty factor s = 1000, inertia weight selection (equation (31)), acceleration factor c1 = c2 = 1:49445, and w s = 0:9, w e = 0:4 To compare the maximum measurement errors of each small stereo space, some data with large and small measurement errors are selected, and the obtained fitness value is retained using two significant figures ( Table 7).

Analysis of experimental results
After testing and analyzing various algorithms for solving the optimal measurement area of AACMM measuring machine in section ''Algorithm test for solving the optimal measurement zone,'' we can get the following analysis results.
Taking the small measuring space area 80mm4X4100mm À100mm4Y4 À 80mm, À40mm4Z4 À 20mm of the measuring machine as an example, as shown in Figure 6 and Table 4, when PSO algorithm, LGMS-FOA algorithm, ACO algorithm and improved FOA are used to determine the optimal measuring area of measuring machine, we can know that, (1) the LGMS-FOA reaches the local optimal solution, and the optimal value is 20.063 mm. The PSO algorithm, ACO algorithm, and improved FOA do not reach the local optimal solution, and the optimal value (i.e. the maximum measurement error in the small stereo space) is 20.11 mm. Therefore, the maximum measurement error of Measurement and Control 53(9-10)  by the three algorithms without falling into the local optimal solution running 100 times independently indicate that the accuracy and stability of the improved FOA are superior to the ACO and PSO algorithms.
As can be seen from Figure 7 and Table 6: operation that is run 100 times is less than the IPGS-FFO, which shows that the stability is better in the improved FOA than in the IPGS-FFO. (5) The comparison of the basic FOA and the improved FOA implies that the performance of the basic FOA can be effectively enhanced through the method proposed in this work.
In the measuring space À100mm4X4100mm, À100mm4Y4100mm, À100mm4Z4100mm of the measuring machine, the larger and smaller measuring error areas and the corresponding measurement errors are obtained by using different algorithms, as shown in Table 7. The results show that the improved FOA algorithm and PSO algorithm can solve the error distribution of the articulated arm coordinate measuring machine, and the optimal measurement area in the measurement space is 0mm4X420mm, À20mm4 Y40mm, 0mm4Z420mm, the maximum measurement error of this area is 0.056 mm. Compared with the maximum measurement error of 0.11 mm, the accuracy is improved by 50.9%. Therefore, the feasibility and effectiveness of the improved FOA algorithm to determine the optimal measurement area of the articulated arm measuring machine is proved again.