## 2 Swarm Algorithms
### Artificial Swarm Fish Algorithm  
The Artificial Swarm Fish algorithm is based on the swarm behaviour of natural fish [18; 48; 49]. It imitates the collective movement of natural fish when they look for food or they are in danger.  
The position of a fish \(i\) is a solution of the problem, \(x_{i}(t)\), and the fitness of the position represents the food concentration. Each fish can see a limited area around it, defined by _visual_ (Figure 3), so as fish \(i\) can see fish \(j\) if the second one is in its neighbourhood: \(||x_{j}(t)-x_{i}(t)||<visual\).  
When a fish moves, it prefers positions with more food than its current position and not too crowded. The position of a fish is crowded if the ratio between the number of fish in its visual area and \(n\) reaches the value \(\rho\), where \(\rho\in(0,1)\) is a parameter called crowd factor.  
When a fish decides to move from its current position \(x_{i}(t)\) towards another position \(x^{\prime}\), its new position is computed according to Equation (5), where the parameter \(step\) limits the distance it can swim.  
\[x_{i}(t+1)=x_{i}(t)+\frac{x^{\prime}-x_{i}(t)}{||x^{\prime}-x_{i}(t)||}\;rnd _{(0,1)}\;step \tag{5}\]  
The algorithm imitates several behaviours of natural fish: Prey, swarm and follow.  
The prey behaviour allows the fish to move to a better position around its current position A fish \(i\) randomly selects a position \(x^{\prime}\) in its visual area and then moves towards it according to Equation (5) if \(x^{\prime}\) has more food than its current position. If the fish cannot move towards a better position after a certain number of attempts, it moves randomly within its visual.  
The swarm behaviour allows the fish to move towards the central point of its neighbourhood. Let us use \(x^{\prime}\) to represent the centre of the neighbourhood of fish \(i\). If the surrounding is not very crowded and the centre has more food than the current position of \(i\), the fish \(i\) swims towards \(x^{\prime}\) according to Equation (5); in other case, \(i\) applies the prey behaviour.  
The follow behaviour allows a fish to follow to other fish which has found food. Let \(j\) represent the fish in the position with the greatest food concentration in the visual area of fish \(i\). If \(x_{j}(t)\) has more food than \(x_{i}(t)\) and the surrounding is not very crowded, the fish \(i\) swims towards the fish \(j\) according to Equation (5) (where \(x^{\prime}\) is replaced by \(x_{j}(t)\)); in other case, this fish applies the prey behaviour.  
The main operations of the Artificial Swarm Fish algorithm are shown in Algorithm 3. After assigning random starting positions to the fish, an iterative process attempts to move them to better positions by applying the behaviours listed above. The behaviour of the fish \(i\) depends on its position and the state of the environment. When there are no fish in the visual of fish \(i\), it moves randomly to attempt to find a better position. When the visual area of \(i\) is crowded, the fish does not follow any  
Figure 3: Currently the fish \(i\) is at the position \(x_{i}(t)\). From this position, it can see other fish if they are in the area defined by the parameter “visual”. The parameter “step” defines the radius of the area that limits the movement of this fish when it swims.  
other fish; on the contrary, it moves to a random position in the visual area. When the visual area of \(i\) is not crowded, this fish can move to the centre of its neighbourhood or to the best position in the visual.  
```
Generate an initial population of \(n\) fish; repeat foreach fish \(i\)do  apply follow behaviour; iffollow behaviour failsthen  apply swarm behaviour;  end if iffollow behaviour failsthen  apply prey behaviour;  end if untilRequirements are met;
```  
**Algorithm 3** Swarm Fish algorithm  
Several improvements of the basic algorithm are described in [50; 51; 52].