# Metaheuristic with Cooperative Processes for the University Course Timetabling Problem
## 3 Simulated Annealing with Cooperative Processes (SACP)
In each process, the Hamming distance is calculated with d_h = d-Hamming (BTT\({}_{i}\), TTSA\({}_{i}\)), evaluating the difference between the two solutions BTT\({}_{i}\) vs. TTSA\({}_{i}\). With this, the processes cooperation is carried out because it is carried out by reducing d-Hamming between the solution obtained in TTSA\({}_{i}\) vs. BTT. 12.1 The Hamming distance is obtained by comparing each timeslot (x, y, z) of both solutions, see Figure 1. 12.2 If the same event is stored in the timeslot (x, y, z) of both solutions, then the similarity of both solutions is the same in that timeslot. 12.3 If the same event is not stored in the timeslot (x, y, z) of both solutions, then there is no similarity in that timeslot. 12.4 The comparison is made between each of the timeslots (x, y, z) of both solutions, BTT\({}_{i}\), TTSA\({}_{i}\), and the degree of difference between both solutions is counted. 12.5 A large d-Hamming value indicates that the similarity between BTT\({}_{i}\) and TTSA\({}_{i}\) is very little. 12.6 A small d-Hamming value indicates that the similarity between BTT\({}_{i}\) and TTSA\({}_{i}\) is greater. 13. Figure 3 presents processes cooperation in the flow diagram. TT\({}_{i}\) = cooperation (BTT\({}_{i}\), TTSAi), brings the best BTTi solution of all processes closer to the best TTSA\({}_{i}\) solution of each process by reducing its Hamming distance. Figure 4 presents a simple example of how the processes cooperation is performed. 13.1 A segment segSA\({}_{i}\)\(<-\) random (di,pi,TTSAi) of TTSA\({}_{i}\) is taken randomly with coordinates (x, y) = (\(d_{i}\), \(p_{i}\)) = (\(d_{2}\), \(p_{3}\)). This segment includes the full depth of the cube, that is (\(z_{1}\), \(\ldots\), \(z_{n}\)) = (\(r_{1}\), \(\ldots\), \(r_{n}\)), see Figure 4c. 13.2 The segSA\({}_{i}\) segment replaces the segBi segment that is located at the same coordinates in the BTT\({}_{i}\) solution, so that all constraints for events in that segment are maintained. 13.3 The replaced segment segBi\({}_{i}\) of BTT\({}_{i}\) is presented in Figure 4d. 13.4 Although the segSA\({}_{i}\) replacement segment does not violate constraints in BTTi, there are repeated events in the new BTT\({}_{i}\)\(<-\) replacement (segSA\({}_{i}\), segBi, BTT\({}_{i}\)) solution. 13.5 To return the feasibility in BTT\({}_{i}\)\(<-\) feasibility (BTT\({}_{i}\)), repeated events Re\({}_{i}\)\(<-\) find_repeat_ev (segBi, segSA\({}_{i}\)), presented in the segments of replacement segSA\({}_{i}\) and segBi\({}_{i}\) are searched. In the example in Figure 4c,d, the event Re\({}_{i}\) = {2} appears as repeated, and this indicates that event 2 will not appear repeated in the new BTT\({}_{i}\) solution (Figure 4e). 13.6 The remaining events 7 and 10 of segSA\({}_{i}\) (Figure 4c) will appear repeated at other coordinates in BTT\({}_{i}\) (Figure 4e). 13.7 Then, the procedure seeks to insert in BTT\({}_{i}\) (Figure 4e) in the position where repeated events 7 and 10 (Figure 4e) are located, to the deleted events Le\({}_{i}\) = \(<-\) find_lost_ev (segBi, segSA\({}_{i}\)). Figure 4d shows the lost events [3, 5] when its segBi\({}_{i}\) segment of BTT\({}_{i}\) was removed. 13.8 The deleted events Le\({}_{i}\) = {3, 5}, are tried to be replaced by the events 7 and 10 which are not inserted in Figure 4c. These events 7 and 10 are searched in BTT\({}_{i}\) outside the segment inserted segSAi, which is defined as a tabu segment. Le\({}_{i}\) events already inserted are proven to meet all constraints to obtain a feasible solution in BTT\({}_{i}\) = feasibility (BTT\({}_{i}\)) when any of them do not meet any constraints. The events are inserted anyway and an exchange that is feasible with other events is sought randomly (minus the events of the segment inserted segSA\({}_{i}\) which is tabu), until achieving the feasibility of BTT\({}_{i}\). Tabu events are not exchanged so as not to increase d-Hamming. 13.9 The previous cooperation procedure makes the new BTT\({}_{i}\) solution (Figure 4e) more similar to TTSA\({}_{i}\) (Figure 4a).