## 3 The Proposed Algorithms
### Description of the Proposed PSO Algorithm
One of the key behaviors simulated in AFS algorithms is the tendency of fish to gather in flocks to maximize food-finding and survival chances [17]. The concentration of fish in flocks (swarming) is simulated by moving the fish to a \"notional\" fish located in the \"center\" of their neighborhood (localCentre fish). This \"notional\" fish, is created by procedure _CalculateLocalCentre_() (Algorithm 2, Line 17). At first, the localCentre fish is set equal to the first fish in the neighborhood of f, which is the fish with the best fitness among all fish in the neighborhood, since procedure _CreateNeighborod_() sets the fish in the neighborhood of f in increasing fitness order (see above). Then, for an arbitrary  
Figure 1: Two fish timetables which differ in cell \((i,j)\). Figure 2: The fish f\({}_{1}\) after switching cells \((i,j)\) and \((i,\,m)\). number of times (without, of course, exceeding the size of the neighborhood), the localCentre approaches the _i_-th fish of the neighborhood, utilizing procedure _Approach_(), with a diminishing step given by the expression \(\frac{1}{i+1}\). For example, the localCentre approaches the second fish of the neighborhood with step equal to \(\frac{1}{3}\), the third fish of the neighborhood with step equal to \(\frac{1}{4}\) and so on. As a result, the participation of the most robust fish of the neighborhood to the creation of the localCentre is greater than that of the less robust. A fish f performs _Prey_() (Algorithm 2, Line 19) procedure when its neighborhood is not rich enough in fish, towards which it could make a move. A fish f\({}_{1}\), different from f, is selected randomly from fish population and if it has better fitness than f then fish f moves towards f\({}_{1}\) using procedure _RandomApproach_() and procedure _Prey_() is completed. If the fitness of f\({}_{1}\) is not better than the fitness of f then f can also move towards f\({}_{1}\) using procedure _RandomApproach_() with probability equal to \(e^{-\frac{dc}{gen}}\) (dc is the difference in fitness between fish f\({}_{1}\) and fish f and gen is the current generation) and procedure _Prey_() is completed, too. This is repeated PREY_TRY_NUMBER times at most, where PREY_TRY_NUMBER is a user defined parameter, constant throughout the execution of the algorithm. In case none of the above situations take place, fish f moves towards its personalBest using procedure _RandomApproach_(). The pseudo code of procedure _Prey_() is presented in Algorithm 3. ```
0. For try < 1 to PREY_TRY_NUMBER {
1. accept < random number between 0 and 1;
2. pick a random fish f\({}_{1}\) among the population;
3. dc < fitness of f\({}_{1}\) - fitness of f;
4. If fitness of f\({}_{1}\) <= fitness of f then {
5. Execute procedure _RandomApproach_(); // _move randomly fish f towards fish f\({}_{1}\);
6. return;
7. } // end If
8. If (fitness of f\({}_{1}\) > fitness of f) and (\(e^{\frac{dc}{gen}}\) > = accept) then {
9. Execute procedure _RandomApproach_(); // _move randomly fish f towards fish f\({}_{1}\);
10. return;
11. } // end If
12. } // end For
13. Execute procedure _RandomApproach_(); // _move randomly fish f towards its personalBest
14. return;
```  
**Algorithm 3**The pseudo code of procedure _Prey_(). Procedure _RandomApproach_() works the same way as procedure _Approach_(), with the difference that it completes its operation if f\({}_{1}\) achieves better fitness than its initial one during the execution of the procedure. It chooses, just like in procedure _Approach_(), a random location at which both fish differ and then tests all the swaps (in same way as described in procedure _Approach_()). From all these swaps, procedure _RandomApproach_() finally chooses to carry out the one that leads to better fitness among all available swaps. The process ends either when a better fitness to f\({}_{1}\) is achieved or when--as in procedure _Approach_()--the percentage of the initial distance between the two fish becomes less than (1.0-STEP_RATIO).