## 5 Optimization Method  
In this section, we propose an optimization method for the OSNR-aware lightpath planning problem in MCF-based SS-FONs. The optimization method applies the OSNR-based QoT estimation model presented in Section 3.2 and generates feasible solutions to the MIP model formulated in Section 4. In the description of the method, we apply the notation presented in previous sections, and we introduce additional symbols specific to the algorithm. The core element of the optimization method is the OSRN-aware lightpath allocation (OSNR-LA) algorithm, which solves the problem of allocation of lightpaths satisfying given SNR requirements for an ordered set of traffic demands (denoted as \(\widetilde{\mathcal{D}}\)), which are processed one by one. The algorithm makes use of candidate routing paths \(\mathcal{P}(d)\) that are available for each demand \(d\). In OSNR-LA, the verification of SNR is performed both for each candidate lightpath and for all already allocated and possibly affected lightpaths based on the actual allocation status of spectral-spatial resources in network links, which is maintained in a network state matrix \(A\). In particular, the allocation status of frequency slices in cores of particular network links is represented using the maximal free-occupied block (MFOB) approach proposed in [30] that utilizes a three-dimensional matrix \(A^{|\mathcal{E}|\times|\mathcal{C}|\times|\mathcal{S}|}\). Element \(A(e,c,s)\) corresponds to slice \(s\) in core \(c\) of link \(e\), and it represents the allocation status of slice \(s\) (free or busy) as well as contains the information about how many consecutive slices (beginning from \(s\)) have the same status as slice \(s\). By reading element \(A(e,c,s)\), the algorithm is able to determine either whether the requested number of consecutive slices is available for allocation of a lightpath or which slice is worth checking next. As shown in [30], the application of MFOB speeds up considerably the searching for free spectrum resources. A pseudo-code of the OSNR-LA algorithm is shown in Algorithm 1. In lines 1 and 2, spectral-spatial resource allocation state matrix (\(A\)), the set of allocated lightpaths (\(\overline{\mathcal{L}}\)), and the required number of slices (\(z\)) are initialized. In line 3, a loop iterating over consecutive demands from the ordered set of demands (\(\widetilde{\mathcal{D}}\)) begins. In line 4, the best lightpath (\(\widetilde{l}\)) selected for demand \(d\) is initialized. In lines 5 and 6, respectively, loops iterating over candidate paths (\(\mathcal{P}(d)\)) for demand \(d\) and available MCF cores (\(\mathcal{C}\)) are started. The beginning frequency slice (\(s_{beg}\)) of a candidate lightpath is initialized in line 7, and a \"while\" loop iterating over consecutive candidate slices starts in line 8. In line 9, frequency slot \(f\) beginning from slice \(s_{beg}\) and occupying \(N(d,p,c)\) consecutive slices is initialized. Here, \(N(d,p,c)\) represents the number of slices required to serve the bit rate of demand \(d\) on path \(p\) and core \(c\), assuming that the best modulation format that can be used on path \(p\) is selected. In line 10, candidate lightpath \(l\) is initialized with path \(p\), core \(c\), and frequency slot \(f\). In line 11, it is checked using the allocation state matrix (\(A\)) whether spectral resources are available for lightpath \(l\) in core \(c\) in each link of path \(p\). If the resources are available, then subset \(\widetilde{\mathcal{L}}\) of the already selected lightpaths (\(\widetilde{\mathcal{L}}\subseteq\overline{\mathcal{L}}\)) that might be affected by lightpath \(l\) is determined in line 12. In line 13, it is checked whether lightpath \(l\) and all possibly affected lightpaths (\(\widetilde{\mathcal{L}}\)) satisfy the QoT requirement by calculating their inverse SNR values, using Model (3), and comparing them with allowable limits, as discussed in Section 3.2.