# Density-Based Prioritization Algorithm for Minimizing Surplus Parts in Selective Assembly
## 3 DBP Algorithm  
As confirmed in Section 2.2, the frequencies of supply and assembly must be balanced throughout the range of measurements to minimize surplus parts in the search-based selective assembly of flow production systems. Accordingly, we propose the DBP algorithm, which prioritizes the selection of parts with many other similar sized parts in the slots. DBP regards the similarity of a part with the other parts for each slot as linear density on the dimensional coordinate; these slots are prioritized in order of density. This linear density \(\lambda\) can be understood as a quantity \(Q\) of parts per unit range \(L\) of measurement;  
Figure 3: Dimensional distribution of outer ring raceway diameter errors in slots over time. this is equal to the inverse of the average distance _E(D)_ between neighboring parts on the dimensional coordinate:  
\[\lambda=\frac{Q}{L}=\frac{1}{E(D)}. \tag{2}\]  
Thus, DBP obtains the density for one part \(\lambda_{i}\) as the inverse of the average distance from one part \(x_{i}\) to its two nearest parts in each of the smaller and larger sides on the dimensional coordinate, \(x_{i-1}\) and \(x_{i+1}\):  
\[\lambda_{i}=\frac{1}{\frac{1}{2}\{(x_{i}-x_{i-1})+(x_{i+1}-x_{i})\}}=\frac{2}{x _{i+1}-x_{i-1}}. \tag{3}\]  
In addition, the order of density is the reverse of the order of average distance and the order of average distance is the order of sum of the two distances:  
\[\lambda_{i}>\lambda_{j}\Leftrightarrow x_{i+1}-x_{i-1}<x_{j+1}-x_{j-1}. \tag{4}\]  
Therefore, unnecessary calculations for prioritization are omitted. Here, since the smallest and largest parts have only one side which is smaller or larger, the distances of these parts from their nearest parts are multiplied by two. The dimensional concentration phenomenon is alleviated by determining whether the outer rings can be assembled in order of priority so that they can be selected first. The implementation of the DBP algorithm is as follows:  
```
Input: Array of measurements of parts X Output: Array of sorted indexes by priority P
1. n \(\leftarrow\) length (X)
2. initialize D[1... n]
3. P \(\leftarrow\) [1... n]
4. sort X and P by X in ascending
5. for i \(\leftarrow\) 2... n-1 do
6. D[j] \(\leftarrow\) [j+1]-X[i-1]
7. end
8. D[1] \(\leftarrow\) 2 \(\times\) (X[2]-X[1])
9. D[n] \(\leftarrow\) 2 \(\times\) (X[n]-X[n-1])
10. sort P by D in ascending
11. return P
```  
**Algorithm:** Density-Based Prioritization  
The selective assembly process selects the outer ring with the highest priority set by DBP among the outer rings that can be assembled. However, this is a poor strategy in terms of process capability, which is an indicator of how well the precision of the process results meets the tolerances required by the process. Process capability should be controlled in the process of manufacturing precision products. The process capability \(C_{pk}\) is calculated as follows:  
\[C_{pk}=\min\bigg{[}\frac{USL-\hat{\mu}}{3\sigma},\ \frac{\hat{\mu}-LSL}{3 \sigma}\bigg{]}. \tag{5}\]  
where _USL_ is the upper specification limit, _LSL_ is the lower specification limit, _\(\hat{\mu}\)_ is the mean of the process, and \(\tilde{\sigma}\) is the variability of the process; the sigma levels corresponding to different \(C_{pk}\) values are shown in Table 1[11]. Even if all parts meet the specifications, a low process capability indicates a high probability of producing defective products due to future fluctuations. Therefore, a method of reducing the process deviation is needed. A phasing method can be implemented to determine whether or not products can be assembled in a narrower tolerance and again in the original tolerance if there are no parts that can be assembled. Since the DBP-applied selective assembly system does not consider the assembly precision, the distribution of the assembly results will approximate a uniform distribution within the tolerance.