# Resource Allocation for Network Slicing in RAN Using Case-Based Reasoning
## 3 Problem Formulation
\[\begin{split} s(\textbf{W})_{1}=&\parallel\textbf{X} ^{\text{T}}\textbf{W}-\textbf{Y}\parallel_{F}^{2}\\ &=(\textbf{X}^{\text{T}}\textbf{W}-\textbf{Y})^{\text{T}}( \textbf{X}^{\text{T}}\textbf{W}-\textbf{Y})\\ &=\textbf{W}^{\text{T}}\textbf{X}\textbf{X}  
wherein, L is a symmetric matrix, so \(\mathbf{L}=\mathbf{L}^{\mathrm{T}}\).  
\[\frac{\partial s(\mathbf{W})}{\partial\mathbf{W}}=2\mathbf{X}\mathbf{X}^{ \mathrm{T}}\mathbf{W}-2\mathbf{X}\mathbf{Y}+2\rho_{2}\mathbf{X}\mathbf{L} \mathbf{X}^{\mathrm{T}}\mathbf{W} =2\Big{(}\mathbf{X}\mathbf{X}^{\mathrm{T}}+\rho_{2}\mathbf{X} \mathbf{L}\mathbf{X}^{\mathrm{T}}\Big{)}\mathbf{W}-2\mathbf{X}\mathbf{Y} \tag{15}\]  
Gradient descent is performed on the smooth term to obtain an intermediate result. \[\mathbf{W}^{k+\frac{1}{2}}=\mathbf{W}^{k}-\alpha*\
abla\mathbf{s}(\mathbf{W}^{ k}) \tag{16}\]  
where \(\alpha\) is the learning rate. So  
\[\mathbf{W}^{k+\frac{1}{2}}=\mathbf{W}^{k}-2\alpha\Big{(}\mathbf{X}^{\mathrm{T }}\mathbf{X}+p_{2}\mathbf{X}\mathbf{L}\mathbf{X}^{\mathrm{T}}\Big{)}\mathbf{W }^{k}+2\alpha\mathbf{X}\mathbf{Y} \tag{17}\]  
Then the intermediate result is substituted into the non-smooth term to obtain the projection of its adjacent points, that is, to complete an iteration. \[\mathbf{W}^{k+1}=argmin_{\mathbf{W}}\{\rho_{1}||\mathbf{W}||_{1}+\frac{1}{2 \alpha}||\mathbf{W}-\mathbf{W}^{k+\frac{1}{2}}||^{2}\} \tag{18}\]  
Let  
\[v(\mathbf{W})=\left\{p_{1}\|\mathbf{W}\|_{1}+\frac{1}{2\alpha}\Big{\|}\mathbf{ W}-\mathbf{W}^{k+\frac{1}{2}}\Big{\|}^{2}\right\} \tag{19}\]  
\[\frac{\partial v(\mathbf{W})}{\partial(\mathbf{W})}=\frac{1}{\alpha}\Big{(} \mathbf{W}-\mathbf{W}^{k+\frac{1}{2}}\Big{)}+p_{1}sgn(\mathbf{W}) \tag{20}\]  
For the derivatives of the \(\rho_{1}||\mathbf{W}||_{1}\), soft thresholding [27] is used. Then, we update the \(\mathbf{W}\) as follows:  
\[\min_{\textbf{Y}=\textbf{X}^{\text{T}}\textbf{W}}\frac{1}{2}\sum_{i,j}^{d}s_{ ij}||y_{i}-y_{j}||_{2}^{2}=\min_{\textbf{W}}tr\Big{(}\textbf{W}^{\text{T}} \textbf{X}\textbf{L}\textbf{X}^{\text{T}}\textbf{W}\Big{)} \tag{7}\]0  
\[\mathbf{W}^{k+1}= \begin{cases}\mathbf{W}^{k+\frac{1}{2}}+\alpha p_{1}, \mathbf{W}^{k+\frac{1}{2}}<-\alpha p_{1}\\ 0,\Big{|}\mathbf{W}^{k+\frac{1}{2}}\Big{|}\leqslant\alpha p_{1}\\ \mathbf{W}^{k+\frac{1}{2}}-\alpha p_{1},\mathbf{W}^{k+\frac{1}{2}}>\alpha p_{1} \end{cases}  \tag{22}\]  
By the convergence theorem [28],  
\[f(\mathbf{W}(t_{k}))-f(\mathbf{W}^{*})\leqslant\frac{2\gamma L\|\mathbf{W}(1)- \mathbf{W}^{*}\|_{F}^{2}}{\left(t+1\right)^{2}} \tag{23}\]  
where \(\gamma\) is a positive predefined constant, \(L\) is a gradual Lipschitz constant. In combination with Equation (22), the \(W^{k+1}\) is as Equation (24)  
\[\mathbf{W}^{k+1}= \begin{cases}\mathbf{W}^{k}-2\alpha\Big{(}\mathbf{X} \mathbf{X}^{\mathrm{T}}+p_{2}\mathbf{X}\mathbf{L}\mathbf{X}^{\mathrm{T}} \Big{)}\mathbf{W}^{k}+2\alpha\mathbf{X}\mathbf{Y}+\alpha p_{1},\mathbf{W}^{k+ \frac{1}{2}}<-\alpha p_{1}\\ 0,\Big{|}\mathbf{W}^{k+\frac{1}{2}}\Big{|}<\alpha p_{1}\\ \mathbf{W}^{k}-2\alpha\Big{(}\mathbf{X}\mathbf{X}^{\mathrm{T}}+p_{2}\mathbf{ X}\mathbf{L}\mathbf{X}^{\mathrm{T}}\Big{)}\mathbf{W}^{k}+2\alpha\mathbf{X} \mathbf{Y}-\alpha p_{1},\mathbf{W}^{k+\frac{1}{2}}>\alpha p_{1}\end{cases}  \tag{24}\]  
The pseudocode of O-KNN is given in Algorithm 2. ```
1:\(\mathbf{X},\mathbf{Y}(\mathbf{X}\in\mathbb{R}^{n\times d},\mathbf{Y}\in\mathbb{R}^ {d\times m})\);
2:predict solution \(\hat{y}\);
3:Initialize \(y_{0}=\mathbf{W}^{0}\in\mathbb{R}^{n\times m}\), \(t_{0}=1\).