## 4 Dynamic Tolerance Allocation Based on As-Built Data
### Optimal Tolerance Allocation Based on GA and As-Built Data  
The GA is used to optimize the tolerance allocation, which takes the as-built data as the input. The flow of GA optimizing tolerance is shown in Figure 12, which contains four modules: the initialization, fitness evaluation, genetic evolution, and tolerances update. Initialization: The dimension chains are generated according to the LSDM's structure, and the tolerance schemes are allocated to each process link of the assembly process dimension chain using the Monte Carlo method according to the service-positioning accuracy and error propagation model. The feature information of each tolerance allocation scheme is extracted and coded to form the initial population. Fitness evaluation: By calculating each chromosome's fitness, the superior individuals are filtered out from the population and the iteration is terminated according to the termination conditions. Genetic evolution: The selection of, crossover of, and variation in each chromosome in the population are carried out to inherit and produce more individuals conforming to the fitness function and to realize the positive evolution of the population. The genes on the chromosome are divided into two categories in the proposed method. They are genes encoded by as-built data and genes encoded by tolerance ranges. The genes of as-built data are selected to the next generation directly without crossover and variation. Tolerances update: The evolutionary loop that satisfies the termination conditions terminates the iteration, outputs the optimal tolerance allocation scheme, and updates the dimension chain to the next step of the assembly tolerance allocation. To achieve chromosome coding, each tolerance scheme is treated as a chromosome. The as-built data of completed processes and the unassembled hinges' position tolerances are treated as the genes to obtain the chromosome coding form as follows:  
\[X_{i}^{j}=\left(\lambda_{1}^{j}\dots\lambda_{e}^{j}\dots\lambda_{i-1}^{j}, \xi_{i}^{j}\dots\xi_{m}^{j}\dots\xi_{n}^{j}\right) \tag{13}\]  
Figure 12: Dynamic tolerance optimization flow using GA and as-built data. where \(X_{i}^{j}\) represents the \(j\)-th tolerance scheme for the \(i\)-th assembly process, when the first (\(i-1\))-th processes have been completed; \(\lambda_{e}^{j}\) is the as-built data of the \(e\)-th assembly process; and \(\xi_{m}^{j}\) represents the \(m\)-th process' position tolerance. The fitness design is essential in GA for tolerance dynamic optimization. This paper designs the fitness function from three dimensions: the service performance, the assembly costs, and the population's diversity. For the service performance, the assembly error model built in Section 3 is used as the fitness function. For the convenience of expression, the error model's function is defined as follows:  
\[\theta_{i}^{j}=f\left(\lambda_{1}^{j}\dots\lambda_{e}^{j}\dots\lambda_{i-1}^{ j},\xi_{i}^{j}\dots\xi_{m}^{j}\dots\xi_{m}^{j}\right) \tag{14}\]  
where \(\theta_{i}^{j}\) represents the pointing accuracy corresponding to the \(j\)-th tolerance scheme in the \(i\)-th assembly process. Assume that the LSDM's pointing accuracy must be no more than \(\theta_{s}\); then, the fitness function considering the service performance is as follows:  
\[\theta_{i}^{j}\leq\theta_{s} \tag{15}\]  
In general, the assembly cost and service performance are mutually constrained, and the pursuit of the maximum service performance is bound to result in a sharp increase in cost. Therefore, it is necessary to consider the cost constraints when using GA to optimize the tolerances. To ensure the calculation accuracy and to simplify the calculation, this paper uses the quintic polynomial model to construct the assembly cost-tolerance model. The product assembly cost \(C_{j}\) corresponding to the \(j\)-th tolerance scheme adopts the McLaurin series and the quintic cost function equation as follows [31]:  
\[\left\{