## 3 The Proposed Algorithms
### Description of the Proposed PSO Algorithm
5:Create initial population of fish, each fish having random structure; //The size of initial population is set to NUMBER OF FISH=24
6:minGlobalFish \(\blackleftarrow\) The fish with best fitness in population;
7:Make every fish best position equal to current (_i.e._, initial) position;
8:generation \(\blackleftarrow\) 0;
9:While generation \(<\) NUM_OF_GENERATIONS \(\{\)//NUM_OF_GENERATIONS is set to 10,000
10:
11:If maximum distance between all fish is less than a minimum threshold then
12://Threshold is equal to MIN_DISTANCE_COEF \(\times\)number of classes \(\times\)35
13:Execute procedure _Turbulence_(); //perturb the population of fish
14:If the % improvement of minGlobalFish fitness for the last LEAP_NUMBER generations is not bigger than MIN_IMPR then
15://MIN_IMPR is a threshold in the improvement of minGlobalFish
16:Execute procedure _Leap_(); //make fish approach minGlobalFish
17:For each fish f \(\{\)
18:If fitness of fish f has been improved then
19:update fish f personalBest;
20:Execute procedure _CreateNeighborhood_(f); //_ recreate the neighborhood of fish f
21:Execute procedure _CalculateLocalCentre_(f); //_calculate the localCentre of the neighborhood of fish f and the localBest of fish f
22:If the neighborhood of fish f is sparse then //_if it contains less than SPARSE_COEF \(\times\) NUMBER OF FISH members
23:Execute procedure _Prey_(f); // try to find for fish f, in the whole population, a structure having better fitness
24:Else
25:If the neighborhood of fish f is dense then //_if it contains more than DENSE_COEF \(\times\)NUMBER_OF_FISH members
26:Execute procedure _InnerPrey_(f); // try to find for fish f, in its neighborhood, a structure having better fitness_
27:Else
28:Execute procedure _SwarmNChase_(f); //_try to find for fish f a structure having better fitness in case its neighborhood is neither dense nor sparse_
29:If fitness of fish f \(<\) = fitness of minGlobalFish then
30:minGlobalFish \(\blackleftarrow\) f;
31:\(\blackleftarrow\) } // end For each fish f
32:++generation;
33:\(\blackleftarrow\) } // end While generation \(<\) numOfGenerations
34:End of main algorithm //Here is where the main algorithm ends and the refinement phase starts
35:Execute _Local Search Procedure_
36:output \(\blackleftarrow\) minGlobalFish;
37:End of hybrid AFS algorithm Procedure _CreateNeighborod_() (Algorithm 2, Line 16) plays a major role in the operation of the algorithm. Its aim is to create in every generation, the current neighborhood for each fish. As the fish move, their mutual distances change and they are getting far or near to each other. Thus, neighborhoods of fish evolve dynamically during execution of the algorithm. This means that in every generation, the neighborhood of each fish is recalculated. We define that a fish f\({}_{1}\) is assumed to lie in the neighborhood of a fish f, if its distance from f is less than minDist + (maxDist - minDist) \(\times\) VISUAL_SCOPE_COEF, where minDist and maxDist are respectively the minimum and maximum distance among all fish of current population and VISUAL_SCOPE_COEF is a user defined parameter, constant throughout the execution of the algorithm. As stated before, the distance d between two fish f1 and f2 is the number of cells of the timetable, in which the two fish differ. Procedure _CreateNeighborod_() sets the fish in the neighborhood of f in increasing fitness order. So, the first fish in the neighborhood of f, is the one with the best fitness among all its neighbors. A neighborhood is considered \"sparse\" (Algorithm 2, Line 18), when containing less than SPARSE_COEF \(\times\) NUMBER_OF_FISH members, where NUMBER_OF_FISH is the population size and SPARSE_COEF is a user defined parameter, constant throughout the execution of the algorithm. A neighborhood is considered \"dense\" (Algorithm 2, Line 21), when containing more than DENSE_COEF \(\times\) NUMBER_OF_FISH members, where DENSE_COEF is a user defined parameter, constant throughout the execution of the algorithm.