# Integrated Tolerance and Fixture Layout Design for Compliant Sheet Metal Assemblies
## 3 Optimization Method
### Optimization Algorithm  
A GA is an evolutionary optimization algorithm meaning the solutions are evolved during a certain number of iterations. The utilized GA algorithm in this paper is denoted in Algorithm 1. Commonly, a population of random solutions is generated to start the optimization procedure. Subsequently, each solution receives a fitness value that is proportional to the value of the objective function for it. Afterward, new solutions are generated through genetic operations, including crossover and mutation. The new solutions with greater fitness values will substitute solutions with lower fitness values. This procedure will continue until the convergence criteria are satisfied. The value of \(x_{ij}\) is zero for all \(j\)s, except one for each part. Therefore, this parameter can be represented by \(j^{\prime}\), which indicates the \(j\) for which \(x\) is one for the corresponding part. For instance, \(j^{\prime}=2\) indicates that the second production strategy is utilized to produce the corresponding part. Each solution should include all design parameters for every part. Moreover, the solutions should satisfy the optimization constraints. Accordingly, a solution is made of \(m\) substrings of integer and real numbers. Each substring represents the production strategyand the fixture layout for a part in the assembly. A substring is identified in the following format: \(j^{\prime},\beta_{i,1},\beta_{i,2},\theta_{i},\alpha_{i1},\alpha_{i2},\ldots, \alpha_{ik}\). **Input:** The number of parts and candidate node numbers of each part. **Output:** The optimal solution including: the optimal production strategy and fixture layout. ```
1:Set the maximum number of iterations in \(n_{MaxIter}\)\(\triangleright\) Initialization
2:Set the stall size in \(n_{stall}\)
3:Set the population size in \(n_{pop}\)
4:Set the number of solutions for crossover in each iteration in \(n_{c}\)
5:Set the number of solutions for mutation in each iteration in \(n_{m}\)
6:Generate \(n_{pop}\) random solutions and save them in \(pop\). 7:Determine the fitness value of solutions in \(pop\) and save them in \(fit\)
8:for\(iteration=1\) to \(n_{MaxIter}\)do\(\triangleright\) Main loop
9:for\(i=1\) to \(\frac{n_{c}}{2}\)do\(\triangleright\) One-point Crossover
10: Select two solution by roulette wheel
11: Generate two new solutions through one-point crossover and save them in \(pop_{c}\)
12: Determine the fitness value of the new solutions and save them in \(fit_{c}\)
13:endfor
14:for\(i=\frac{n_{c}}{2}+1\) to \(n_{c}\)do\(\triangleright\) Multi-point Crossover
15: Select two solution by roulette wheel
16: Generate two new solutions by one-point crossover for _each substring_ and save them in \(pop_{c}\)
17: Determine the fitness value of the new solutions and save them in \(fit_{c}\)
18:endfor
19:for\(i=1\) to \(n_{m}\)do\(\triangleright\) Mutation
20: Select a random solution from \(pop\)
21: Generate a new solution by mutation and save it in \(pop_{m}\)
22: Determine the fitness value of the new solution and save them in \(fit_{m}\)
23:endfor
24:\(pop\gets pop+pop_{m}+pop_{c}\)\(\triangleright\) Merging
25: Sort \(pop\) in a _decedent_ order based on \(fit\), \(fit_{c}\), and \(fit_{m}\)
26: Truncate solutions of \(pop\) that are ordered after \(n_{pop}\)
27:if iteration > \(n_{stall}\) and the best solution has not improved during the last \(n_{stall}\) iterations then
28: Break the FOR loop
29:endif
30:endfor
31:return the first solution in \(pop\)
```  
**Algorithm 1** The utilized GA  
The following solution is presented as an example: 5, 7, 3, 122.5, 1, 0, 0, 1, 1, 0, 1, 0, 2, 4, 6, 82.0, 0, 0, 0, 1, 1, 1, 0, 1, 1. This solution denotes the production scenario and the fixture layout of an assembly of two parts, because it has two substrings. The first number in each substring states the production strategy with which the part's tolerances are defined. In this example, the tolerances of the first and second part are defined based on the fifth and second production scenario of each part, respectively.