# Metaheuristic with Cooperative Processes for the University Course Timetabling Problem
## 3 Simulated Annealing with Cooperative Processes (SACP)
This procedure is performed with each of the TTSA\({}_{i}\) solutions of each process \(i\) and the best BTT\({}_{i}\) solution obtainedfrom all processes. Once the \(\text{BTT}_{i}\) solution is feasible, it is assigned as the new \(\text{TT}_{i}\) = \(\text{BTT}_{i}\), solution to start with the next SA in process \(i\). * Figure 2 shows cooperation between processes is repeated every time that ends a restart with SA. * The algorithm counts the \(\text{RSA}_{i}\) number of SA restarts (NR). If the total number NR\({}_{i}\) has already been reached, the algorithm ends its execution, otherwise the execution of a new SA begins in process \(i\) with the new \(\text{TT}_{i}\) = cooperation (\(\text{BTT}_{i}\), \(\text{TTSA}_{i}\)) solution, obtained by cooperation between processes. NR\({}_{i}\) is the stopping criterion of SACP and is evaluated in each process \(i\). Figure 2: Simulated annealing with cooperative processes (SACP). Figure 4: Processes cooperation between a pair of solutions, the best obtained by a process vs. the best of all processes (\(\text{TTSA}_{i}\) vs. \(\text{BTT}_{i}\)). (**a**) Best solution obtained by process i, \(\text{TTSA}_{i}\). (**b**) Best solution of all processes, \(\text{BTT}_{i}\). (**c**) \(\text{TTSA}_{i}\) segment to insert into \(\text{BTT}_{i}\). (**d**) \(\text{BTT}_{i}\) segment to be replaced from \(\text{BTT}_{i}\). (**e**) New \(\text{BTT}_{i}\) solution with a lower d-Hamming value with \(\text{TTSA}_{i}\) that requires a correction to make it feasible (procedure 13.5). Figure 3: Processes cooperation procedure, \(\text{TTI}\) = cooperation (\(\text{BTT}_{i}\), \(\text{TTSAi}\)). Algorithm 1 presents the proposed simulated annealing algorithm that is applied in SACP within each process \(i\). Function SA\({}_{i}\) (TT\({}_{i}\)). The steps are explained below:  
1. The SA algorithm always requires starting with a solution feasible of the TT\({}_{i}\) problem. This feasible solution is evaluated with the objective function in (1) to obtain the \(bsc_{i}\) cost. The best known bsi solution is initialized with the value of \(bsc_{i}\). 2. SA input parameters, such as the control parameter \(T_{i}\), the length of the Markov chain MCL, the control coefficient \(\alpha\), that controls the decrease in the control parameter and the final value control parameter, with the value \(T_{f}\), which works as the SA stopping criterion, are initialized. 3. Lines 3 and 4, the external cycle of SA is performed as long as \(T\) does not reach \(T_{f}\). In addition, \(T\) is decremented with \(\alpha\), see line 28. 4. Lines 5 and 6, the internal cycle represents the cycle of Metropolis, and this is repeated until MCL is met, see line 26. 5. Line 7, a disturbance is performed by applying the neighborhood structure that exchanges a couple of randomly chosen events to assign each of them in a different timeslot. The TT\({}_{i}\) feasibility is evaluated with the sets of constraints presented in (2) to (6) of the optimization model, in case it is not feasible, then the pair of events is returned to its initial position and tested with another pair of events until TT\({}_{i}\) is feasible. The new feasible solution is stored in TT\({}_{p}\). 6. Line 8, the \(bsp_{c}\) cost of the disturbed TT\({}_{p}\) solution is obtained with Equation (1). 7. Line 9, the costs of TT\({}_{i}\) and TT\({}_{p}\) solutions are compared. If a better cost of the disturbed solution is obtained then online 10 and 11, TT\({}_{p}\) is accepted as the new TT\({}_{i}\) solution. 8. Lines 12 to 17, if the cost of \(bsp_{c}\) is less than or equal to that best solution obtained, then TT\({}_{p}\) is stored in TTSA\({}_{i}\) as the best solution obtained. 9. Lines 18 to 23 evaluate the criterion of acceptance of SA. This applies when the \(bsp_{c}\) cost obtained by the disturbance turns out to be greater than the cost of \(bsc_{i}\). 10. Line 18, a random number \(\rho\) is generated uniformly distributed between zero and one. 11.