## 5 Optimization Method
If the QoT of lightpaths is acceptable, then it is checked (in line 14) whether candidate lightpath \(l\) has a lower beginning slice index than the best lightpath (\(\widetilde{l}\)) found so far for demand \(d\). If so, lightpath \(\widetilde{l}\) is substituted with lightpath \(l\) (in line 15) and the \"while\" loop is terminated (in line 16). Otherwise, if either spectral resources are not available or the QoT of some lightpath is not satisfied, then beginning slice \(s_{beg}\) is updated to the next available slice (in line 18), and the candidate lightpath verification procedure (starting in line 9) is repeated. After all candidate path-core pairs have been processed, the best lightpath (\(\widetilde{l}\)) found for demand \(d\) is included into the set of allocated lightpaths (\(\overline{\mathcal{L}}\)) and network state (\(A\)) is updated in line 19. In addition, in line 19, the required number of frequency slices (\(z\)) is updated if the ending slice (\(s_{end}\)) of lightpath \(\widetilde{l}\) exceeds \(z\). The algorithm terminates after all demands have been processed. Algorithm 1 returns a feasible allocation of lightpaths after processing the demands according to given order (\(\widetilde{\mathcal{D}}\)). Since the lightpaths selected and spatial-spectral resources allocated may differ for different sequences of processed demands, the value of objective function (\(z\)), which represents the number of frequency slices required in the network, may differ as well. Therefore, as the value of \(z\) is subject to minimization, we execute Algorithm 1 a number of times, each time assuming a different order od demands \(\widetilde{\mathcal{D}}\), and we consider the solution with the lowest value of \(z\) as the best one and returned by the optimization method. To drive the algorithm in its search toward the best order of demands, we apply a simulated annealing (SA) method [31]. Namely, at each SA iteration, two randomly selected demands in \(\widetilde{\mathcal{D}}\) are swapped, and Algorithm 1 is executed for the resulting order of demands. If the obtained value of \(z\) is improved, it is considered as the best one and order \(\widetilde{\mathcal{D}}\) is accepted as the current one; otherwise, order \(\widetilde{\mathcal{D}}\) is accepted with certain probability, which decreases after each SA iteration. To control the performance of SA, two parameters are used: temperature \(\mathcal{T}>0\) determining the probability of accepting non-improving solutions and cooling rate \(\rho\) representing the speed of decreasing the temperature in consecutive iterations, where \(0<\rho<1\). We consider that \(\mathcal{T}\) is initialized with the product of the value of \(z\) obtained in the first algorithm iteration and a temperature coefficient (denoted as \(\tau\)). After each SA iteration, \(\mathcal{T}\) is updated and takes the value \(\mathcal{T}\times\rho\). The probability of accepting non-improving solutions is calculated as \(e^{-(z-\overline{z})/\mathcal{T}}\), where \(z\) and \(\overline{z}\) are objective function values corresponding, respectively, to the new and current solution. In Section 6.2, we perform algorithm tuning to select the values of \(\tau\) and \(\rho\) that offer the best performance. Eventually, to speed up the algorithm, we make use of multi-core CPU capabilities and run a number of parallel threads (one per a logical CPU core), where each thread executes an instance of the SA method described above. For algorithm parallelization, we apply the cooperative with solution exchange (CSE) approach proposed in [30]. In CSE, the best global solution (namely, best order \(\widetilde{\mathcal{D}}\) and best value of \(z\)) is shared between the threads. Whenever improved, this best global solution is updated and distributed among the parallel instances of SA that consider \(\widetilde{\mathcal{D}}\) as the current order of demands. As shown in [30], a parallel simulated annealing (PSA) algorithm allows significantly decreasing computation times.