# RIS-Assisted Network Slicing Resource Optimization Algorithm for Coexistence of eMBB and URLLC
## 4 Problem Conversion and Solution
### Solution of URLLC Allocation Problem  
At the beginning of each mini-slot, the above three types of RIS phase shift matrices are acquired, transferred, and stored in the RIS controller. When the RIS phase shift matrix \(\mathbf{\Phi}^{m}\) is one of the pre-configured RIS phase shift matrices, i.e., substitute it to solve problem \(P2\). In other words, when the RIS is determined, the original problem becomes solving the optimal frequency and power allocation problem for URLLC services, expressed as follows:  
\[P2.1:\max_{\mathbf{P}_{L}^{m},\mathbf{K}^{m},\mathbf{I}_{L}^{m},\mathbf{I}_{L }^{m}}[f_{1}(\mathbf{k}^{m}),-f_{2}(\mathbf{I}_{E}^{m})] \tag{52}\]  
\[ \begin{array}{l}s.t.I_{l}^{m}c_{l}\geq k_{l}^{m}c_{th},\forall l\in L^{m}\\ r^{\prime}\geq r_{e},h,\forall e\in E\end{array}  \tag{53}\]  
\[0\leq P_{l}^{m}\leq P_{l}^{m,max},\forall l\in L^{m},\forall m\in M \tag{54}\]  
\[\sum_{e=1}^{E}P_{eb}+\sum_{l=1}^{L^{m}}P_{l}^{m}\leq P_{gNB} \tag{55}\]  
\[k_{l}^{m}\in\{0,1\},\forall l\in L^{m} \tag{56}\]  
\[\sum_{l=1}^{L^{m}}l_{l}^{m}=\sum_{e=1}^{E}l_{e}^{m} \tag{57}\]  
where constraint (58) ensures that the number of punctured eMBB resources equals the number of resources allocated to URLLC traffic. According to constraint (54), at mini-slot \(m\), the representation of the maximum number of available RBs allocated to URLLC packets by eMBB user \(e\) is given as follows:  
\[I_{e}^{\max,m}=\min\bigg{(}\left|\hat{b}_{e}\bigg{(}1-\frac{r_{e,th}}{r_{e}} \bigg{)}\right|,\hat{b}_{e}\bigg{)} \tag{58}\]  
After determining the number of RB allocations for the URLLC packet \(l\), the optimal power allocation expression is as follows:  
\[P_{l}^{m*}=\frac{e^{\frac{\mathbf{I}^{m}c_{th}}{2(\mathbf{I}_{L}^{m})l_{l}^{m }}}-1}{h_{l}} \tag{59}\]  
where \(h_{l}=C_{l}/\sigma^{2}\). Based on the above, \(P2.1\) can be simplified as follows:  
\[P2.2:\max_{\mathbf{K}^{m},\mathbf{I}_{L}^{m},\mathbf{I}_{E}^{m}}[f_{1}( \mathbf{k}^{m}),-f_{2}(\mathbf{I}_{E}^{m})] \tag{60}\]  
\[s.t.k_{l}^{m}\in\{0,1\},\forall l\in L^{m} \tag{61}\]\[\frac{I_{l}^{m}}{B}\leq k_{l}^{m}\leq I_{l}^{m},\forall l\in L^{m} \tag{63}\] \[\sum_{l=1}^{L^{m}}I_{l}^{m}=\sum_{e=1}^{E}I_{e}^{m}\] (64) \[\sum_{e=1}^{E}P_{eb}+\sum_{l=1}^{L^{m}}P_{l}^{m}\leq P_{gNB} \tag{55}\]0  
Given that URLLC services have strict latency requirements, low-complexity allocation algorithms are crucial for incoming URLLC packets. While ordinary iterative methods usually require a long computation time, this paper proposes low-complexity heuristic algorithms. Firstly, to improve the URLLC packet admission rate, we consider preferentially assigning URLLCs with better channel conditions. \(C_{ub}\) is known to denote the channel gain of URLLC user \(u\). Then the descending order of it is denoted as \(\mathbf{C}_{ub}=\left\{C_{ub}^{(1)},\cdots,C_{ub}^{(U)}\right\}\). Similarly, \(\mathbf{\beta}_{e}^{m}=\left\{\beta_{e}^{m(1)},\cdots,\beta_{e}^{m(E)}\right\}\) means the ascending order of eMBB users according to their URLLC load allocation weights. Secondly, the algorithm allocates resources to URLLC users \(u\) by iterating over ordered eMBB users. The iterative process guarantees that the cumulative data rate of URLLC packets on a given eMBB user is below the rate threshold. Finally, these steps are repeated for all URLLC packets while satisfying the eMBB QoS. The detailed steps of the pre-configured RIS-based heuristic allocation algorithm are given in Algorithm 3. The algorithm's time complexity is related to the number of URLLC packets \(L^{m}\), and the worst-case time complexity is O(\(L^{m}\times E\)).