## 2 Materials and Methods
### Method for Spectrum Assignment Using Multi-Level Formats and Optical Frequency Combs--RMLSA
```
1:\(atf\gets 0.2\)\(\triangleright\) Fiber attenuation in dB/km
2:\(BER\gets 0.7\times 10^{-9}\)\(\triangleright\) Communication BER
3:\(tmod[i]\)\(\triangleright\) ith modulation used
4:\(FSR\)\(\triangleright\) OFC free spectral range
5:\(Bd[j]\)\(\triangleright\) jth request bandwidth
6:\(Dd[j]\)\(\triangleright\) jth request distance
7:\(FRP\)\(\triangleright\) Optical comb spectrum in [dB]
8:\(EBN0\)\(\triangleright\) OSNR for tmod [i]
9:VA\(\triangleright\) Assignment vector with each demand
10:\(rejected\)\(\triangleright\) Rejection vector
11:
12:\(T_{mod}\leftarrow\text{length}(tmod)\)\(\triangleright\) Number of modulation formats
13:\(T_{d}\leftarrow\text{length}(Dd)\)\(\triangleright\) Request number
14:\(T_{Li}\leftarrow\text{length}(FRP)\)\(\triangleright\) Comb line number
15:for\(i\gets 1\) to \(T_{md}\)do
16:for\(j\gets 1\) to \(T_{d}\)do
17:\(bw_{mod}[i]\leftarrow\left[\frac{2\text{dB}[i]}{\text{log}(\text{mod}[i]/ \text{log}[2])}\right]\)\(\triangleright\) Compute bandwidth for tmod[i] modulation
18:\(VL[i][j]\leftarrow\left[\frac{bw_{mod}[i][j]}{\text{PSR}}\right]\)\(\triangleright\) Compute carrier number
19:if\(\text{mod}(VL[i][j],2)=0\)then\(\triangleright\) Check if VL is odd or even
20:\(VL[i][j]\gets VL[i][j]+1\)\(\triangleright\) If even, the algorithm requires a longer wavelength
21:for\(i\gets 1\) to \(T_{md}\)do
22:\(EbEN0\gets compute_{EbEN0}(log10(BER),tmod[i])\)\(\triangleright\) Compute OSNR for a modulation format
23:for\(k\gets 1\) to \(T_{Li}\)do
24:\(dist[k]\leftarrow(FRP[k]-EbEN0)/at\)\(f\)\(\triangleright\) Vector of distances for each comb line
25:\(MAD[i][k]\gets dist[k]\)\(\triangleright\) Compute distance for each tmod[i]
26:\(VP\gets 0.2 Bd+0.8 Dd\)\(\triangleright\) Cost equation for each demand
27:\([\sim,ibd]\gets sort(VP,descend)\)\(\triangleright\) Sort in descending order of cost
28:\(bId\gets Bd[ibd]\)\(\triangleright\) Organize bandwidth based on VP ordering
29:\(dId\gets Dd[ibd]\)\(\triangleright\) Organize distances based on VP ordering
30:\(VL2\gets VL[:][:,ibd]\)\(\triangleright\) Matrix of required lines ordered by VP
31:for\(i=1:T_{d}\)do
32:\(jj=0\):
33:for\(k=T_{mod}:-1:1\)do\(\triangleright\) Search from the highest to the lowest modulation format
34:\(r=MAD[k][j]\textgreater=dId[i]\)\(\triangleright\) Assign 1 to distances > i-th demand
35:if\(\sum r>=VL2[k][i]\)then\(\triangleright\) If found lines are greater or equal than required proceed
36:\(cell=specon(r)\):\(\triangleright\) Find the group of contiguous lines as a candidate for assignment
37:\(tel=length(cell)\);\(\triangleright\) Compute the size of candidate groups
38:for\(j=1:tel\)do
39:\(CE=cell(j)\);\(\triangleright\) Select candidate group
40:if\(\text{length}(CE)>=VL2[k][i]\)then\(\triangleright\) Check if group has enough lines to assign
41:\(jj=jj+1\);\(\triangleright\) Counter for groups with sufficient lines for assignment
42:for\(K=1:VL2[k][i]\)do
43:\(VA[CE[K]]=ibd[i]\);\(\triangleright\) Assign ibd[i] to VA positions for each group
44:\(MAD[:,CE[K]]=zeros(T_{mod},1)\);\(\triangleright\) Fill used lines with zeros to exclude them
45:break;\(\triangleright\) Stop iteration when demand ibd[i] is assigned
46:break;\(\triangleright\) Stop iteration when all groups have been analyzed
47:if\(jj==0\)then\(\triangleright\) If no group was assigned, add rejected request
48:\(con=con+1\);
49:\(rejected[con]=ibd[i]\);\(\triangleright\) Store rejected demand ibd[i]
50:
51:function\(compute_{EbEN0}\)\(\triangleright\) Compute OSNR for a modulation format
52:function\(specon\)\(\triangleright\) Compute the wavelength contiguous group in VA vector
```  
**Algorithm 1** RMSLA Assignment Algorithm for OFCs. Next, it sorts the requests in descending order based on a cost equation considering the bandwidth and distance, to prioritize more complex requests. The sorted requestsare then processed in order of decreasing cost, searching for the optical comb carrier that can satisfy each request.