## 6 Modified Priority-Based Greedy Heuristic  
We propose an alternative to the PG heuristic that improves the VNF placement results, reducing the number of non-allocated SFCrs and maintaining similar total cost. Following the approach of the PG solution, the heuristic proposed in this work, which is called the Modified Priority-based Greedyheuristic (ModPG), consists of two stages: an SFCr mapping stage (described in Algorithm 1) and a VNFr merging stage (described in Algorithm 2). ```
Input: MDCs: R, network status: \(\Omega_{0}\), set of SFCrs: \(\Gamma\), Substrate Network: SN; Output: Set of used MDCs: R1, network status: \(\Omega_{1}\), total cost: TC\({}_{1}\)
1 classify (\(\Gamma\)) \(\leftarrow\) Procedure 1;
2 while\(\Gamma\) is not empty:do
3\(\gamma_{x}\) = the SFCr in \(\Gamma\) with the minimum length of set_possible_MDC ;
4\(\gamma_{x}\_mapped=0\) ;
5\(mem_{\gamma_{Tx}}\) = total memory requirement of \(\gamma_{x}\) ;
6\(CPU_{\gamma_{x}}\) = total CPU requirement of \(\gamma_{x}\) ;
7 sort set_possible_MDC(\(\gamma_{x}\)) by total_delay ;
8 if\(\gamma_{x}\) not mapped:then
9 for\(n_{i}^{S}\) in set_possible_MDC(\(\gamma_{x}\)):do
10 if(avail_mem_n\({}_{i}^{S}>mem_{\gamma_{x}}\))and(avail_CPU_n\({}_{i}^{S}>CPU_{\gamma_{x}}\))then
11 map \(\gamma_{x}\) in \(n_{i}^{S}\) creating new VNFs if necessary ;
12 if(avail_mem_n\({}_{i}^{S}<SFC_{mem}^{min}\)) or(avail_CPU_n\({}_{i}^{S}<SFC_{CPU}^{min}\))then
13 remove \(n_{i}^{S}\) from set_possible_MDC of the rest of the SFCrs in \(\Gamma\) ;
14 break ;
15 if\(\gamma_{x}\) not mapped:then
16 distribute \(\Phi_{\gamma_{x}}\) to MDCs \(\in\) R / (all VNFs \(\in\Phi_{\gamma_{x}}\) are instantiated) and (max. No. consecutive VNFrs in an MDC) and (resource and delay constraints' fulfillment) ;
17 if\(\gamma_{x}\) not mapped:then
18 distribute \(\Phi_{\gamma_{x}}\) to MDCs \(\in\) R / (max. No. consecutive VNFrs in an MDC) and (resource and delay constraints' fulfillment);
19\(TC_{1}\)=obtain_total_cost \(\leftarrow\) equation (1) ;
```  
**Algorithm 1**ModPG-SFCr mapping algorithm. ```
Input: Set of used MDCs: R1, status of the network: \(\Omega_{1}\), total cost: TC\({}_{1}\) Output: Set of used MDCs: R2, status of the network: \(\Omega_{2}\), total cost: TC\({}_{2}\)
1 R\({}_{2}\)=R\({}_{1}\); \(\Omega_{2}\)=\(\Omega_{1}\); TC\({}_{2}\)=TC\({}_{1}\);
2\(\rho\)=[set of MDCs in R\({}_{2}\) in order of increasing number of mapped VNFrs];
3 for\(\rho_{i}\) in \(\rho\):do
4 R\({}_{2}^{temporal}\)=R\({}_{2}\); \(\Omega_{2}^{temporal}\)=\(\Omega_{2}\);
5\(\rho_{i,total}\)=[set of SFCrs totally mapped on \(\rho_{i}\) in order of decreasing resource requirements];
6\(\rho_{i,partial}\)=[set of SFCrs partially mapped on \(\rho_{i}\)];
7 if\(\rho_{i,partial}\) is empty:then
8\(\#\)moved=0;
9 for\(\gamma\) in \(\rho_{i,total}\):do
10 if(moving to an MDC in \(R_{2}^{temporal}\)) or(moving to MDCs in \(R_{2}^{temporal}\)):then
11\(\#\)moved++ ;
12
13 else
14 break ;
15 if\(\#\)moved==\(\rho_{i,total}\)\(|\):then
16\(\textnormal{TC}_{2}^{temporal}\)=obtain_total_cost(\(R_{2}^{temporal}\),\(\Omega_{2}^{temporal}\)) ;
17 if\(TC_{2}^{temporal}\)<TC\({}_{2}\):then
18\(\textnormal{R}_{2}\)\(\leftarrow\)R\({}_{2}^{temporal}\); \(\Omega_{2}\)\(\leftarrow\)\(\Omega_{2}^{temporal}\); TC\({}_{2}\)\(\leftarrow\)TC\({}_{2}^{temporal}\) ;
19 Although the problem statement defined in Section 4 considers Gas a variable number of CDCs, the ModPG heuristic (similarly to the PG heuristic in [13]) is defined considering a network scenario with just one CDC. A single CDC with limited resources would constrain the total set of SFCrs that could be mapped, but in both the PG and ModPG heuristics, this constraint has been considered outside the scope of this work, assuming CDC resources as infinite. A multiple CDC model will require extending the proposed heuristics by answering the problem of the load balancing among the links from MDCs to CDCs. This extension will be addressed in future works.