## 3 The Proposed Algorithms
### Description of the Proposed PSO Algorithm
Procedure _InsertColumn_() takes as first parameter either Personal_best(p) or Global_best, as second parameter particle(p) and as third parameter a random selected timeslot t, which is the timeslot to be replaced in particle(p) either from Personal_best(p) or Global_best. The _While Loop Structure_ tries to discover, for each particle(p), a particle with the best or equal fitness value to the fitness value of Global_best, by applying procedure _InsertColumn_() between Global_best and particle(p). In order to avoid being trapped into an infinite loop, the algorithm can exit the _While Loop Structure_ with a probability set to 1.08%, no matter what the achieved fitness value is, every time 10 more loops are executed. ### Description of the Proposed AFS Algorithm

The population of the proposed AFS algorithm consists of 24 fish, each of which is a two-dimensional array. The fish encoding is the same as the one used by the proposed PSO algorithm and the algorithm presented in [20]. In Algorithm 2, the pseudo code of the proposed AFS based algorithm is presented. The algorithm is a hybrid one consisting of two basic components:

* the main algorithm, which will be analytically described in the following paragraphs. * a local search procedure, which is the same as the one used by the proposed PSO algorithm and the algorithm presented in [20]. As seen in Algorithm 2, the main algorithm includes seven basic procedures, namely, procedure _Prey0_, procedure _InsertPrey()_, procedure _SwarmNChace()_, procedure _CreateNeighborood()_, procedure _CalculateLocalCentre()_, procedure _Leap()_, and procedure _Turbulence()_. A detailed description of these procedures is given in the following paragraphs. We define Distance d between two fish f1 and f2 as the number of cells of the timetable, in which the two fish differ. The distance of two fish takes values in the interval [0, number of classes \(\times\) 35]. As the algorithm progresses, the fish tend to approach each other and the population loses the desired diversity that allows fish to seek in wider solutions area. To prevent this phenomenon, a shaker process of the space of solutions is used, called procedure _Turbulence()_ (Algorithm 2, Line 10). This procedure is activated when the current maximum distance between all fish becomes less than MIN_DISTANCE_COEF \(\times\) number of classes \(\times\) 35, wherein MIN_DISTANCE_COEF is a user defined \"proximity factor\", constant throughout the execution of the algorithm. During the execution of procedure _Turbulence()_, a random fish, a random row (class) in this fish and two random periods are selected. Then, utilizing procedure _Swap()_ teachers assigned to classes during these periods are swapped. Procedure _Swap()_ is repeated a specified number of times, which in all experiments conducted was equal to TURBULENCE_ITERATIONS \(\times\) NUMBER_OF_FISH, wherein TURBULENE_ITERATIONS is user defined, constant throughout the execution of the algorithm. The parameters of procedure _Swap()_, as used in procedure _Turbulence()_, are four: a randomly selected fish, a randomly selected row in this fish and two randomly selected columns in this fish. It swaps the values of two cells in the same row of the timetable of fish f, _i.e._, teachers who are assigned to the two periods of the timetable of the class. Procedure _Leap()_ (Algorithm 2, Line 12) is activated when the improvement of the obtained best fitness (_i.e._, the fitness of minGlobalFish) during the last LEAP_NUMBER generations is less than MIN_IMR, where LEAP_NUMBER and MIN_IMR are user defined and constant. Parameter MIN_IMR is the threshold of desired fitness' rate improvement in order to start the _Leap()_ procedure (see also Table 1). Procedure _Leap()_ is triggered repeatedly until the desired rate of improvement has been achieved or 10 executions without desired rate of improvement have been completed. In order to achieve the desired rate of improvement, procedure _Leap()_ applies procedure _Approach()_, which forces current fish f to approach minGlobalFish.