## 3 The Proposed Approach
### The PSO Algorithm  
#### 3.4.1 The Standard PSO Algorithm  
The PSO algorithm is an evolutionary computational technique that originated from the study of the behavior of flocks of birds foraging. The idea of the algorithm originates from the study of the foraging behavior of bird flocks, where the flock finds the optimal destination through collective information sharing. Suppose that in a \(D\)-dimensional  
\begin{table}
\begin{tabular}{c c c c c c c c c c c c} \hline k & 3 & 4 & 5–10 & 11–15 & 16–35 & 36–56 & 57–126 & 127–210 & 211–462 & 463–792 & 793–1716 & 1717–3003 \\ \hline m & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & 13 & 14 & 15 \\ \hline \end{tabular}
\end{table}
Table 1: Statistics on the number of optimal test cases for \(t=2\), \(s=2\), and \(3<k<3003\).  
target search space, there is a swarm that contains \(N\) particles, where the \(i\)-th particle is represented by a vector with \(D\) dimensions, denoted as \(X_{i}=(x_{i1},x_{i2},\ldots,x_{iD}),i=1,2,\ldots,N\). The velocity of the \(i\)-th particle is also a \(D\)-dimensional vector, denoted as \(V_{i}=(v_{i1},v_{i2},\ldots,v_{iD}),i=1,2,\ldots,N\). The optimal position obtained by the \(i\)-th particle is \(P_{id,pbest}=(p_{i1},p_{i2},\ldots,p_{iD}),i=1,2,\ldots,N\). The optimal position based on the search results of all the particles in the population is \(P_{d,gbest}=(p_{1,gbest},p_{2,gbest},\ldots,p_{D,gbest})\). The fitness value of the \(i\)-th particle, which is the value of the objective function for the optimal position searched by the particle, is denoted by \(f_{i,p}\). The fitness value of the optimal position obtained by the population is \(f_{g}\).  
The \(i\)-th particle updates its velocity and position according to the following equations:  
\[v_{id}^{k+1}=\omega v_{id}^{k}+c_{1}r_{1}\Big{(}p_{id,pbest}^{k}-x_{id}^{k} \Big{)}+c_{2}r_{2}\Big{(}p_{d,gbest}^{k}-x_{id}^{k}\Big{)} \tag{8}\]  
\[x_{id}^{k+1}=x_{id}^{k}+v_{id}^{k+1} \tag{9}\]  
where \(c_{1}\) is the individual learning factor, and \(c_{2}\) is the group learning factor.  
In this paper, the goal of the PSO is to cover the maximum number of pairwise combinations of elements with the minimum number of test cases after using the ROBDD. In other words, the problem is how to generate the TS in Definition 5 of Section 3.3 when the number of inputs (\(k\)) and the number of input values (s) are known. So, the position of each particle (\(X_{i}\)) is an \(m\times k\) matrix that represents \(m\) test cases, and the system under the test has \(k\) inputs. The fitness function (\(\text{Fit}(X_{i})\)) is defined as the combined coverage of the pairwise tests (i.e., the ratio of all possible value-taking outcomes that have occurred for all pairwise combinations). It can be calculated via Equation (10):  
\[\text{Fit}(X_{i})=\frac{n(X_{i})}{4\times C_{k}^{2}} \tag{10}\]  
where \(n(X_{i})\) represents the number of combinations executed at least once, and \(4\times C_{k}^{2}\) represents the number of all possible combinations. The termination condition for the PSO is to make \(\text{Fit}(X_{i})\) reach 1. This means that enough test cases are designed so that every possible combination of the conditions in the judgment occurs at least once.