# Binary Spring Search Algorithm for Solving Various Optimization Problems
## 3 Binary Spring Search Algorithm (\(BSSA\))  
In this section, a binary version of the spring search algorithm is developed. In the binary version of SSA, real values are displayed in binary using the numbers zero and one. The search space is discrete, and the appropriate number of binary values must be used to display each variable on the axis. Given that in the binary version, there are only two numbers (zero and one), the concept of displacement is defined as changing the status from zero to one or changing the status from one to zero. In order to implement this concept of displacement in the binary version, a probability function is used. Based on the value of this probability function, the new position of each member in each dimension of the problem may be change or remain unchanged. Therefore, in the \(BSSA\), \(dX^{jd}\) is the probability of \(X^{jd}\) becoming zero or one. The method of calculating the spring forces, the constant values of the springs, the amount of displacement per member of the population, and the update steps are similar in both the binary and real versions. The difference between the two versions is in how the population is updated. Given that the probability function must be a number between zero and one, the probability of changing the position for each dimension of each member is calculated using Equation (12). \[S\Big{(}dX^{jd}(t)\Big{)}\ =\ \Big{|}\tanh\Big{(}dX^{jd}(t)\Big{)}\Big{|} \tag{12}\]  
Therefore, based on the values of the probability function, the new position of each dimension of each member is updated using Equation (13). \[ \begin{split}\text{If }rand<S\Big{(}dX^{jd}(t)\Big{)}\ \text{ Then }X^{jd}(t+1)=\text{complement}(X^{jd}(t))\\ \text{Else }X^{jd}(t+1)=X^{jd}(t)\end{split}  \tag{13}\]  
According to Equation (13), each member of population changes its position with a probability; the higher the value of \(dX^{jd}\), the higher the probability of object \(j\) moving in dimension \(d\). \(rand\) is a random number with a normal distribution in the range \(of\ [0-1]\). The different steps of the \(BSSA\) are shown as flowcharts in Figure 1.  
In order to clearly illustrate how the proposed method seeks the optimal solution, let us consider the following standard function:  
\[f(x)=\sum_{i=1}^{2}x_{i}^{2}\]  
This problem is solved for two dimensions with 50 iterations and 10 bodies as the problem population. In the first iteration, the members of the population are randomly placed in the problem space. It is observed in Figure 2 that the proposed algorithm extensively searches the search space in the initial iterations to cover the defined space of the problem with high search capacity. Over time, it is seen that the proposed algorithm converges towards an optimal solution, and members of the population are concentrated in the vicinity of this optimal solution. The high capacity of the algorithm is presented for a quick exploration of the optimal solution. The numerical results of the test function in different iterations are shown in Table 1.  
Figure 1: The flowchart of the Binary Spring Search Algorithm (_BSSA_).