## 3 Advanced AFSA Optimization Method
### Adaptive GSA  
After optimizing the adaptive initialization process according to Algorithm 1, it will be more conducive to advancing the adaptive GSA part integrally. Algorithm 1 and the fitness function will establish a link between the previous process and subsequent adaptive adjustment stages in AFSA. In order to apply the fitness function value more reasonably to the optimization process of AFSA, normalization is necessary. According to Equation (5) in this paper, if the total number of samples used by the indoor localization system is recorded as \(N\), the weight of the \(i\)-th sample is recorded as \(Weight_{i}\). Therefore, the proportion of NLOS acoustic signal samples for training in the system can be improved according to the statistical data of NLOS situations. The training weight used in the system can be obtained by \(J(w_{i})\), and \(Weight_{i}\) can be acquired:  
\[Weight_{i}=\frac{J(w_{i})}{\sum\limits_{i=1}^{N}J(w_{i})} \tag{7}\]  
The ultimate purpose of the AFSA optimization method is classical, and the core idea is clear. In nature, some biologists believe that fish in the natural environment will tend to gather or forage in the area where the nutrition is highly concentrated and the crowding is relatively low. Thus, many researchers construct the AFSA model or methods. For the conventional AFSA optimization method, any infantry mainly completes sample reorganization, reselection, and optimization through the three stages of AFSA_preying, AFSA_swarming, and AFSA_following in the backbone of optimization. Furthermore, AFSA_preying refers to the movement in unit time taken by an artificial fish when it searches for the next position where the nutrition is higher than the current state within the fields of visual range. If \(X_{i}\) is used to indicate the current state of the fish, \(X_{j}\) is used to indicate another state within the field of vision, and \(range(t)\) is used to indicate the visual range. It is regarded as a variable function, which is allowed to fluctuate randomly within the effective zones. It also means that the visual range can be changed promptly in a unit of time under this state. \(rand()\) represents a random number, so the basic description of the states can be written as follows:  
\[X_{j}=X_{i}+range(t)\times rand()\times Weight_{i} \tag{8}\]  
If an infantry decides to move from \(X_{i}\) to \(X_{j}\) after finishing the comparison based on fitness function values at time \(i\), it is necessary to further update the moving range and the fields of vision or dynamical adjusting factors adaptively. If \(rand()\) represents a random number within \((0,1)\), the AFSA_preying behavior can be written by combining formula (8):  
\[X_{i}^{(t+1)}=X_{i}^{(t)}+\frac{X_{j}-X_{i}^{(t)}}{\left\|X_{j}-X_{i}^{(t)} \right\|}\times range(t)\times rand()\times Weight_{i} \tag{9}\]  
Although the AFSA_following behavior and the AFSA_swarming behavior have some similarities in the core process or settings, the influential factors of the two behaviors mentioned above are distinct. The action of an infantry is affected by the location \(X_{j}\) where the target concentration value is the highest within the fields. The geometric center \(X_{p,c}\) of this set can be influenced by specific partners within the fields. The concentration value of nutrients will be updated in real-time during their training processes. Judging by the Euclidean distance between the samples in the learning period, if the location of the center to be determined is better than the current location of the center, and the surrounding area is not overcrowded, the infantry will move towards the suspected center in a unit time, otherwise it performs the AFSA_preying behavior in Equation (9). Some critical thresholdneeds to be set by ourselves, which is related to the population density within the effective range.